SA-MP Forums Archive
Timer loosing 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Timer loosing time? (/showthread.php?tid=85111)



Timer loosing time? - happyface - 05.07.2009

I am trying to make an accurate little time filterscript so I can sync everything, but compared to a real clock, my timer seems to be getting behind 4 seconds every minute, so that 60 seconds is no longer a game hour, its like 1 minute 4 seconds equals 1 game hour.

so say I start the server at 12:00:00, the timer should do every seconds a game minute so at 12:01:00 game time should be 01:00, instead its like, at 12:01:00 the game time still at 00:56, where are these 4 seconds going?

Am I doing something wrong, or are the timers just not as accurate as I wish them to be?

pawn Код:
public OnGameModeInit()
{
    SetTimer("UpdateTime",1000,true);
    SetTimer("PrintTime",1000,true);
    return 1;
}
pawn Код:
public UpdateTime()
{
    if(Minutes < 59)
    {
        Minutes++;
       
    }
    else if(Minutes == 59)
    {
        Minutes = 0;
        Hours++;
    }
    return 1;
}
The rest has nothing to do with the timer and just prints it.
pawn Код:
public PrintTime()
{
    new Time[20];
    if(Hours < 10 && Minutes < 10)
    {
        format(Time, sizeof(Time),"Game Time: 0%i:0%i",Hours,Minutes);
        print(Time);
    }
    if(Hours < 10 && Minutes > 9)
    {
        format(Time, sizeof(Time),"Game Time: 0%i:%i",Hours,Minutes);
        print(Time);
    }
    if(Hours > 9 && Minutes < 10)
    {
        format(Time, sizeof(Time),"Game Time: %i:0%i",Hours,Minutes);
        print(Time);
    }
    if(Hours > 9 && Minutes > 9)
    {
        format(Time, sizeof(Time),"Game Time: %i:0%i",Hours,Minutes);
        print(Time);
    }
    return 1;
}



Re: Timer loosing time? - happyface - 05.07.2009

Bump. Am still looking for some help here.