SA-MP Forums Archive
Help with getting all players - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help with getting all players (/showthread.php?tid=410529)



Help with getting all players - Kudoz - 25.01.2013

Hello! I'm making a gamemode, and I need help.
When a player dies, I need it to announce how many people which is still going.

So like, ".: ( %s ) has died! There are ( numbers of surviviors ) opponents left! :."


Re: Help with getting all players - DrDoom151 - 25.01.2013

Make a global variable which you increase when there's a new survivor (or a player connects) and decrease when a survivor dies (or disconnects).

Easy example:
pawn Код:
new TotalSurvivors=0;

public OnPlayerConnect(playerid)
{
    TotalSurvivors++;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    TotalSurvivors--;
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    new string[124], PlayerName[MAX_PLAYERNAME];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName);
    TotalSurvivors--;
    format(string, sizeof(string), "%s has died, there are %i survivors remaining.", PlayerName, TotalSurvivors);
    return 1;
}