Race time - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Race time (
/showthread.php?tid=133698)
Race time -
Jeffry - 13.03.2010
Hello guys,
I have a question.
Does anybody have a function that counts up the time, and gives it out when the player finished a race?
Like this:
•/race
•The timer starts counting up
•Player drives troght last checkpoint
•Time that he needed for the race will be shown.
Can anyone help me?
Jeffry
Re: Race time -
Joe Staff - 13.03.2010
GetTickCount();
You would save it to a variable at the beginning of a race, and then compare it with the current GetTickCount() at the end of the race.
pawn Code:
BeginRace(playerid)
{
Timer[playerid]=GetTickCoun();
}
EndRace(playerid)
{
Timer[playerid]=GetTickCount()-Timer[playerid]; //That will be how long the player was in the race in milliseconds
}
Re: Race time -
Jeffry - 13.03.2010
Okay, this works, but I get 6295 as result.
How do I give it out as: min

ec:milisec ?
Re: Race time -
Joe Staff - 13.03.2010
Could create a function
pawn Code:
stock ConvertTime(Milliseconds,&rMin,&rS,&rMS)
{
rMin=Milliseconds/60000;
Milliseconds-=rMin*60000;
rS=Milliseconds/1000;
Milliseconds-=rS*1000
rMS=Milliseconds;
}
pawn Code:
new Min,Sec,MS;
ConvertTime(Timer[playerid],Min,Sec,MS);
printff("%02d:%02d.%01d",Min,Sec,MS/100);
will print
Re: Race time -
Jeffry - 13.03.2010
WOORKS!!! YUHUU!
Thank you so much!