SA-MP Forums Archive
Count joins - 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 joins (/showthread.php?tid=604451)



Count joins - Harty - 05.04.2016

How to count player's joins after the last server restart and get the info by a string??

Thanks.


Re: Count joins - AndySedeyn - 05.04.2016

Create a global variable that you'll use to keep record on the amount of connections, increment the variable when a new player connects and reset it under OnGameModeInit (when the server [re]starts):

PHP код:
new playersJoined;
public 
OnGameModeInit() {
    
playersJoined 0;
    return 
true;
}
public 
OnPlayerConnect(playerid) {
    
playersJoined ++;
    return 
true;
}
// Assuming you're using ZCMD
CMD:lastserverrestart(playerid) {
    new
        
string[61];
    
format(stringsizeof(string), "%i players have connected since the last server restart."playersJoined);
    
SendClientMessage(playerid, -1string);
    return 
true;

If that's not what you meant, then please elaborate.


Re: Count joins - Harty - 05.04.2016

Thanks.

My 'stupid' issue, was that i wrote %s instead of %d, so it was showing buggy.

Thanks again for your answer speed. +REP


Re: Count joins - Harty - 05.04.2016

Do count has a limit?

Thanks.


Re: Count joins - Vanter - 05.04.2016

No Variables don't have number limits
the limit is too much for anyone to handle, lol


Re: Count joins - AndySedeyn - 05.04.2016

Yes: 2,147,483,647 (signed* 32 bit).

* PAWN is a typeless 32 bit scripting language and integer variables are by default signed.


Re: Count joins - Harty - 05.04.2016

Btw i don't think on my server will totally join 2 billions of players on 24 hours.

Thanks & Best Regards.