SA-MP Forums Archive
Count Players in Map - 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: Count Players in Map (/showthread.php?tid=478119)



Count Players in Map - Avi Raj - 28.11.2013

Hello,

I have a define :-
pawn Код:
if(DerbyStartedMap1 == 0)
{
      //styufff
      DerbyStartedMap1 = 1;
}
I Want something that i could get like the Last player in that Map.
He/she should get a Message :- You have won the derby.

If anyone can make this, I Will appreciate it.
Thanks.


Re: Count Players in Map - ikbenremco - 28.11.2013

When will the players leave the map? Upon death? Or when?

Create a new global variable;

PHP код:
new PlayersInDerby 0
playervariable:

PHP код:
InDerby[MAX_PLAYERS]; 
When they write the command or any other way to join the derby:

PHP код:
PlayersInDerby ++; 
InDerby[playerid] = 1;

When they leave;

InDerby[playerid] = 0;
PHP код:
PlayersInDerby --; 
PHP код:
if(PlayersInDerby == 1
{
        foreach(
Playeri)
    {
               if(
IsPlayerConnected(i))
          {
                     if(
InDerby[i] == 1)
                     {
                             
format(stringsizeof(string), "Player ID %d has won the derby!"i);
                             
SendClientMessageToAll(0xFFFFFFFstring);
                     }
              }
         }