How to check if all players are dead?
#2

pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    new j;

    for(new i; i < MAX_PLAYERS; i++) // Loop through players (foreach Recommended)
    {
        if(cantspawn[i] == 0) j++; // If someone is alive, increase j by 1.
        if(j > 1) break; // If j is more than 1, break loop (for efficiency)
    }
   
    if(j == 1) // Check that there is only 1 player alive
    {
        // killerid is the winner.
    }
    return 1;
}
Untested - Probably not the most efficient way.

EDIT: This will only work if the second last player is killed by the last player. If he died by falling etc, it wouldn't work. For that you would need to use a timer.
Reply


Messages In This Thread
How to check if all players are dead? - by BlackWolf120 - 01.04.2011, 14:24
Re: How to check if all players are dead? - by JamesC - 01.04.2011, 14:43
Re: How to check if all players are dead? - by BlackWolf120 - 01.04.2011, 21:36
Re: How to check if all players are dead? - by BlackWolf120 - 01.04.2011, 23:30
AW: Re: How to check if all players are dead? - by Manuel1948 - 01.04.2011, 23:32
Re: How to check if all players are dead? - by BlackWolf120 - 02.04.2011, 13:53
Re: How to check if all players are dead? - by coole210 - 02.04.2011, 14:49
Re: How to check if all players are dead? - by BlackWolf120 - 02.04.2011, 16:30

Forum Jump:


Users browsing this thread: 1 Guest(s)