Fix noxapi thinking all are supporters.

Changed zombiegasses effects.
This commit is contained in:
JetBoom 2014-12-23 11:26:08 -05:00
parent 8dffa52522
commit 714f3e88a6
2 changed files with 54 additions and 47 deletions

View file

@ -19,31 +19,41 @@ function ENT:Think()
end end
end end
local particleTable = {
[ 1 ] = { particle = "particle/smokesprites_0001", sizeStart = 0, sizeEnd = 96, airRecis = 90, startAlpha = 180, endAlpha = 0, randXY = 46, randZMin = 34, randZMax = 72, color = Color( 0, 80, 0 ), rotRate = 0.9, lifeTimeMin = 1.8, lifeTimeMax = 2.9 },
[ 2 ] = { particle = "particle/smokesprites_0002", sizeStart = 0, sizeEnd = 90, airRecis = 76, startAlpha = 110, endAlpha = 0, randXY = 24, randZMin = 24, randZMax = 62, color = Color( 0, 120, 0 ), rotRate = 0.6, lifeTimeMin = 1.6, lifeTimeMax = 2.2 },
[ 3 ] = { particle = "particle/smokesprites_0003", sizeStart = 0, sizeEnd = 140, airRecis = 49, startAlpha = 130, endAlpha = 0,randXY = 36, randZMin = 39, randZMax = 42, color = Color( 0, 90, 0 ), rotRate = 0.6, lifeTimeMin = 1.8, lifeTimeMax = 2.4 },
[ 4 ] = { particle = "particle/smokesprites_0004", sizeStart = 0, sizeEnd = 100, airRecis = 59, startAlpha = 160, endAlpha = 0,randXY = 42, randZMin = 31, randZMax = 68, color = Color( 0, 60, 0 ), rotRate = 0.2, lifeTimeMin = 1.6, lifeTimeMax = 2.9 },
[ 5 ] = { particle = "particle/smokesprites_0007", sizeStart = 0, sizeEnd = 160, airRecis = 79, startAlpha = 180, endAlpha = 0,randXY = 46, randZMin = 16, randZMax = 56, color = Color( 0, 70, 0 ), rotRate = 1.4, lifeTimeMin = 1.6, lifeTimeMax = 2.2 },
[ 6 ] = { particle = "particle/smokesprites_0008", sizeStart = 0, sizeEnd = 60, airRecis = 46, startAlpha = 190, endAlpha = 0,randXY = 49, randZMin = 12, randZMax = 48, color = Color( 0, 90, 0 ), rotRate = 1, lifeTimeMin = 1.7, lifeTimeMax = 2.4 },
[ 7 ] = { particle = "particle/particle_glow_03", sizeStart = 0, sizeEnd = 4, airRecis = 4, startAlpha = 255, endAlpha = 0,randXY = 69, randZMin = 16, randZMax = 64, color = Color( 0, 255, 0 ), rotRate = 0, lifeTimeMin = 1.5, lifeTimeMax = 2.8 },
}
function ENT:Draw() function ENT:Draw()
if GAMEMODE.ZombieEscape or CurTime() < self.NextGas then return end if GAMEMODE.ZombieEscape or CurTime() < self.NextGas then return end
self.NextGas = CurTime() + math.Rand(0.08, 0.2) self.NextGas = CurTime() + math.Rand( 0.05, 0.25 )
local radius = self:GetRadius() local pos = self:GetPos()
local vecRan = VectorRand()
vecRan:Normalize()
local particledata = particleTable[math.random(7)]
vecRan = vecRan * math.Rand( 20, 40 )
vecRan.z = math.Rand( 10, 60 )
local randdir = VectorRand() local emitter = ParticleEmitter( pos )
randdir.z = math.abs(randdir.z) emitter:SetNearClip( 48, 64 )
randdir:Normalize()
local emitpos = self:GetPos() + randdir * math.Rand(0, radius / 2)
local emitter = ParticleEmitter(emitpos) local particle = emitter:Add( particledata.particle, pos + vecRan )
emitter:SetNearClip(48, 64) particle:SetVelocity( Vector( math.Rand( -particledata.randXY, particledata.randXY ), math.Rand( -particledata.randXY, particledata.randXY ), math.Rand( particledata.randZMin, particledata.randZMax ) ) )
particle:SetColor( particledata.color.r, particledata.color.g, particledata.color.b )
local particle = emitter:Add("particles/smokey", emitpos) particle:SetAirResistance( particledata.airRecis )
particle:SetVelocity(randdir * math.Rand(8, 256)) particle:SetCollide( true )
particle:SetAirResistance(64) particle:SetDieTime( math.Rand( particledata.lifeTimeMin , particledata.lifeTimeMax ) )
particle:SetDieTime(math.Rand(1.2, 2.5)) particle:SetStartAlpha( particledata.startAlpha )
particle:SetStartAlpha(math.Rand(70, 90)) particle:SetEndAlpha( particledata.endAlpha )
particle:SetEndAlpha(0) particle:SetStartSize( particledata.sizeStart )
particle:SetStartSize(1) particle:SetEndSize( particledata.sizeEnd )
particle:SetEndSize(radius * math.Rand(0.25, 0.45)) particle:SetRollDelta( math.Rand( -particledata.rotRate, particledata.rotRate ) )
particle:SetRoll(math.Rand(0, 360))
particle:SetRollDelta(math.Rand(-1, 1))
particle:SetColor(0, math.Rand(40, 70), 0)
emitter:Finish() emitter:Finish()
end end

