Zombie Survival random zombie selector immunity

Ive been trying to figure this out, and im not too good with lua, my current code is



	if ( pl:SteamID() == "" ) then 

	else	 if vols == desiredzombies then
		for _, pl in pairs(voltab) do
			pl:SetTeam(TEAM_UNDEAD)
			DeadSteamIDs[pl:SteamID()] = true
			pl:StripWeapons()
			pl:Spawn()
			umsg.Start("recvolfirstzom", pl)
			umsg.End()
		end
	elseif vols < desiredzombies then
		local spawned = 0
		for i, pl in ipairs(voltab) do
			pl:SetTeam(TEAM_UNDEAD)
			DeadSteamIDs[pl:SteamID()] = true
			pl:StripWeapons()
			pl:Spawn()
			umsg.Start("recvolfirstzom", pl)
			umsg.End()
			spawned = i
		end

		for i = 1, desiredzombies - spawned do
			local humans = team.GetPlayers(TEAM_HUMAN)

			if 0 < #humans then
				local pl = humans[math.random(1, #humans)]
				pl:SetTeam(TEAM_UNDEAD)
				DeadSteamIDs[pl:SteamID()] = true
				pl:StripWeapons()
				pl:Spawn()
				umsg.Start("recranfirstzom", pl)
				umsg.End()
			end
		end
	elseif desiredzombies < vols then
		for i, pl in ipairs(voltab) do
			if desiredzombies < i and pl:Team() == TEAM_HUMAN then
				pl:SetPos(self:PlayerSelectSpawn(pl):GetPos())
			else
				pl:SetTeam(TEAM_UNDEAD)
				DeadSteamIDs[pl:SteamID()] = true
				pl:StripWeapons()
				pl:Spawn()
				umsg.Start("recvolfirstzom", pl)
				umsg.End()
			end
		end
	end
end

But i cant figure out where to put it, and if i put it in the gm:setrandomstozombie or gm:setrandomtozombie
It doesnt seemly do anything

Anybody know what im doing wrong?