The online racing simulator
Check out the first post in this thread, there is an example how to use OutGauge in LFS_External. The code I posted is sort of a pseudocode, so you'll need to modify it to your needs.
I know, however there is now function" Dashlights". In the LFS External 1.1 with OutSim and OutGauge example for C#
Has anyone else had problems with NPL.Plate? It seems to only hold 7 characters, but LFS sends 8 and InSim defines it as having 8.
It's because IS_NPL.Plate does not end with a NULL character, like normal C-style strings. LFS_External must be popping off the last character of the string somewhere, which is perfectly fine for all other InSim strings (which end with a NULL char), but not for Plate.
Quote from DarkTimes :It's because IS_NPL.Plate does not end with a NULL character, like normal C-style strings. LFS_External must be popping off the last character of the string somewhere, which is perfectly fine for all other InSim strings (which end with a NULL char), but not for Plate.

That's what I was thinking, I was hoping there might have been a workaround though.
Not really, except for disassembling the library and recompiling it with a couple of changes. What you need to do is change:

[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 8)]
public string Plate;

To...

[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public char[] Plate;

Quote from DarkTimes :Not really, except for disassembling library and recompiling it with a couple of changes.

Never occurred to me

Thanks DarkTimes, works a treat now.
please help
what one of LFS External do i download from the top i wonner put it on my server but im pretty new to this guys
-
please help (gazastrike) DELETED by gazastrike
what one do i need to download mate im pretty new to this
You would download the latest version, of course (which currently is 1.1, I think).
Also, if you want to get started with the syntax faster, download the one with an example.

But, if you're new at it, you need to know at least the basics of the language you're downloading it for. If not that, then at least the basics of a similar language to it. You don't just grab it and start programming, because that would
1) get you mindeffed and
2) annoy you, which will
3) probably make you post "angry" help threads in which
4) you will get a lot of members annoyed too which can
4.1) make you post more "angry" posts that will get you banned or
4.2) get all your threads deleted, or nobody replying to them.

So, it's almost 100% game over for you.

But if you do know the basics, you can be sure that you will start getting the hang of it sooner or later. It's common sense: You don't know the basics, you don't know what to ask Google, therefore, you don't know what to do, OR, You do start learning the basics, which will get you a bit bored maybe, but in the end you'll be a lot more comfortable when you're doing changes/adding something to the application (and you might actually enjoy it too).

