How to save played time on mysql.
#1

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];
Reply
#2

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.
Reply
#3

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


Forum Jump:


Users browsing this thread: 2 Guest(s)