SA-MP Forums Archive
Counting registered players. - 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: Counting registered players. (/showthread.php?tid=497483)



Counting registered players. - SyntaxQ - 27.02.2014

I want to count all the registered users and display them in a dialog.
Can you tell me how to count all user files or registered users?


Re: Counting registered players. - Kwarde - 27.02.2014

Well, you could make a system that counts when a player registers. So instead of counting files (no idea how to do that, as far as I know that's not possible) you could update a variable in a file when a player registers. Know what I mean?


Re: Counting registered players. - SyntaxQ - 27.02.2014

I made a variable, and incremented it when the player registers but when i restart my server it lost its value.. :S
EDIT: What do you mean by update a variable in a file?


Re: Counting registered players. - Kwarde - 27.02.2014

Well, if you are using Dini or Djson or userfiles like that; you don't have to make an userfile persй. For example, if your variable is RegisteredPlayers;

pawn Код:
OnPlayerRegister() //Off course, when a player is registered. Doesn't actually exist (standard)
{
    new str[45];
    RegisteredPlayers++;
    djSetInt("ServerFile.ini", RegisteredPlayers, RegisteredPlayers); //or dini_IntSet etc.
    format(str, 45, "There are now %d registered users!", RegisteredPlayers);
    SendClientMessageToAll(0xFFFFFFAA, str);
}
Something like that. Just save that variable into a file. And off course, load it when the server is loading