And just a final suggestion: If you want full InSim functionality, you might also want to get InSim.NET, because, even though it may(or may not) have some minor issues, this is currently the most up-to-date .NET library, as far as I'm aware. It is also, currently, the most actively-developed one, so any problems you report, will most likely be looked at & fixed. Also, it's opensource, so you can fix them yourself (if you know what you're doing, of course).
According to the license for LFS_External you are free to disassemble the library and basically do what you like with it, so with that in mind I updated it for LFS Z32. This meant adding the IS_CON packet and event, updating OutGaugePack with the relevant dash-lights and flags, as well as a couple of other small changes, such as IS_MTC*.

I created a new assembly versioned 1.1.1.7 that you can download below, that includes the updated assembly as well as the disassembled source (updated for VS2010).

If you find a bug with my changes I'll fix it, but I am in no way providing support for this library and I will not add any new features (the source is included in my download so you can add them yourself). Also if T-RonX has a problem with it I'll take it down.

* Note that I did not make IS_MTC a variable-sized packet, as that would have required a crap-bunch more work, also LFS_External does not deal with other variable-sized packets anyway. If you want stuff like variable-sized packets (better performance), proper string support (for other charsets than just ASCII) and many other general improvements, I recommend using InSim.NET.

I have also updated the original example program, which can be found below. The changes are mainly improvements to the code to make it more succinct and more efficient.
Attached files
LFS_External_1.1.1.7.zip - 1021.4 KB - 1063 views
LFS_ExternalExample.zip - 38.2 KB - 776 views
I tried to re-use this library but it seems more buggy than I expected bcuz whenever I start the app it closes or stops responding so I guess codes from 1.1.1.4 doesn't work on the stripped 1.1.1.5 version, Oh well since u dont have to support it, I'm going to continue using spark insim anyways nice try darktimes
Well thanks for that really detailed error report! As I say I will only provide support for stuff that I have changed (e.g. CON, RST, MTC (except the variable-sized thing) and OutGaugePack).

Other than that the library is completely unchanged and works as it always did.

using System;
using LFS_External.InSim;

class Program
{
static void Main()
{
InSimInterface insim = new InSimInterface(new InSimSettings());

insim.VER_Received += new InSimInterface.VER_EventHandler(insim_VER_Received);

insim.Connect();

Console.ReadKey(true);
}

static void insim_VER_Received(LFS_External.Packets.IS_VER VER)
{
Console.WriteLine("InSim Version: {0}", VER.InSimVer);
}
}

I uploaded a new version, as I had made a mistake with the MTC packet that caused a breaking bug. I uploaded it to my original post.

I have checked this new version against T-RonX's original example program (from the first post in this thread), and it seems to work OK!
-
(MariusMM) DELETED by MariusMM
tested nice try darktimes but the character strings has a bug which doesn't show string and end up bug like 1.1.1.4 bug which strings at create btn has a limit
Quote from skywatcher122 :tested nice try darktimes but the character strings has a bug which doesn't show string and end up bug like 1.1.1.4 bug which strings at create btn has a limit

You are seriously not reading, are you? 1.1.1.4's bugs will stay (to say it in the simplest way possible). Get the source and fix it, instead of saying "nice try".
oh I apologize if i say that way anyways, im not using this library either.
First of all, thanks DarkTimes for your time to update the library

I modified a little the vbnet example(outsim&outgauge) from the first post, to test the outgauge, but I found some problems and I can't figure out what it is wrong. I think something is wrong with the new dll...

-Throttle value reporting as brake
-Brake value reporting as clutch
-And none of the ShowLights reporting as on (always 0)

I attached my modified vbnet example for outsim&outgauge: http://www.box.net/shared/ktbcz35ob0

I hope you can check it sometime...
Thanks in advance and sorry for my poor English
Attached images
accelarating.jpg
braking.jpg
Quote from Ant0niS :First of all, thanks DarkTimes for your time to update the library

I modified a little the vbnet example(outsim&outgauge) from the first post, to test the outgauge, but I found some problems and I can't figure out what it is wrong. I think something is wrong with the new dll...

-Throttle value reporting as brake
-Brake value reporting as clutch
-And none of the ShowLights reporting as on (always 0)

I attached my modified vbnet example for outsim&outgauge: http://www.box.net/shared/ktbcz35ob0

I hope you can check it sometime...
Thanks in advance and sorry for my poor English

Yup, I accidentally made the DashLightFlags a ushort instead of a uint. That caused all the fields that follow it to be shifted up two bytes. I uploaded a fixed version.

http://www.lfsforum.net/showthread.php?p=1589388#post1589388
Thank you DarkTimes Thumbs up
Now works fine Smile


I uploaded the modified vb.net example for everyone who want to see all the outgauge data in one form, and/or extended to a nice outgauge application.Smile


http://www.box.net/shared/ykmkeljvu6
Attached images
1.JPG
2.JPG
I tried to fix the Create_BTN bug which limits characters (which extracted from LFS_External 1.1.0.0 DLL from dissembler) and it seems to be working on DarkTimes 1.1.1.6

open "MakePacket.cs" and replace the code below

<?php 
        
public static byte[] ISP_BTN(string ButtonTextLFS_External.InSim.Flags.ButtonStyles Stylebyte Heightbyte Widthbyte Topbyte Leftbyte ClickIDbyte UniqueIDbyte RequestIDbool AlwaysVisible)
        {
            
LFS_External.Packets.IS_BTN sourceStruct = new LFS_External.Packets.IS_BTN
            
{
                
Size 0xfc,
                
ReqI RequestID,
                
Type 0x2d,
                
UCID UniqueID,
                
BStyle Style,
                
ClickID ClickID,
                
Text ButtonText,
                
TypeIn 0
            
};
            if (
AlwaysVisible)
            {
                
sourceStruct.Inst 0x80;
            }
            
sourceStruct.Height;
            
sourceStruct.Width;
            
sourceStruct.Top;
            
sourceStruct.Left;
            return 
Util.PacketToData(sourceStruct);
        }

        public static 
byte[] ISP_BTN(string ButtonTextstring DialogCaptionLFS_External.InSim.Flags.ButtonStyles Stylebyte Heightbyte Widthbyte Topbyte Leftbyte TypeInbyte ClickIDbyte UniqueIDbyte RequestIDbool AlwaysVisible)
        {
            
LFS_External.Packets.IS_BTN sourceStruct = new LFS_External.Packets.IS_BTN();
            
char ch '\0';
            
string str string.Concat(new object[] { chDialogCaptionchButtonText });
            
sourceStruct.Size 0xfc;
            
sourceStruct.ReqI RequestID;
            
sourceStruct.Type 0x2d;
            
sourceStruct.UCID UniqueID;
            
sourceStruct.BStyle Style;
            
sourceStruct.ClickID ClickID;
            
sourceStruct.Text str;
            
sourceStruct.TypeIn TypeIn;
            if (
AlwaysVisible)
            {
                
sourceStruct.Inst 0x80;
            }
            
sourceStruct.Height;
            
sourceStruct.Width;
            
sourceStruct.Top;
            
sourceStruct.Left;
            return 
Util.PacketToData(sourceStruct);
        }
?>

How to use the collision packets in the example project?

Since I have lost all my old sources and I'm looking to update an app I made I have to code it again (no big deal) but I want to use the collision packet rather than speed...

So I started with the sample VB project from post 1.. Changed the dll to the updated one from DarkTimes.. added these parts:

Quote :'Collision
AddHandler InSim.CON_Received, AddressOf CON_CONTACT

' A collision happened.
Private Sub CON_CONTACT(ByVal CON As Packets.IS_CON)
If DoInvoke() Then
Dim p As Object = CON
Me.Invoke(New dlgCON(AddressOf CON_CONTACT), p)
Return
End If

'some test code to test it out
textBox1.Text += CON.A.PLID & Constants.vbCrLf
textBox1.Text += CON.B.PLID & Constants.vbCrLf
End Sub

But I get nothing in the text box, nor does adding a debug marker on the sub call anything up. it does connect to insim because I see the MSO messages in the textbox..

Long time since I coded anything, not just InSim so is there something missing or anything?

(oh and I tested it with AI and in a multiplayer server..)
Set the InSim Flag with an IS_CON
Ah :P Works now.. Cheers

Amazing the amount of collisions the AI have when starting from in their pits, lol
Sorry for double but wouldn't get attention if I just edited

How can I get a players name from their PlayerID (PLID)?

EDIT: What I had written did work, just I had a FOR NEXT which it didn't need and stopped it working...

Function getname(ByVal PLID As Integer) As String
Dim i As Integer = 0
Do
If Connections(i).UniqueID = GetUniqueID(PLID) Then
Return Connections(i).PlayerName
End If
i = i + 1
Loop Until i = Connections.Count
End Function

and the GetUniqueID is:

Public Function GetUniqueID(ByVal PLID As Integer) As Integer
For i As Integer = 0 To Players.Count - 1
If Players(i).PlayerID = PLID Then
Return Players(i).UniqueID
End If
Next i
Return 0
End Function

Is there an easier way to do this? this way working good.. tested online and with AI... But might not be the best nor fastest way to do it :/

FGED GREDG RDFGDR GSFDG