SA-MP Forums Archive
Recording Total Game Time - 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: Recording Total Game Time (/showthread.php?tid=282283)



Recording Total Game Time - kadaradam - 10.09.2011

How can I save the time of the player on my server?

Please help me!
It's very important!
Thanks!


Re: Recording Total Game Time - Kingunit - 10.09.2011

Do you know how to work with timers?


Re: Recording Total Game Time - kadaradam - 10.09.2011

Yes, but can be solved easily,just i dont know how!


Re: Recording Total Game Time - =WoR=Varth - 10.09.2011

You don't know how to use the timer, or don't know how to save it?


Re: Recording Total Game Time - kadaradam - 10.09.2011

i dont know how to do that, i know how to save!


Re: Recording Total Game Time - =WoR=Varth - 10.09.2011

Have you read https://sampwiki.blast.hk/wiki/SetTimerEx?
Start the timer when player logged in, but kill the timer when player disconnect.
The timer have 1 hour/minutes interval. Up2u. Create a variable to store player's total play time, then increase them each callback from timer get called.
Make a sense?


Re: Recording Total Game Time - kadaradam - 10.09.2011

Yes i already readed!
But i have a script from LuxAdmin!
Like this:

pawn Код:
enum PlayerData
{
    hours,
    mins,
    secs,
    TotalTime,
    ConnectTime
    };
    new AccInfo[MAX_PLAYERS][PlayerData];


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

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

    return AccInfo[playerid][TotalTime];
}

public OnPlayerConnect(playerid)
{
    AccInfo[playerid][ConnectTime] = gettime();
 return 1;
}
But dont work,the new replaces the old one!


Re: Recording Total Game Time - rbN. - 10.09.2011

Just use gettime()

Far better than everything what's said above


Re: Recording Total Game Time - kadaradam - 10.09.2011

So:
pawn Код:
public OnPlayerConnect(playerid)
{
    gettime();
 return 1;
}



Re: Recording Total Game Time - Wesley221 - 10.09.2011

Use the GetTime on playerconnect like you did, then save the hours, minutes & seconds in a variable (player bounded ofcourse), and then create another variable with GetTime on playerdisconnect, then compare them howmutch is between them and save that in a file.
https://sampwiki.blast.hk/wiki/Gettime