The online racing simulator
.NET - LFS External (InSim/OutSim/OutGauge SDK Library)
(540 posts, started )
.NET - LFS External (InSim/OutSim/OutGauge SDK Library)
Hello,

LFS External is an InSim/Outsim/OutGauge SDK library for the .NET Framework. This software allows you to build your own external Live for Speed applications.
You can use LFS External with any .NET language that supports dll files. It fully supports InSim V4, OutGouge and OutSim, C# and VB.NET example code is included.

Requirements:
- Microsoft Visual C# Express Edition 2005/2008 (free!) (or another C# IDE) or
- Microsoft Visual Basic Express Edition 2005/2008 (free!) (or another VB.NET IDE)
- Knowledge of C# or VB.NET

Download

InSim Example
- LFS External 1.1 with InSim example for C#
- LFS External 1.1 with InSim example for VB.NET

OutSim and Outgauge Example
- LFS External 1.1 with OutSim and OutGauge example for C#
- LFS External 1.1 with OutSim and OutGauge example for VB.NET

Library only
- LFS External 1.1 library only (For advanced users)

Obsolete
- LFS External 1.04 (NOT recommended, old version)

Update 1.1.1.4
- Updated TCP code
- Small performance improvement

Update 1.1.1.3
- Resolved string issue

Update 1.1.1.2
- Added missing TINY and SMALL send methods

Update 1.1.1.0
- Added support for OutSim and OutGauge

Update 1.1.0.0
- Faster and more reliable connection to host
- Auto reconnect on connection failure
- Better error handling
- Example code for C# and VB.Net
- Used more descriptive method names
- Now supports multiple instances of InSimInterface
- Lot of small things

Update 1.04
- Added IntakeRestriction property to Players class
- Removed unused property in Players class
- Player rename bug now really fixed
- Included license file

Update 1.03
- Fixed Player rename bug
- Added missing BFN (shift+i ingame) receive event

Update 1.02
- Fixed crash on crowded server

Update 1.01
- Compiled to dll
- Works much better but by far not perfect
- Fixed lot of bugs
- Added full UDP support
- Flags now work how they should

Updates since previous VB .NET version:
- Upgraded to C#
- V4 support
- Supports MCI/NLP
- Automatically maintenances Connections and Players list
- A lot more..
Uh, you know that LFSLib, which is a .NET LFS library, has been around for quite some time? Hate to see duplicated work (unless of course for learning purposes).

Quote from T-RonX :Hello,

I made an InSim base for C#. It can handle any InSim V4 packet in both directions. It's build to be mainly used with TCP, but it supports NPL/MCI over UDP too. You should start looking at frmMain(code), I explained the most important stuff there.

Updates since previous VB .NET version:
- Upgraded to C#
- Supports MCI/NLP
- Automatically maintenances Connections and Players list
- A lot more..

This is my first big C# thing, so if there might be some bad code, don't start flaming. Instead, help me.

Happy coding.

Yes I know. It has been a kinda learning project And I think this one is much easier to use for beginners.
#4 - Xior
I can't open the programm it says: "Rapport verzenden/Niet verzenden" when i open vshost.exe.

And when i open InSim_v4.exe it says: "Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd", what must i do now?
Quote from Xior :Is this a realistic script like the [TC]City Drving server?
How can i use this script in my server?

It's not a script, its a base. You have to code all the stuff you want for your server yourself. This software handles the communication between LFS and you app.
#6 - Xior
Quote from T-RonX :It's not a script, its a base. You have to code all the stuff you want for your server yourself. This software handles the communication between LFS and you app.

Oww oke, thanks for fast reply =}

//edit
I thought a insim server is a realistic server with cops etc..?
Quote from Xior ://edit
I thought a insim server is a realistic server with cops etc..?

I don't know what you mean by that.

About the error:
Obviously you have to specify what server it connects to. Read the readme part at the top of the frmMain file
@Xior: No, InSim is the interface that allows communication between LFS and external applications. For example TC, CTRA and similar are such external applications that use InSim to interact with LFS.
#9 - Xior
Quote from AndroidXP :@Xior: No, InSim is the interface that allows communication between LFS and external applications. For example TC, CTRA and similar are such external applications that use InSim to interact with LFS.

