29.01.2018, 11:10
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.
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.