Online time
#6

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:
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;
}
Reply


Messages In This Thread
Online time - by cyberlord - 30.12.2014, 12:14
Re: Online time - by TonyII - 30.12.2014, 12:18
Re: Online time - by cyberlord - 30.12.2014, 12:21
Re: Online time - by TonyII - 30.12.2014, 12:23
AW: Re: Online time - by Flori - 30.12.2014, 12:43
Re: Online time - by Facerafter - 30.12.2014, 12:46
Re: Online time - by cyberlord - 30.12.2014, 12:48
Re: Online time - by Facerafter - 30.12.2014, 12:51
Re: Online time - by cyberlord - 30.12.2014, 16:15
AW: Online time - by Nero_3D - 30.12.2014, 16:46
Re: AW: Online time - by cyberlord - 30.12.2014, 17:37
Re: AW: Online time - by Cameltoe - 30.12.2014, 17:53
Re: AW: Online time - by cyberlord - 30.12.2014, 18:08
Re: Online time - by cyberlord - 30.12.2014, 20:23

Forum Jump:


Users browsing this thread: 1 Guest(s)