if (team.NumPlayers(1) < 1) then
PrintMessage( HUD_PRINTCENTER, "Your mom Wins" )
team.AddScore( 2 , 1 )
timer.Create ( "RoundRestart" , 5 , 1 , function ()
game.CleanUpMap()
ply:StripWeapons()
ply:Spawn()
PrintMessage( printScore )
PrintMessage( printScore )
end)
end
Mine is not working, im pretty new. Basically when i die it doesnt pop up your mom wins.
How is this code being executed, playerdeath hook or what?
My bad, Yes its from playerdeath
I’d suggest storing the players team in a variable with
ply:Team()
And use that with some other if statements inside the death hook. That way you are always going to be sure you are getting the correct team index.
You can use
team.GetName()
With that variable to make sure that you are going to be using the correct team.
This isn't getting the alive players, this is just seeing if one team has less than one player, I would set a variable when a player dies and check if that variable is less than or equal to one
tried my best but can you give me more tips ?
Is there any way to not have this :
"attempt to compare string with number"
Hey! I'm kinda new too!
How I did it (someone recommend a better way if this isn't the proper way)
I just did a custom function, define ply with player.GetAll()
set a local value like "allAreDead" to 0
then did a loop that checks if each player is dead, if it found that a player was dead it added 1 to the "allAreDead" value.
I then did a check to see if allAreDead was equal to the entire player table and if it was then 'do stuff'.
If you're doing it for a team then I think this is how you would do it:
function deathCheck()
local team1 = team.GetPlayers()
local team1death = 0
for _,v in pairs(team1) do
if !v:Alive() then
team1death = team1death +1
end
end
if alldeadz == table.Count(team1) then
endRound()
end
end
hook.Add("PlayerDeath","teamChk", deathCheck)
hey man thanks! i'll let you know if it works
what is the error?
Sorry, you need to Log In to post a reply to this thread.