tickcount() skips numbers sometimes.
#1

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);
}
Reply
#2

Let me guess...

pawn Код:
SetTimer("Update", 1000, true);
Reply
#3

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)