From 714f3e88a66b4d697a225fae5cf1343aa69eeff6 Mon Sep 17 00:00:00 2001 From: JetBoom Date: Tue, 23 Dec 2014 11:26:08 -0500 Subject: [PATCH] Fix noxapi thinking all are supporters. Changed zombiegasses effects. --- .../entities/zombiegasses/cl_init.lua | 52 +++++++++++-------- .../zombiesurvival/gamemode/noxapi/server.lua | 49 ++++++++--------- 2 files changed, 54 insertions(+), 47 deletions(-) diff --git a/gamemodes/zombiesurvival/entities/entities/zombiegasses/cl_init.lua b/gamemodes/zombiesurvival/entities/entities/zombiegasses/cl_init.lua index 1fe6cd7..14f4d04 100644 --- a/gamemodes/zombiesurvival/entities/entities/zombiegasses/cl_init.lua +++ b/gamemodes/zombiesurvival/entities/entities/zombiegasses/cl_init.lua @@ -19,31 +19,41 @@ function ENT:Think() 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() 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 emitter = ParticleEmitter( pos ) + emitter:SetNearClip( 48, 64 ) - local randdir = VectorRand() - randdir.z = math.abs(randdir.z) - randdir:Normalize() - local emitpos = self:GetPos() + randdir * math.Rand(0, radius / 2) - - local emitter = ParticleEmitter(emitpos) - emitter:SetNearClip(48, 64) - - local particle = emitter:Add("particles/smokey", emitpos) - particle:SetVelocity(randdir * math.Rand(8, 256)) - particle:SetAirResistance(64) - particle:SetDieTime(math.Rand(1.2, 2.5)) - particle:SetStartAlpha(math.Rand(70, 90)) - particle:SetEndAlpha(0) - particle:SetStartSize(1) - particle:SetEndSize(radius * math.Rand(0.25, 0.45)) - particle:SetRoll(math.Rand(0, 360)) - particle:SetRollDelta(math.Rand(-1, 1)) - particle:SetColor(0, math.Rand(40, 70), 0) + local particle = emitter:Add( particledata.particle, pos + vecRan ) + 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 ) + particle:SetAirResistance( particledata.airRecis ) + particle:SetCollide( true ) + particle:SetDieTime( math.Rand( particledata.lifeTimeMin , particledata.lifeTimeMax ) ) + particle:SetStartAlpha( particledata.startAlpha ) + particle:SetEndAlpha( particledata.endAlpha ) + particle:SetStartSize( particledata.sizeStart ) + particle:SetEndSize( particledata.sizeEnd ) + particle:SetRollDelta( math.Rand( -particledata.rotRate, particledata.rotRate ) ) emitter:Finish() end diff --git a/gamemodes/zombiesurvival/gamemode/noxapi/server.lua b/gamemodes/zombiesurvival/gamemode/noxapi/server.lua index 476cf6a..f6b00bc 100644 --- a/gamemodes/zombiesurvival/gamemode/noxapi/server.lua +++ b/gamemodes/zombiesurvival/gamemode/noxapi/server.lua @@ -47,8 +47,8 @@ end function CACHE:Save() local tosave = {} - for steamid, level in pairs(self.Cache) do - table.insert(tosave, steamid.."="..level) + for _, cached in pairs(self.Cache) do + table.insert(tosave, cached[1].."="..cached[2]) end file.Write("noxapi_cache.txt", table.concat(tosave, "\n")) @@ -69,28 +69,36 @@ end function CACHE:BufferRequest() local IDS = {} + local steamid_to_player = {} + local steamids = {} for i=1, math.min(10, #Buffer) do IDS[#IDS + 1] = {Buffer[1][1], Buffer[1][2]} + steamids[#steamids + 1] = Buffer[1][1] table.remove(Buffer, 1) end - local SIDS = {} - for k, v in pairs(IDS) do - SIDS[k] = v[1] + for _, pl in pairs(player.GetAll()) do + steamid_to_player[pl:SteamID()] = pl 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) - if #levels == #SIDS then + if #levels == #IDS then + local allplayers = player.GetAll() + 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 pl and pl:IsValid() then - pl:SetDTBool(15, true) - pl:PrintMessage(HUD_PRINTTALK, SUPPORTER_MESSAGE) + if (level == 1 or level == 2) and pl and pl:IsValid() then + pl:SetDTBool(15, true) + pl:PrintMessage(HUD_PRINTTALK, SUPPORTER_MESSAGE) + end + + CACHE:Set(steamid, level) end - - CACHE:Set(steamid, level) end end end) @@ -112,22 +120,11 @@ hook.Add("PlayerInitialSpawn", "noxapi", function(pl) local steamid = pl:SteamID() local memberlevel = CACHE:Get(steamid) if memberlevel then - if level == 1 or level == 2 then + if memberlevel == 1 or memberlevel == 2 then pl:SetDTBool(15, true) pl:PrintMessage(HUD_PRINTTALK, SUPPORTER_MESSAGE) end 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}) CACHE:WaitForBuffer() end