SA-MP Forums Archive
How to put number of player currently playing ? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to put number of player currently playing ? (/showthread.php?tid=135827)



How to put number of player currently playing ? - Noredine - 21.03.2010

How to put number of player currently playing ?

Exemple : %s joined the server. currently playing (Number Of Player)




Re: How to put number of player currently playing ? - TheChaoz - 21.03.2010

pawn Код:
public OnPlayerConnect(playerid)
{
  new name[MAX_PLAYER_NAME], str[128];
  GetPlayerName(playerid, name, sizeof(name));
  format(str, sizeof(str), "%s (%d) Has joined the server", name, playerid);
  SendClientMessageToAll(0x808080FF, str);
  return 1;
}
hope it helps u

ahah, now i understand what u want.
thy this:
pawn Код:
new PlayersCount;

public OnPlayerConnect(playerid)
{
  PlayersCount++;
  new name[MAX_PLAYER_NAME], str[128];
  GetPlayerName(playerid, name, sizeof(name));
  format(str, sizeof(str), "%s (%d) Has joined the server. [Current Players: %d]", name, playerid, PlayersCount);
  SendClientMessageToAll(0x808080FF, str);
  return 1;
}

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



Re: How to put number of player currently playing ? - adsy - 21.03.2010

look at my filterscript (check signature)


Re: How to put number of player currently playing ? - Noredine - 22.03.2010

Doesn't work

I have error with PlayerCounts++


Re: How to put number of player currently playing ? - Noredine - 22.03.2010

Quote:
Originally Posted by Noredine
Doesn't work

I have error with PlayerCounts++
Can you give me good code please.


Re: How to put number of player currently playing ? - Finn - 22.03.2010

Quote:
Originally Posted by the_chaoz
thy this:
pawn Код:
new PlayersCount;

public OnPlayerConnect(playerid)
{
  PlayersCount++;
  new name[MAX_PLAYER_NAME], str[128];
  GetPlayerName(playerid, name, sizeof(name));
  format(str, sizeof(str), "%s (%d) Has joined the server. [Current Players: %d]", name, playerid, PlayersCount);
  SendClientMessageToAll(0x808080FF, str);
  return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
  PlayersCount--;
  return 1;
}
Your question was answered and the code was given to you, what's wrong?


Re: How to put number of player currently playing ? - GTAIV2008 - 22.03.2010

pawn Код:
new count;
for(new i;i<MAX_PLAYERS;i++)
{
    if(IsPlayerConnected(i))
      count++;
}
count will store the currently connected players.


Re: How to put number of player currently playing ? - Noredine - 22.03.2010

Quote:
Originally Posted by GTAIV2008
pawn Код:
new count;
for(new i;i<MAX_PLAYERS;i++)
{
    if(IsPlayerConnected(i))
      count++;
}
count will store the currently connected players.
Ok i add this where ? End of script or Top of script


Re: How to put number of player currently playing ? - GTAIV2008 - 22.03.2010

Add it where you want to use it
In cmds or something like that, the code above is NOT an actual function working on its own.


Re: How to put number of player currently playing ? - Noredine - 22.03.2010

Quote:
Originally Posted by GTAIV2008
Add it where you want to use it
In cmds or something like that, the code above is NOT an actual function working on its own.
Ok and you can give me the code current players if he leave

exemple : Guys has joined the server . [Current Players : 12]
after : Guys has leaved the server . [Current Players : 11]

U know what i need ?