How to check if all players are dead?
#5

Its important that you set all cantspawn[playerid]=1 on playerconnect if the connecting players shouldn't spawn and play, if you don't want this forgott it. A must-do is to set cantspawn[playerid]=1 on playerdisconnect and on gamemodeinit

[QUOTE=JamesC;1147535]
pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    new j,klid;

    for(new i=0; i < MAX_PLAYERS; i++) // Loop through players (foreach Recommended)
    {
        if(cantspawn[i] == 0) {j++; klid=i;} // If someone is alive, increase j by 1; Save playerid in klid.
        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
    {
        // klid is the winner.
    }
    return 1;
}
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)