Playing Time
#1

Hey i have a bug in player stats (played time) the time increases by 160 hours or smthing after a minutes from register
when player register the time is working good but after few minutes it gets bugged.

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

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

    return PInfo[playerid][TotalTime];
}
thats the code of how it should count the played time i guess its the wrong one
also under onplayerconnect
PInfo[playerid][ConnectTime] = gettime();
Reply
#2

What is the purpose of this section?:
Код:
(PInfo[playerid][hours]*60*60) + (PInfo[playerid][mins]*60) + (PInfo[playerid][secs])
You just need this code:
Код:
(gettime() - PInfo[playerid][ConnectTime])
Reply
#3

If PInfo[playerid][TotalTime] is integer you dont use floatround. It is not float. How do you call TotalGameTime if you call repeatedly PInfo[playerid][hours] and PInfo[playerid][TotalTime] will increase also and increase each other.
Reply
#4

What is the point of PInfo[playerid][hours]?
Just use (gettime() - PInfo[playerid][ConnectTime]) to calculate how much time passed since the player has last connected.

Save that value each time into your player's db/ini file (incrementing your current totalplaytime). Then do whatever calculations you want to display the hours, minutes and seconds. There's no point saving them in variables once you have a timestamp..
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)