TOTAL online time
#4

Keeping multiple variables for time is inefficient, as is using timers. You only need one unit of time (usually seconds) and all the rest can be deducted from that; 86400 seconds is 1440 minutes is 24 hours is 1 day. That is the principle of the Unix timestamp.
PHP код:
new gTimeJoined[MAX_PLAYERS]; 
When the player logs in you save a timestamp.
PHP код:
gTimeJoined[playerid] = gettime(); 
When the player leaves (or requests his stats) you calculate the difference.
PHP код:
new difference gettime() - gTimeJoined[playerid]; 
Now you have the total time in seconds the player has been playing during that session. Then it's a simple matter of addition. Very easy in SQL based systems. Slightly more tricky in file based system: read the total time, add the session time and then write the result back to the file.
Reply


Messages In This Thread
TOTAL online time - by ALoX12 - 27.07.2015, 21:36
AW: TOTAL online time - by Mencent - 27.07.2015, 21:40
Re: TOTAL online time - by ALoX12 - 27.07.2015, 21:53
Re: TOTAL online time - by Vince - 27.07.2015, 22:03

Forum Jump:


Users browsing this thread: 1 Guest(s)