05.07.2009, 14:19
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?
The rest has nothing to do with the timer and just prints it.
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;
}
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;
}