The online racing simulator
Initialize InSim Events
Hello, I started working with my InSim again and I was wondering about all insim events that are available to use. I`d like to make InSim recognize 2 car contact. The problem is I dont know how to make it. For example I got events like this
InSim.CPR_Received += new LFS_External.InSim.InSimInterface.CPR_EventHandler(CPR_ClientRenames); // A client changed name or plate.

But what I need to write so that InSim reads 2 car contact? And how to make it to show which cars were involved? And maybe there are many more? If yes where can I find them all?

Thanks for help
LFS/docs/insim.txt

This file contains all packets and documentation on what each returns so you can easily find out how to use them.

From the file:

// CONTACT - reports contacts between two cars if the closing speed is above 0.25 m/s
// =======

// Set the ISF_CON flag in the IS_ISI to receive car contact reports

struct CarContact // 16 bytes : one car in a contact - two of these in the IS_CON (below)
{
byte PLID;
byte Info; // like Info byte in CompCar (CCI_BLUE / CCI_YELLOW / CCI_LAG)
byte Sp2; // spare
char Steer; // front wheel steer in degrees (right positive)

byte ThrBrk; // high 4 bits : throttle / low 4 bits : brake (0 to 15)
byte CluHan; // high 4 bits : clutch / low 4 bits : handbrake (0 to 15)
byte GearSp; // high 4 bits : gear (15=R) / low 4 bits : spare
byte Speed; // m/s

byte Direction; // car's motion if Speed > 0 : 0 = world y direction, 128 = 180 deg
byte Heading; // direction of forward axis : 0 = world y direction, 128 = 180 deg
char AccelF; // m/s^2 longitudinal acceleration (forward positive)
char AccelR; // m/s^2 lateral acceleration (right positive)

short X; // position (1 metre = 16)
short Y; // position (1 metre = 16)
};

struct IS_CON // CONtact - between two cars (A and B are sorted by PLID)
{
byte Size; // 40
byte Type; // ISP_CON
byte ReqI; // 0
byte Zero;

word SpClose; // high 4 bits : reserved / low 12 bits : closing speed (10 = 1 m/s)
word Time; // looping time stamp (hundredths - time since reset - like TINY_GTH)

CarContact A;
CarContact B;
};

If I remember correctly lfs_external does not have that packet , But I am not sure
Quote from ADr3nAl1n :If I remember correctly lfs_external does not have that packet , But I am not sure

You are correct, LFS_External is unaware if the ISF_CON flag so it cannot even tell LFS to send IS_CON packets.
And how to add that packet to lfs_external?
Quote from jobans :And how to add that packet to lfs_external?

You cannot do that because there is no source code available for LFS_External. You have to use another more up-to-date library.
And where can I get it?
Thanks I got it updated
But now I have anothe problem. How can make it to for example write in chat those two cars who were in contact?
I got somethong like this so far but I dont know how to continue
private void CON_CarContact(Packets.IS_CON CON)
{
try
{
foreach (clsConnection C in Connections)
{
if ()
{

}
}
}
catch { }
}

Still waiting for help :/
LFS_External 1.1.1.7 has IS_CON I just got it working :3

HINT: use Connections[GetConnIdx2(CON.A.PLID)].
Thanks, finally I can try to make something, but got problem, again

// Car Contact
private void CON_CarContact(Packets.IS_CON CON)
{
try
{

if (Connections[GetConnIdx2(CON.A.PLID)].Cash > 0)
{
MsgAll("^6»^7 Contact detected");



}
}


catch { }
}

I put this code but when I do 2 car contact I dont get that message, Im using these variables only for testing, Can anyone tell whats the problem?
Quote from jobans :Thanks, finally I can try to make something, but got problem, again

// Car Contact
private void CON_CarContact(Packets.IS_CON CON)
{
try
{

if (Connections[GetConnIdx2(CON.A.PLID)].Cash > 0)
{
MsgAll("^6»^7 Contact detected");



}
}


catch { }
}

I put this code but when I do 2 car contact I dont get that message, Im using these variables only for testing, Can anyone tell whats the problem?

Cash ? you mean Crash ?
Remove if (Connections[GetConnIdx2(CON.A.PLID)].Cash > 0) statement

If its not working after you remove the statement then you didn't add the flag correctly
Nothing happens even if I remove that statement. What coutldt bet wrong with that flag? How to add it correctly?
Look in Form for Insim settings , search ISF_MCI or something and add there ISF_CON
Thanks got it to work :*

FGED GREDG RDFGDR GSFDG