So it's another mod they use to be a cop in that servers?
Quote from Xior :So it's another mod they use to be a cop in that servers?

InSim is a protocol for communicating with LFS through the use of TCP or UDP network packets.
HI!

I was used ur insim base for vb, it was great like the new one is too. But i have a question about it. what packet can i use instead of the old MSS packet?

thanks for the answer and the good work u have done and shared with us.
Quote from CJ Ice :HI!

I was used ur insim base for vb, it was great like the new one is too. But i have a question about it. what packet can i use instead of the old MSS packet?

thanks for the answer and the good work u have done and shared with us.

MSO, there is a TextStart variable in it.

---

I update the base. I compiled it to a dll so you don't have all the code in your project. Its far from perfect yet, but it works better then the previous version and a lot of bugs are fixed now. And it fully supports udp now. It's not throwing any exceptions yet if something goes wrong, but i'm working on that. It hasn't been tested very well yet...
Updated to 1.02
- Fix a bug that could crash InSim on crowded servers.

Don't forget to add the dll to your project! It's in the zip. Or if you were already using the previous version, you can just replace the dll file.
Updated to 1.03
- Fixed Player rename bug
- Added missing BFN (shift+i ingame) receive event
can this also handle OutGauge?
Don't think so... see the LFSLib; it handles InSim, OutSim and OutGuage along with the relay server.

Quote from CrazyICE :can this also handle OutGauge?

ok, thx...
Can someone give me a sample code of how to create a text field button? And is it possible to use multiple style flags (how?)
This is a text field...

System.Windows.Forms.TextBox tb = new System.Windows.Forms.TextBox(); // creates a new textbox
tb.Text = "whatever"; // sets the text of the textbox.
this.Add(tb); // adds the textbox to the form, represented by this.

This is a button...
System.Windows.Forms.Button btn = new System.Windows.Forms.Button(); // creates a new button
btn.Text = "whatever"; // sets the text of the button.
this.Add(btn); // adds the buttonto the form, represented by this.

Or better yet, just drag-n-drop it onto the form itself in the VS editor; this is pretty basic stuff though.... there are tons of tutorials on doing WindowsForm programming in .NET on the web.

Quote from windstyle :Can someone give me a sample code of how to create a text field button? And is it possible to use multiple style flags (how?)

Quote from windstyle :Can someone give me a sample code of how to create a text field button? And is it possible to use multiple style flags (how?)

InSim.Send_BTN_CreateButton("Button Text", "Title", Flags.ButtonStyles.ISB_DARK | Flags.ButtonStyles.ISB_CLICK, 5, 30, 100, 10, 96, 1, UCID, 40, false);

replace UCID by your UCID.


As you can see it's an overloader. It's the same function but it requires different parameters.

And yes you can use multiple flags, but not combinations work, just try out.

Good luck.

@Hollywood: He ment an InSim button.
#21 - vane
i was gonna have a go at coding something in here, can someone give me an example of a swear filter that says something when you swear. can you also show some examples of where like you write what packet it looks for and what it does when it finds it. thanks, vane

p.s maybe for next release you could have a button code but have // infront to demonstrate the layout of the code.
Quote from vane :i was gonna have a go at coding something in here, can someone give me an example of a swear filter that says something when you swear. can you also show some examples of where like you write what packet it looks for and what it does when it finds it. thanks, vane

why not just say "Will you teach me how to program in C#" thats basically what your asking.. but anyway

if(MSO.Msg.Contains("vane"))
{
InSim.Send_MST_Message(
"/msg " + Connections[GetConnIdx(MSO.UCID)].PlayerName + " said vane");
}


very basic and bad way but thats a possible way....
#23 - vane
well i asked you earlier and you said no are all the packet names in the commands.txt file?
#24 - vane
i have added that but it just underlines it in a red squiggly line in visual c# it says it cant find MSO in current context
Quote from vane :i have added that but it just underlines it in a red squiggly line in visual c# it says it cant find MSO in current context

Have you uncommented MSO in the "default" region?

Have you:

privatevoid MSO(Packets.IS_MSO MSO)
{

before your command?


These are the basics that I found out the hard way

.NET - LFS External (InSim/OutSim/OutGauge SDK Library)
(540 posts, started )
FGED GREDG RDFGDR GSFDG