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


Messages In This Thread
GetTickCount() skips numbers sometimes. - by Activest - 13.08.2013, 05:58
Re: tickcount() skips numbers sometimes. - by Pottus - 13.08.2013, 06:30
Re: tickcount() skips numbers sometimes. - by Activest - 13.08.2013, 06:40
Re: tickcount() skips numbers sometimes. - by Pottus - 13.08.2013, 07:00

Forum Jump:


Users browsing this thread: 1 Guest(s)