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



Count Players In Server - StrickenKid - 12.04.2009

Will this stock function i made work?

pawn Код:
stock CountPlayers()
{
  new count = 0;
  for (new i = 0; i < MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected(i))
    {
      count++;
    }
  }
  return count;
}
Thanks!


Re: Count Players In Server - Marcel - 12.04.2009

Yes


Re: Count Players In Server - StrickenKid - 12.04.2009

k thanks


Re: Count Players In Server - OmeRinG - 12.04.2009

Why did you open a thread for that? couldn't you just check :S?


Re: Count Players In Server - StrickenKid - 12.04.2009

yah, but sometimes it works but i didnt do something right which lead to errors further on :S


Re: Count Players In Server - 90NINE - 12.04.2009

pawn Код:
new Players;

public OnPlayerConnect(playerid)
{
  Players++;
  return 1;
}

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