View file

@ -47,8 +47,8 @@ end
function CACHE:Save() function CACHE:Save()
local tosave = {} local tosave = {}
for steamid, level in pairs(self.Cache) do for _, cached in pairs(self.Cache) do
table.insert(tosave, steamid.."="..level) table.insert(tosave, cached[1].."="..cached[2])
end end
file.Write("noxapi_cache.txt", table.concat(tosave, "\n")) file.Write("noxapi_cache.txt", table.concat(tosave, "\n"))
@ -69,28 +69,36 @@ end
function CACHE:BufferRequest() function CACHE:BufferRequest()
local IDS = {} local IDS = {}
local steamid_to_player = {}
local steamids = {}
for i=1, math.min(10, #Buffer) do for i=1, math.min(10, #Buffer) do
IDS[#IDS + 1] = {Buffer[1][1], Buffer[1][2]} IDS[#IDS + 1] = {Buffer[1][1], Buffer[1][2]}
steamids[#steamids + 1] = Buffer[1][1]
table.remove(Buffer, 1) table.remove(Buffer, 1)
end end
local SIDS = {} for _, pl in pairs(player.GetAll()) do
for k, v in pairs(IDS) do steamid_to_player[pl:SteamID()] = pl
SIDS[k] = v[1]
end end
http.Fetch("http://www.noxiousnet.com/api/player/memberlevel?steamids="..table.concat(SIDS, ","), function(body, len, headers, code) http.Fetch("http://www.noxiousnet.com/api/player/memberlevel?steamids="..table.concat(steamids, ","), function(body, len, headers, code)
local levels = string.Explode(",", body) local levels = string.Explode(",", body)
if #levels == #SIDS then if #levels == #IDS then
local allplayers = player.GetAll()
for k, v in pairs(levels) do for k, v in pairs(levels) do
local steamid = IDS[k][1] local kv = string.Explode("=", v)
if #kv == 2 then
local steamid = kv[1]
local level = tonumber(kv[2]) or 0
local pl = steamid_to_player[steamid]
local pl = IDS[k][2] if (level == 1 or level == 2) and pl and pl:IsValid() then
if pl and pl:IsValid() then pl:SetDTBool(15, true)
pl:SetDTBool(15, true) pl:PrintMessage(HUD_PRINTTALK, SUPPORTER_MESSAGE)
pl:PrintMessage(HUD_PRINTTALK, SUPPORTER_MESSAGE) end
CACHE:Set(steamid, level)
end end
CACHE:Set(steamid, level)
end end
end end
end) end)
@ -112,22 +120,11 @@ hook.Add("PlayerInitialSpawn", "noxapi", function(pl)
local steamid = pl:SteamID() local steamid = pl:SteamID()
local memberlevel = CACHE:Get(steamid) local memberlevel = CACHE:Get(steamid)
if memberlevel then if memberlevel then
if level == 1 or level == 2 then if memberlevel == 1 or memberlevel == 2 then
pl:SetDTBool(15, true) pl:SetDTBool(15, true)
pl:PrintMessage(HUD_PRINTTALK, SUPPORTER_MESSAGE) pl:PrintMessage(HUD_PRINTTALK, SUPPORTER_MESSAGE)
end end
else else
http.Fetch("http://www.noxiousnet.com/api/player/memberlevel?steamid="..steamid, function(body, len, headers, code)
local level = tonumber(body) or 0
if level == 1 or level == 2 then
pl:SetDTBool(15, true)
pl:PrintMessage(HUD_PRINTTALK, SUPPORTER_MESSAGE)
end
CACHE:Set(steamid, level)
end)
table.insert(Buffer, {steamid, pl}) table.insert(Buffer, {steamid, pl})
CACHE:WaitForBuffer() CACHE:WaitForBuffer()
end end