Need help with Online Time Counter
#2

Hi, so I found this on my script, could be useful for you.
First you got this:
pawn Код:
enum pInfo
{
TotalTime,
hours,
mins,
secs,
ConnectTime
};
new PlayerInfo[MAX_PLAYERS][pInfo];

// now this
TotalGameTime(playerid, &h=0, &m=0, &s=0)
{
    PlayerInfo[playerid][TotalTime] = ( (gettime() - PlayerInfo[playerid][ConnectTime]) + (PlayerInfo[playerid][hours]*60*60) + (PlayerInfo[playerid][mins]*60) + (PlayerInfo[playerid][secs]) );

    h = floatround(PlayerInfo[playerid][TotalTime] / 3600, floatround_floor);
    m = floatround(PlayerInfo[playerid][TotalTime] / 60,   floatround_floor) % 60;
    s = floatround(PlayerInfo[playerid][TotalTime] % 60,   floatround_floor);

    return PlayerInfo[playerid][TotalTime];
}
Now when you want to see the total game time(example, in /stats), use the following:
pawn Код:
TotalGameTime(playerid, h, m, s);
//now to preview it:
format(string, sizeof(string), "Total Time: %d hours %d minutes %d seconds", h, m, s);
SendClientMessage(playerid, -1, string);
Let's load it OnPlayerConnect:
pawn Код:
PlayerInfo[playerid][ConnectTime] = gettime();
I hope this is what you need!


Oh, also you need to save the time OnplayerDisconnect.
Reply


Messages In This Thread
Need help with Online Time Counter - by Majava - 02.08.2013, 06:38
Re: Need help with Online Time Counter - by JimmyCh - 02.08.2013, 07:08
Re: Need help with Online Time Counter - by Majava - 02.08.2013, 07:58
Re: Need help with Online Time Counter - by JimmyCh - 02.08.2013, 08:32
Re: Need help with Online Time Counter - by ApOcAlYpSe98 - 22.03.2014, 12:09

Forum Jump:


Users browsing this thread: 2 Guest(s)