The online racing simulator
problems with if (InSim.State == LFS_External.InSim.InSimInterface.InSimState.Conne ct
Hi all, I have a little problem with debugging, when I press F5, they called me this problem:
if (InSim.State == LFS_External.InSim.InSimInterface.InSimState.Connected)
Here is my screen shot


// Use this method to connect to InSim so you are able to catch any exception that might occur
public void InSimConnect()
{
try
{
#region ' Read Setup.cfg '
if (System.IO.File.Exists(@"Files/Setup.cfg") == false)
{
File.Create(@"Files/Setup.cfg");
}
StreamReader Sr = new StreamReader("Files/Setup.cfg");

string line = null;
while ((line = Sr.ReadLine()) != null)
{
if (line.Substring(0, 5) == "Admin")
{

string[] StrMsg = line.Split('=');
AdminPW = StrMsg[1].Trim();
}

if (line.Substring(0, 4) == "Port")
{
string[] StrMsg = line.Split('=');
Port = ushort.Parse(StrMsg[1].Trim());
}

if (line.Substring(0, 2) == "IP")
{
string[] StrMsg = line.Split('=');
IPAddress = StrMsg[1].Trim();
}

}
Sr.Close();
#endregion

// InSim connection settings
InSimSettings Settings = new InSimSettings(IPAddress, Port, 0, Flags.InSimFlags.ISF_MSO_COLS | Flags.InSimFlags.ISF_MCI, '!', 500, AdminPW, Interface, 5);
InSim = new InSimInterface(Settings); // Initialize a new instance of InSimInterface with the settings specified above

InitializeInSimEvents(); // Initialize packet receive events
InSim.Connect(); // Attempt to connect to the InSim host

}
catch { }
finally
{
if (InSim.State == LFS_External.InSim.InSimInterface.InSimState.Connected)
{
InSim.Request_NCN_AllConnections(255);
InSim.Request_NPL_AllPlayers(255);
InSim.Send_MST_Message("/wind=1");

}
}
}
// You should only enable the events you need to gain maximum performance. All events are enable by default.
private void InitializeInSimEvents()
{
try
{


If you know some code to fix it Thanks!
Attached images
Naamloos.png
this will be the first and last time i help you, that error means you have something set wrong in the setup.cfg in other words it cant find what you set it to connect to. make sure the server you have the insim set to connect to is running and that you can connect to that server, also if you change directory names you need to tell the code where to look.

hope that helps.

FGED GREDG RDFGDR GSFDG