SA-MP Forums Archive
How to save played time on mysql. - 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: How to save played time on mysql. (/showthread.php?tid=470526)



How to save played time on mysql. - Scrillex - 18.10.2013

Hello again my mates..

Idk how to save the time in mysql..
And every played hour gives 1 exp.
my enum:
pawn Код:
enum e_pInfo
{
    pRespect,
    pEXP,
        pSec,
        pMin,
        pHour
}
new g_PlayerInfo[MAX_PLAYERS][e_pInfo];



Re: How to save played time on mysql. - RajatPawar - 18.10.2013

Under onplayerconnect, make a variable and do this
pawn Код:
playerJOINtime[playerid] = gettime();
then under OnPlayerDisconnect,
pawn Код:
Player total time played this session = gettime() - playerJOINtime[playerid]
now this difference gives the no of secs played by player in this session. Each time, add this to the existing time (MAKE SURE YOU DO NOT OVERWRITE IT, BUT ADD IT) after retreiving it. Then, divide by 3600, floatround to get the hours played, for mins, divide by 60 and floatround, for seconds, just use
pawn Код:
secs = totaltime % 60
to get the secs and display it.. Hope you understood.


Re: How to save played time on mysql. - Scrillex - 18.10.2013

Something like that?
g_PlayerInfoplayerid][pSec] = gettime() - playerJOINtime[playerid];