tickcount() skips numbers sometimes. - 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)
+--- Thread: tickcount() skips numbers sometimes. (
/showthread.php?tid=457776)
GetTickCount() skips numbers sometimes. -
Activest - 13.08.2013
Hey.
I noticed that GetTickCount() skips sometimes numbers, I think its because the milliseconds.
I want to do race-times, but how to fix that the numbers will be right?
The testing was about 20 seconds, but its finishing on the number 22 instead 20.
I tried to check it with this:
pawn Код:
new
Timer,
gStartTime;
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/try", true))
{
Timer = 0;
gStartTime = GetTickCount();
return 1;
}
return 0;
}
forward Update();
public Update()
{
new string[128];
if(Timer < 21)
{
new
totalSeconds = GetTickCount() - gStartTime, minutes, seconds, ms;
timeconvert(totalSeconds, minutes, seconds, ms);
format(string, sizeof(string), "Time: %d minutes, %d seconds and %d ms.", minutes, seconds, ms);
SendClientMessageToAll(-1, string);
}
Timer++;
}
timeconvert(Time, &Minutes, &Seconds, &MSeconds)
{
new Float:fTime = floatdiv(Time, 60000);
Minutes = floatround(fTime, floatround_tozero);
Seconds = floatround(floatmul(fTime - Minutes, 60), floatround_tozero);
MSeconds = floatround(floatmul(floatmul(fTime - Minutes, 60) - Seconds, 1000), floatround_tozero);
}
Re: tickcount() skips numbers sometimes. -
Pottus - 13.08.2013
Let me guess...
pawn Код:
SetTimer("Update", 1000, true);
Re: tickcount() skips numbers sometimes. -
Activest - 13.08.2013
Yes

, but why its matter? if I did the timer for 20 seconds then this is the results(22 and sometimes 23)
Even if I did another variable like Timer++ that displaying the minutes and seconds instead the GetTickCount(),
on the results the GetTickCount() is higher from the number...
Well, how can I accurate the time on messages?
Re: tickcount() skips numbers sometimes. -
Pottus - 13.08.2013
It matters because timers in SAMP are not accurate what you think is 1000 (1 - second) is about 1.1 seconds that is why your results are off.
https://sampforum.blast.hk/showthread.php?tid=289675