Count how many players are connected - 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 how many players are connected (
/showthread.php?tid=416792)
Count how many players are connected -
Vlaoff - 18.02.2013
Hello,
I'd need to count how many players are ingame(for a tp command ) , but can't figure out how to do it. I'm pretty sure there is a simple function doing this, can you help me to find it ?
Thanks,
Re: Count how many players are connected -
Falcon. - 18.02.2013
pawn Код:
new playersC;
public OnPlayerConnect(playerid)
{
playersC ++;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
playersC --;
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/playersC", true))
{
static string[21];
format(string, 21, "players in-game: %02i", playersC);
return SendClientMessage(playerid, -1, string);
}
return 0;
}

Re: Count how many players are connected -
Stylock - 18.02.2013
Use foreach include and:
Re: Count how many players are connected -
Vlaoff - 18.02.2013
Ok(falcon) thats the way i do it, but i asked in case there is an other way to do it.
I'll look at the foreach include
Thanks guys,