SA-MP Forums Archive
Calculating 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: Calculating time. (/showthread.php?tid=156605)



Calculating time. - Zh3r0 - 23.06.2010

Can someone please show me exactly how to calcuate time?
Like the time traveled from checkpoint A to B?
I heard i must use GetTickCount but have no idea how?
I would be gratefull to the one who shows me, thanks(I want seconds too)


Re: Calculating time. - Zh3r0 - 23.06.2010

Sorry for the bump but i really need this i can't find it anywhere, thanks again


Re: Calculating time. - Jeffry - 23.06.2010

I had the same problem for my races.

This may help you: http://forum.sa-mp.com/index.php?topic=158971.0


Re: Calculating time. - russo666 - 23.06.2010

Sometime ago I did a race and that's what I used:

Race Starts:

pawn Код:
new tick;
tick = tickcount();
SetPVarInt(playerid, "RaceTime", tick);
Race ends:

pawn Код:
new tick, calc, tmin, tsec, tmsec;
tick = tickcount();
calc = tick - GetPVarInt(playerid, "RaceTime");
ConvertTime(calc, tmin, tsec, tmsec);
Then you just format the values tmin, tsec, tmsec into a string with %d. Oryou can do w/e you want, like formating the number with %2d, etc.

Hope you understand.

Edit:

pawn Код:
stock ConvertTime(Milliseconds, &rMin, &rS, &rMS) //don't know the creator
{
  rMin = Milliseconds/60000;
  Milliseconds -= rMin*60000;
  rS = Milliseconds/1000;
  Milliseconds -= rS*1000;
  rMS = Milliseconds;
}



Re: Calculating time. - Zh3r0 - 23.06.2010

Thanks both of you Glad i got an answer, thanks again!