13.08.2013, 05:58
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:
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);
}