Race times.. Linux server -
Outbreak - 22.07.2009
I've searched around and read some thing about GetTickCount not working on linux, not sure if its still returns minus or not.
So i'd like to know how i can do the times on races using minutes, seconds and milliseconds.
So it would be like this.. MM:SS.ms or 01:42.54
One minute Fourty Two seconds and 54 milliseconds.
If GetTickCount works in linux, how could i convert the ms into the format above?
Re: Race times.. Linux server -
Outbreak - 23.07.2009
anyone?
Re: Race times.. Linux server -
Joe Staff - 23.07.2009
You'd have to make a 10 ms timer that adds to a server wide variable. Then when the rae starts you save a player specific variable with the value that the time variable has, then at the end, you take the current time and subtract it from the player's held time, and you'd get how many 10ths of a second it took for them to finish.
Re: Race times.. Linux server -
Outbreak - 23.07.2009
Cant i jsut use GetTickCount? I tried and it gives a positive value, i just dont know how to convert it to mm
s.ms
Re: Race times.. Linux server -
Joe Staff - 23.07.2009
Well 1 second is 1000 milliseconds... and 1 minute is 60 seconds... Ahh the power of Arithmetic.
Re: Race times.. Linux server -
M4S7ERMIND - 23.07.2009
pawn Код:
ConvertTime(time, &minutes, &seconds, &milliseconds) {
for(new i; i<1000; i++) {
if(time >= 1000) {
time = time-1000;
seconds++;
if(seconds == 60) {
seconds = 0;
minutes++;
}
}else{
milliseconds = time;
break;
}
}
}
Have fun SAFC
Re: Race times.. Linux server -
Joe Staff - 23.07.2009
pawn Код:
converttime(time,&h,&m,&s,&ms)
{
ms=time;
s=ms/1000;
ms-=second*1000;
m=s/60;
s-=m*60;
h=m/60;
m-=h*60;
}
Much much faster, no use of loops.
Re: Race times.. Linux server -
Outbreak - 24.07.2009
Thanks guys, i checked it against a real life timer and its pretty accurate.
How do i get it to show 2minutes 10 seconds or 1 second and 54 ms as 2:10:54 / 2:01:54 and not 2:1:54
BTW, the guy who called me SAFC... what name would i know you by?
Re: Race times.. Linux server -
Joe Staff - 24.07.2009
You can change how format displays the numbers, I believe it's in the wiki in explicit detail.
Example:
pawn Код:
format(string,sizeof(string),"%d:%02d.%02d",minute,second,millisecond);
This would display something like
2:05.02