Getting the amount of players online. - 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: Getting the amount of players online. (
/showthread.php?tid=267019)
Getting the amount of players online. -
Luis- - 06.07.2011
Hello, I would like to see if I can get the amount of players online, here is my code which I have now.
pawn Код:
format(string, sizeof(string), "~r~%d~w~/~b~%d ~y~Players Online", GetMaxPlayers());
Cheers.
Re: Getting the amount of players online. -
Luis- - 06.07.2011
Please could some one attempt to help, I really need this fixed.
Re: Getting the amount of players online. -
Skylar Paul - 06.07.2011
Easy! Just create a variable..
OnPlayerConnect:
OnPlayerDisconnect:
Wallah!
Re: Getting the amount of players online. -
BlackWolf120 - 06.07.2011
hi,
you could also count the players with a variable on the server:
pawn Код:
new Players;
//OnPlayerConnect
Players++;
//OnPlayerDisconnect
Players--;
//and show them where u want...
format(string, sizeof(string), "%d Players Online", Players);
SendClientMessage(playerid,colour,string);
regards, wolf.
//edit: damn, too slow
Re: Getting the amount of players online. - [L3th4l] - 06.07.2011
pawn Код:
stock OnlinePlayers() return Itter_Count(Player);
Re: Getting the amount of players online. -
Luis- - 06.07.2011
Thanks, I have done it now

.
Re: Getting the amount of players online. -
Shadoww5 - 06.07.2011
I think it works:
PHP код:
forward Check();
public Check()
{
new players;
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(IsPlayerConnected(i)) players++;
}
return players;
}
format(string, sizeof(string), "~r~%d~w~/~b~%d ~y~Players Online", Check, GetMaxPlayers());