The online racing simulator
Calculating Race Times
(6 posts, started )
Read out Best Laptimes
Code to read out Best Lap time
=============================




Step by Step:




1. Fill in the private void:


RES_RaceOrQualifyingResult(Packets.IS_RES RES)
{

}


2. Add position "finder".
Till up to ResultNum == 31.

RES_RaceOrQualifyingResult(Packets.IS_RES RES)
{
if (RES.ResultNum == 0) // 0=1, 1=2 .....
{

}
}

3. Add some code to display the Informations.
You must remove ButtonID to the ID.
RES_RaceOrQualifyingResult(Packets.IS_RES RES)
{
if (RES.ResultNum == 0) // 0=1, 1=2 .....
{
//Convert ms to Minutes:Seconds:Milliseconds
TimeSpan bestLap = TimeSpan.FromMilliseconds(RES.BTime);
string bestLapStr = string.Format("{0}:{1:00}.{2:000}", bestLap.Minutes, bestLap.Seconds, bestLap.Milliseconds);

//Buttons to display the Informations.
InSim.Send_BTN_CreateButton("^7[COLOR=Red]*[/COLOR]", Flags.ButtonStyles.ISB_DARK | Flags.ButtonStyles.ISB_LEFT, 4, 5, 25, 10, 37, 255, 1, false);
InSim.Send_BTN_CreateButton(RES.PName, Flags.ButtonStyles.ISB_DARK | Flags.ButtonStyles.ISB_LEFT, 4, 20, 25, 15, 38, 255, 1, false);
InSim.Send_BTN_CreateButton("^7"+bestLapStr, Flags.ButtonStyles.ISB_DARK | Flags.ButtonStyles.ISB_LEFT, 4, 10, 25, 40, 40, 255, 1, false);
}
}

4. Fill in into your InSim Application.

*WARNING*

* = Needs to be removed to each result number.
THIS IS JUST A PICE OF THE WHOLE CODE! BE HAPPY IF IT WORKS WHEN YOU "COPY|PASTE" IT OTHERWISE TRY TO GET IT WORKING


Thanks to:

DarkTimes = Remember me on TimeSpan method.
Dougie-Lampkin = Gave me Tipps.
Marco1 = Seting up a Server and tested code stuff.



Support at:
- [MSN] Marco-0510@hotmail.de
- [ICQ] 355863550
- [PN] Private Message
- [E-Mail] marco0510@web.de
-
(DarkTimes) DELETED by DarkTimes
To get the milliseconds, use the modulus operator.

string milliseconds = (RES.BTime % 1000).ToString().PadLeft(2, '0');

You could also use the TimeSpan method to convert MS into Days, Hours, Minutes, Seconds, Milliseconds. No examples to hand unfortunately,but it's well documented on t'internets
TimeSpan bestLap = TimeSpan.FromMilliseconds(RES.BTime);

Thanks DarkTimes
-
(Heiko1) DELETED by Heiko1
-
(Heiko1) DELETED by Heiko1
The easiest way is just to use the System.TimeSpan class.
TimeSpan bestLap = TimeSpan.FromMilliseconds(RES.BTime);
string bestLapStr = string.Format("{0}:{1:00}.{2:000}", bestLap.Minutes, bestLap.Seconds, bestLap.Milliseconds);

-
(Heiko1) DELETED by Heiko1
-
Update 27.Feb. 2009 (Heiko1) DELETED by Heiko1

Calculating Race Times
(6 posts, started )
FGED GREDG RDFGDR GSFDG