[Question] Connections - 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: [Question] Connections (
/showthread.php?tid=163518)
[Question] Connections -
tony_fitto - 27.07.2010
Hey everyone.
I just have a simple question, do anyone know how i can create a command so if i type /count the server counts how many players there are online.
I know how to make a command but not to know how many players there are online
Re: [Question] Connections -
DJDhan - 27.07.2010
Code:
if(!strcmp(cmdtext,"/count",true))
{
new count,string[128];
for(new i=0;i<GetMaxPlayers();i++)
{
if(IsPlayerConnected(i)) count ++;
}
format(string,128,"%d players are currently online.",count);
SendClientMessage(playerid,0xffff00aa,string);
return 1;
}
The easy way would be to press "Tab" and see the number of players online.
Re: [Question] Connections -
Conroy - 27.07.2010
pawn Code:
//This can be used in any command or any function.
new PlayerCount;
for(new i; i <= MAX_PLAYERS; i++) {
if(IsPlayerConnected(i) && !IsPlayerNPC(i)) {
PlayerCount++;
}
}
/*
Then use PlayerCount in a formatted string.
You can also do this for the amount of admins online by using:
if(IsPlayerConnected(i) && !IsPlayerNPC(i) && IsPlayerAdmin(playerid)) {
*/
EDIT: Beat me to it. ^^