The online racing simulator
Car Contact
(8 posts, started )
Car Contact
Hi there (Again) i am coding a car contact sitem and i code this.


// Car contact between 2 cars
private void CON_CarContact(Packets.IS_CON CON)
{
try
{

{
MsgAll("^1> ^3Accident: " + Connections[GetConnIdx2(CON.B.PLID)].NoColPlyName + " ^4<CRASH> " + Connections[GetConnIdx2(CON.A.PLID)].NoColPlyName);
MsgAll("^1> ^3Speed: " + Connections[GetConnIdx2(CON.B.PLID)].CompCar.Speed + "^1 m/s" + " ^4<CRASH> " + Connections[GetConnIdx2(CON.A.PLID)].CompCar.Speed + "^1 m/s");
}
}
catch { }
}



the code work corectly but it shows me the speed in meters per seconds and i cat figure out to change it to kilometers per hour

i tryed to add this : var kmh = Conn.CompCar.Speed / 91; but didnt work
THX for your help
A long time ago I learned on school that 1 m/s * 3.6 = 3.6 km/h

(Oh I see you are 15, maybe you get this later :P )
here in romania its different than other countries . i aleardy have learnt than when i was 13 .
But i want to know how to put that in code.
I believe CompCar.Speed is not in m/s. Check the LFS InSim manual. It says: speed (32768 = 100 m/s)

Example: When the speed = 65536, you divide it by 32768, and multiply it by 100. 65536 / 32768 = 2 * 100 = 200 m/s

Once you have the m/s value, you then convert it to km/h.

1m/s = 3.6km/h
200 m/s * 3.6 = 720km/h

The speed in the example is obviously really fast, but it's easy to calculate with in such an example. I'm sure there's a faster and/or more efficient way to do it, but this is easy to understand I think.

Please correct me if I'm wrong in the calculation!

edit: Maybe you can use the SpClose from IS_CON? That way you get the closing speed between the cars.
Quote from cargame.nl :A long time ago I learned on school that 1 m/s * 3.6 = 3.6 km/h

I started school in 1964, and at no time since that first day, till I left, and started work in 1976, was I ever taught that.

If asked, might have been able to work it out for myself...1 ms
=> * 60 seconds = 60 metres per minute
=> * 60 minutes = 3600 metres per hour
=> / 1000 in a kilo = 3.6 km per hour.
Then, for the proper speed, 3.6 * 0.621 = 2.24mph.

Attached images
simples.jpg
Quote from Bose321 :

edit: Maybe you can use the SpClose from IS_CON? That way you get the closing speed between the cars.

Oke thx thats really helpfull!


Thx u all for your answers!

Car Contact
(8 posts, started )
FGED GREDG RDFGDR GSFDG