Recording Total Game Time
#1

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

Please help me!
It's very important!
Thanks!
Reply
#2

Do you know how to work with timers?
Reply
#3

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

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

i dont know how to do that, i know how to save!
Reply
#6

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?
Reply
#7

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!
Reply
#8

Just use gettime()

Far better than everything what's said above
Reply
#9

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)