Skip to content

Commit

Permalink
Avoid setting human class twice & remove unused variable (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vauff authored Nov 5, 2023
1 parent 8fcb6f4 commit 07d4dc2
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions scripts/vscripts/ZombieReborn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ require("ZombieReborn.AmmoReplenish")
require("ZombieReborn.PlayerClass")
require("ZombieReborn.AntiStack")

ZR_ROUND_STARTED = false
ZR_ZOMBIE_SPAWNED = false -- Check if first zombie spawned
ZR_ZOMBIE_SPAWN_READY = false -- Check if first zombie is spawning

Expand Down Expand Up @@ -54,23 +53,10 @@ function OnRoundStart(event)
ScriptPrintMessageChatAll("The game is \x05Humans vs. Zombies\x01, the goal for zombies is to infect all humans by knifing them.")

--Setup various functions and gameplay elements
SetAllHumanClasses()
SetupRespawnToggler()
SetupAmmoReplenish()

Timers:RemoveTimer("MZSelection_Timer")

ZR_ROUND_STARTED = true
end

function SetAllHumanClasses()
for i = 1, 64 do
local hController = EntIndexToHScript(i)

if hController ~= nil and hController:GetPawn() ~= nil then
InjectPlayerClass(PickRandomHumanDefaultClass(), hController:GetPawn())
end
end
end

function OnPlayerHurt(event)
Expand Down Expand Up @@ -141,9 +127,9 @@ function OnPlayerSpawn(event)
return
end

-- assign human class for those who missed the human class assignment
if ZR_ROUND_STARTED and not ZR_ZOMBIE_SPAWNED and hPlayer:GetTeam() == CS_TEAM_CT then
DoEntFireByInstanceHandle(hPlayer, "RunScriptCode", "InjectPlayerClass(PickRandomHumanDefaultClass(), thisEntity)", 0.01, nil, nil)
-- assign human class
if not ZR_ZOMBIE_SPAWNED and hPlayer:GetTeam() == CS_TEAM_CT then
DoEntFireByInstanceHandle(hPlayer, "RunScriptCode", "InjectPlayerClass(PickRandomHumanDefaultClass(), thisEntity)", 0.0, nil, nil)
end
end

Expand Down

0 comments on commit 07d4dc2

Please sign in to comment.