I am having problems coming up with a piece of code that runs a function when everyone on one team dies. If you haven't guessed the gamemode is TeamVsTeam.
I currently have two teams "defender" (ID = 1) and "attacker" (ID = 2).
The function needed to be ran would be "defender_win"(When whole attacker team dies) and "attacker_win"(When whole defender team dies).
I will be very grateful for whoever can help me. Thankyou.
If you need any more info just ask in comments. I believe the info above should be all that is necessary.
[lua]hook.Add( "PlayerDeath", "", function( ply, inflictor, attacker )
team1 = true -- as if all players are dead
team2 = true
for k, v in pairs( team.GetPlayers( 1 ) ) do
if v:Alive() then team1 = false end -- if a single one is alive reverse the variable
end
for k, v in pairs( team.GetPlayers( 2 ) ) do
if v:Alive() then team2 = false end -- " "
end
if team1 then attacker_win()
elseif team2 then defender_win()
end -- return the winning team if either of the teams are wiped out
end )[/lua]
Sorry, you need to Log In to post a reply to this thread.