Just a question - 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: Just a question (
/showthread.php?tid=648831)
Just a question -
wallen - 29.01.2018
Is there any tutorials that explains how to count the current player's online time and save it with y_ini?
Re: Just a question -
Eoussama - 29.01.2018
Use the
gettime() function, it returns the
Unix timestamp, more about the function
here.
When someone joins, store the value of the Unix timestamp of that moment somewhere, then when they leave, subtract the Unix timestamp stored from the timestamp then, you will have the seconds spent online by that specific player.
PHP код:
new pTimeStamp[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
pTimeStamp[playerid] = gettime();
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new timeOnline = gettime() - pTimeStamp[playerid];
return 1;
}
// the timeOnline variable has the time spent online by that player in seconds.