30.12.2014, 12:46
I think the best way to do this is with Unix time stamps.
Use gettime() when the players joins and store it.
When the player leaves use gettime() agian subtract it from the first one and you will have the amount of seconds he was in the server.
Example:
Use gettime() when the players joins and store it.
When the player leaves use gettime() agian subtract it from the first one and you will have the amount of seconds he was in the server.
Example:
pawn Код:
new TimeOnServer[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
TimeOnServer[playerid] = gettime();
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
PlayerInfo[playerid][pTimeOnServer] = TimeOnServer[playerid] - gettime();
// or save it directly to the players file
return 1;
}