PDA

View Full Version : .NET - LFS External (InSim/OutSim/OutGauge SDK Library)


Pages : 1 [2]

the_angry_angel
1st July 2008, 12:28
Is it possible to change the Request ID and the Click ID to a short?Nope - this is a limitation in InSim, not LFS_External. My only suggestion would be to select the player and then present the kick/ban/close buttons for that user only.

2. Is it possible to clear all the buttons on the screen with one command? Yes - although I don't know the LFS_External API I can tell you that you need to send an IS_BFN, with sub type (SubT) of BFN_CLEAR, which will clear all buttons made by that insim instance.

Silox
1st July 2008, 13:15
Nope - this is a limitation in InSim, not LFS_External. My only suggestion would be to select the player and then present the kick/ban/close buttons for that user only.

Thanks for your quick reaction :) I'll try to find a method for this the next days...

Yes - although I don't know the LFS_External API I can tell you that you need to send an IS_BFN, with sub type (SubT) of BFN_CLEAR, which will clear all buttons made by that insim instance.

Well, the problem here is when I try to clear the buttons like you've said with the LFS_External API with this code:
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_CLEA R)
It asks for a RequestId and a UniqueID, and there's no way around to only put the BFN_CLEAR as SubT...

the_angry_angel
1st July 2008, 13:24
Just set them to NULL or 0, would be my suggestion :)

Silox
1st July 2008, 14:03
Just set them to NULL or 0, would be my suggestion :)

That's what I tought too but:
Null is not longer used, use System.DBNull instead.
So I use System.DBNull but:
System.DBNull is a type in system and cannot be be used as an expression

Any ideas?

What I could do too is make the same loop as the loop that creates the buttons so it deletes the buttons button by button, but I think that that's too slow...

EDIT:
When I set the Req ID's to 0, InSim gave an Invalid Button ID error.

the_angry_angel
1st July 2008, 16:10
I have the feeling there maybe a more suitable function to use in LFS_External (Send_BFN_DeleteButton seems to apply very specifically to an IS_BFN with SubT of BFN_DEL_BTN), but I'm afraid that you'll have to wait until someone familiar with it comes along or consult the manual for LFS_External.

My guess would be that you're after something like Send_BFN_Clear.. :shrug: As I say, I don't use LFS_External so I honestly wouldn't know.

dougie-lampkin
1st July 2008, 20:52
I haven't seen anything to delete all the buttons, but I've never had the need to delete them all either. What I do when deleting multiple buttons is to use a for loop. EG:

for (byte ClickID = 0; ClickID <= 255; ClickID++)
{
InSim.Send_BFN_DeleteButton(0, ClickID, 255);
}

If you only need to delete them from one screen, replace 255 with the appropriate UCID.

Hope that helps a bit...

T-RonX
1st July 2008, 21:18
This will do the job:
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_CLEA R, 0, UCID);

Silox
2nd July 2008, 08:07
This will do the job:
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_CLEA R, 0, UCID);

Thank you!
I think the most of my problems are solved now :) but you never know... :D

SkinCast
8th July 2008, 01:52
Hi, i' trying to make Buttons (equal !stats command).

I`ve add it in code:

byte ButtonID1 = 10; (already exist)
byte ButtonIDA = 11;
byte ButtonIDB = 12;
byte ButtonIDC = 13;

And it:

InSim.Send_BTN_CreateButton("^7text", Flags.ButtonStyles.ISB_LEFT, 5, 31, LocationX, 15, ButtonID1, MSO.UCID, 40, false);
InSim.Send_BTN_CreateButton("^6text", Flags.ButtonStyles.ISB_LEFT, 5, 31, LocationY, 15, ButtonIDA, MSO.UCID, 40, false);
InSim.Send_BTN_CreateButton("^7text", Flags.ButtonStyles.ISB_LEFT, 5, 31, LocationA, 15, ButtonIDB, MSO.UCID, 40, false);
InSim.Send_BTN_CreateButton("^6text", Flags.ButtonStyles.ISB_LEFT, 5, 31, LocationB, 15, ButtonIDC, MSO.UCID, 40, false);


But, when i click in close button, only ButtonID1 close. Buttons A, B and C continue in display. Someone helps me ?:D

Silox
8th July 2008, 07:42
This will do the job:
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_CLEA R, 0, UCID);

This is the code to close all buttons...

SkinCast
8th July 2008, 14:40
Works now...

Thanks guy! :thumb:

Silox
8th July 2008, 16:19
Works now...

Thanks guy! :thumb:

Thanks T-RonX ;) He helped me with it too...

SkinCast
10th July 2008, 07:01
How i' create a login system?

How it works:

- Client connect
- Client: !login 'password'*
- Insim: Get the username (key) and 'password'
- Insim: Validade and log in the user
- Client: Acess the account and play

*Registered in .txt of user (pass = "")


I'm trying, but it don't works :(
Someone help me, please :D

Silox
10th July 2008, 07:04
I think you should check out the source of the opensource Cruise, I can help you with some things, not with all but I'll got to work now... I'll post later on some tips...

ReVoX
10th July 2008, 09:44
SkinCast: You can use NCN.Contains and the ussername, you dont need use !login or some.
You want this?
http://www.lfsforum.net/showthread.php?t=45187

SkinCast
10th July 2008, 10:16
No. I want create a login system to protect user accounts.

Rooble
10th July 2008, 14:12
No. I want create a login system to protect user accounts.


Why bother? LFS now requires all demo user names to be registered so there's no chance anyone will now ever have the same username (lfsworldname) so just use this to authenticate users.

SkinCast
10th July 2008, 15:41
i' using version Y to play in LAN mode (Local Host). When someone changes the Key with keygen or realkey, its possible to hack other account.

T-RonX
10th July 2008, 18:19
I update LFS External to version 1.1.1.2. I added the missing send methods for TINY and SMALL packets.

You can update by replacing the dll file and reloading your project.

dougie-lampkin
10th July 2008, 21:40
I update LFS External to version 1.1.1.2. I added the missing send methods for TINY and SMALL packets.

You can update by replacing the dll file and reloading your project.

Nice one ;)

duncan007
11th July 2008, 12:55
Hi all

I have mistmatches between NLP.Info(i).PLID and Players(i).PlayerID created with the NPL event. I test with 20 ai and only 3 have mistmatches.

Any idea ?

Thanks


Edit : in fact i have one player in NLP.info which is not present in Players class. Dunno why.

SkinCast
12th July 2008, 23:38
Its solve "9 players > Cruise Mod close" ? (New dll)

LeifOlav
13th July 2008, 09:51
Anyone know how I can create a button in the MCI packet, because I just get's error when using MCI.Info[0] instead of f.ex NCN.UCID?

Silox
13th July 2008, 10:36
Anyone know how I can create a button in the MCI packet, because I just get's error when using MCI.Info[0] instead of f.ex NCN.UCID?

InSim.Send_BTN_CreateButton("text", Flags.ButtonStyles.ISB_CLICK Or Flags.ButtonStyles.ISB_DARK, x , x , x , x , x, MCI.UCID, x, True)

?

Replace x with the other options; Height, width, top, left, cliqueID, ...

dougie-lampkin
13th July 2008, 11:04
MCI only contains PLID, so you need to "convert" it to UCID by scanning the connections list for it. Replace MCI.Info[0] with:

Players[GetPlyIdx(MCI.Info[0].PLID)].UniqueID

And that will show the UCID of that PLID :thumb:

LeifOlav
13th July 2008, 20:44
I've created a button in the NCN packet, and then I discovered that when I have both lapper and external running, some of the lappers functions stop working. Because when I have the external running, f.ex !drf doesn't work any more. Anyone else experienced the same error? Is there any way I can get around that? :shrug:

LeifOlav
14th July 2008, 10:59
I've created a button in the NCN packet, and then I discovered that when I have both lapper and external running, some of the lappers functions stop working. Because when I have the external running, f.ex !drf doesn't work any more. Anyone else experienced the same error? Is there any way I can get around that? :shrug:

Anyone?

Someone know how I can remove characters from a string? When I get the output from heading and direction to get the angle of the car, i get outputs with both + and -, so I have to remove the - when the output has a - in it. Anyone?

Silox
14th July 2008, 16:10
I've created a button in the NCN packet, and then I discovered that when I have both lapper and external running, some of the lappers functions stop working. Because when I have the external running, f.ex !drf doesn't work any more. Anyone else experienced the same error? Is there any way I can get around that? :shrug:

Yup, the !top nor !stats don't work anymore, I didn't try it yet, but I think the solution is simple: Let your app run on another InSim port...

LeifOlav
14th July 2008, 17:12
Yup, the !top nor !stats don't work anymore, I didn't try it yet, but I think the solution is simple: Let your app run on another InSim port...

But it's not working to run 2 apps on the same server :shrug:

Silox
14th July 2008, 17:41
My program is running with the lapper on the same InSim, only the !commands don't work...

You tested it with different ports?

LeifOlav
14th July 2008, 17:51
My program is running with the lapper on the same InSim, only the !commands don't work...

You tested it with different ports?

Yea, I tested with insim port 28888 for the lapper, and 29999 for the external, but then the lapper stopped working.

SkinCast
17th July 2008, 18:47
Hi to all...

I' created a cruise mod based in buttons. But, when player click in one action (ex.:buy new car), the actions are directed to Host.

No matter the player that clicked... The command is given by the host

Button Code (Buy Uf1):

//Buying UF1
case 181:
InSim.Send_MST_Message("!comprar uf1");
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_CLEA R, 0, BTC.UCID);
break;

duncan007
17th July 2008, 21:14
Hi all

still with my NPL problem.
It sounds that my problem comes from the InSim.Request_NPL_AllPlayers(255) method for populating the players class.
When i have a race with already 16 ia players added my program display only fifteen.
If i start the race from 0 ia player and add one by one as many as i want, i have no problem.
So NPL event is not the problem but the InSim.Request_NPL_AllPlayers(255) is not correct for me with a field already filled with 16 ia players.

If someone can confirm ? :shrug:

Thx
Duncan

LeifOlav
18th July 2008, 10:39
Is it just me and Silox who has this problem with insim and external? :shrug:

dougie-lampkin
18th July 2008, 15:54
My program is running with the lapper on the same InSim, only the !commands don't work...

You tested it with different ports?

Running 2 different InSim apps side-by-side might cause problems with the way both of them receive MSO, and they way in which one might "hide" messages beginning with '!' from another. I'm not sure on that, but it sounds like that could be the problem...


Yea, I tested with insim port 28888 for the lapper, and 29999 for the external, but then the lapper stopped working.

LFS can only have one port open at once, so when you opened 29999, it closed 28888, and killed lapper. You need to run them on the same port as each other...



//Buying UF1
case 181:
InSim.Send_MST_Message("!comprar uf1");
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_CLEA R, 0, BTC.UCID);
break;

When you send a message, it is as if the host has typed it. Send a message like this:

InSim.Send_MST_Message("This is a message!");

And you'll see it in-game as "Host: This is a message!". When you send a ! message, it is the host typing it ;)

To work around this, you could have the contents of the !buy UF1 copied into the case 181, so that it does the same thing as actually typing it.


Hi all

still with my NPL problem.
It sounds that my problem comes from the InSim.Request_NPL_AllPlayers(255) method for populating the players class.
When i have a race with already 16 ia players added my program display only fifteen.
If i start the race from 0 ia player and add one by one as many as i want, i have no problem.
So NPL event is not the problem but the InSim.Request_NPL_AllPlayers(255) is not correct for me with a field already filled with 16 ia players.

If someone can confirm ?

Thx
Duncan

That sounds odd...Are you sure you're counting player 0, as LFS starts from 0?

SkinCast
18th July 2008, 16:03
Works nice!... Thanks dougie-lampkin

LeifOlav
18th July 2008, 16:44
Running 2 different InSim apps side-by-side might cause problems with the way both of them receive MSO, and they way in which one might "hide" messages beginning with '!' from another. I'm not sure on that, but it sounds like that could be the problem...


Okay, thanks for answering :)

Is there a way I can deactivate the external from receive MSO, so it doesn't make problems with the insim? Beacause I don't need the MSO in the external insim. :shrug:

dougie-lampkin
18th July 2008, 17:19
Yes. In the init line, with the password, IP address and InSim port, replace '!' with ' '. This will stop it from displaying messages beginning with a space, which is impossible in LFS, rather than a !. Lapper should be able to receive ! messages then ;)

LeifOlav
18th July 2008, 19:20
Yes. In the init line, with the password, IP address and InSim port, replace '!' with ' '. This will stop it from displaying messages beginning with a space, which is impossible in LFS, rather than a !. Lapper should be able to receive ! messages then ;)

Thanks alot! Your my hero! :thumb: :smileypul

duncan007
19th July 2008, 08:30
I want my hero ! :shrug:

T-RonX
25th July 2008, 18:03
I want my hero ! :shrug:

Your hero has arrived.

I updated LFS External to version 1.1.1.4. Your issue should be fixed now.
Thanks for the help on debugging. :)

duncan007
25th July 2008, 23:20
Unbelievable !
I have my Hero !!
I test this new version asap.
:D

I confirm : He's my HERO ! :thumb:

Silox
26th August 2008, 17:33
I'm back from holiday and trying to script my own ranking ladder server system... Or how you wish to call it ;)

My first problem:
How do you gather all the race finish results from all players? How to display and how to store it? I would like to store the positions of all the finished racers with the Private Sub RES_RaceOrQualifyingResult(ByVal RES As Packets.IS_RES) function.

For example:
Racers finished like this: racer2, racer4, racer1 and racer3 as last. The results should be storred in an array like this: {racer2,racer4,racer1,racer3}.
With this code I can build further on the whole script...

Big question, but after a full day of searching I haven't found an answer...

What I have found is this:
InSim.Request_RES_AllResults()
But I can't find any way to handle or use it.

Thanks in regards, I'll update this post when I've found an answer!

UPDATE
Found more stuff in Private Sub FIN_PlayerFinishedRaces(ByVal FIN As Packets.IS_FIN)
But no way to work with it...

UPDATE 2
Found maybe a way, scripting it now...
Once a players crosses the line, just add him to the array. When the race is finished, divide points :)

UPDATE 3
Seems to work at the last way :D

Funny... Every time I post a problem here, I come up with a solution after 5 minutes ^^

UPDATE 4
Array and stuff is working...

1 more problem:
How can you see that everybody has finished?

Silox
27th August 2008, 18:06
* sigh * coding the whole day about a simple timer issue, I've let 5 professional programmers have a look at it... Noone came up with a solution...

To test where the error was, I tested to following things:
1.
I enabled a timer from the MSO sub. When I type !blaat, a timer gets activated and once it ticks, it says "Blaat". This works.
2.
I replaced the code which is in timer tick function to the code it should be (underneath an example). The code fails with no error.
3.
I placed the code which doesn't works in the timer tick at step 2 to the !request. This works. But the other timer enabled in the that piece of code doesn't.

Here's the piece of code:

Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick

Dim i As Integer

everyfinish = True
InSim.Send_MST_Message("/msg ^7Race ^1ended! ^7Restart in^1 0.5 minutes!")

For i = 0 To UBound(finished)
InSim.Send_MST_Message("/msg " & i + 1 & ". " & finished(i))
Next i
Timer3.Enabled = False
Timer2.Enabled = True
end sub


I'm really tired now, I've worked the whole day and I can't understand why I fail at a simple timer... I hope you guys can come up with a solution.

Reese
10th September 2008, 23:24
Hello
I'm new to VB and I've just started a little OutGauge project with LFS External.
But now I've a problem with the "Flags" packet.

Example:

Select Case CInt(og.Flags)
Case Is = 49152
LBL_OG_Local.Text = "Local = Metric"
LBL_OG_Handbrake.Text = "Handbrake = Off"
LBL_OG_Shiftlight.Text = "Shiftlight = Off"
Case Is = 49156
LBL_OG_Local.Text = "Local = Metric"
LBL_OG_Handbrake.Text = "Handbrake = On"
LBL_OG_Shiftlight.Text = "Shiftlight = Off"
Case Is = 49157
LBL_OG_Local.Text = "Local = Metric"
LBL_OG_Handbrake.Text = "Handbrake = On"
LBL_OG_Shiftlight.Text = "Shiftlight = On"
Case Is = 49153
LBL_OG_Local.Text = "Local = Metric"
LBL_OG_Handbrake.Text = "Handbrake = Off"
LBL_OG_Shiftlight.Text = "Shiftlight = On"
Case Is = 0
LBL_OG_Local.Text = "Local = Imperial"
LBL_OG_Handbrake.Text = "Handbrake = Off"
LBL_OG_Shiftlight.Text = "Shiftlight = Off"
Case Is = 4
LBL_OG_Local.Text = "Local = Imperial"
LBL_OG_Handbrake.Text = "Handbrake = On"
LBL_OG_Shiftlight.Text = "Shiftlight = Off"
Case Is = 5
LBL_OG_Local.Text = "Local = Imperial"
LBL_OG_Handbrake.Text = "Handbrake = On"
LBL_OG_Shiftlight.Text = "Shiftlight = On"
Case Is = 1
LBL_OG_Local.Text = "Local = Imperial"
LBL_OG_Handbrake.Text = "Handbrake = Off"
LBL_OG_Shiftlight.Text = "Shiftlight = On"
End Select

This works but if I do this for ALL Flags it becomes very very long, so I think there must be something shorter, am i right? :)
Please help me ;)

EDIT: Nobody can help me? :( Please I just don't get it^^

MfG Reese

Silox
17th September 2008, 13:50
Ranking System finally finished, and the last (I hope) problem pops up...

In the FIN_PlayerFinishedRaces class, I want to save the playername (pnames) from the player AND the username (unames) from the player to a different array...


Dim pnames(0 to 0), unames (0 to 0) as string

redim preserve pnames(ubound(pnames) + 1)
redim preserve unames(ubound(unames) + 1)

pnames(ubound(pnames)) = Players(GetPlyIdx(FIN.UCID)).Username

' Here's my problem
unames(ubound(unames)) = Players(GetPlyIdx(FIN.UCID)). ???


So... With what do I have to replace the ??? ? Username is not in the list, and when I try it with: Connections(GetConIdx(FIN.UCID)).Username, it returns "" instead of my username. I tried alot of combinations (UCID, PLID, Username, Playername, Players, Connections ... But none of them returned my Username.

Thanks in regards,
Silox aka Tom.

UPDATE:
Got it with some searching around here... Found this:
Connections(GetConnIdx(Players(GetPlyIdx(FIN.PLID) ).UniqueID)).Username

It's weird, because I earlier tried this and it didn't work... Oh well, thanks!

Ramon F.
31st December 2008, 10:08
Hi, I'm using LFS External 1.1.1.4 with VB.NET, LFS Z, all was working fine until I had to write some code in TOC_PlayerCarTakeOver subrutine, when someone take over a car in LFS the event is triggered 3 times with the same data, I'm not sure if this is a problem with Insim or LFS External.

Example:

Dim testTOC As Integer = 0

Private Sub TOC_PlayerCarTakeOver(ByVal TOC As Packets.IS_TOC)
Players(GetPlyIdx(TOC.OldUCID)).UniqueID = TOC.NewUCID ' Update Players[] list
Players(GetPlyIdx(TOC.OldUCID)).PlayerID = TOC.PLID ' Update Players[] list

testTOC += 1
InSim.Send_MST_Message("TOC#: " & testTOC.ToString & " NewUCID: " & TOC.NewUCID.ToString & " OldUCID: " & TOC.OldUCID.ToString & " PLID: " & TOC.PLID.ToString)
End Sub
LFS Message:

Host: TOC#: 1 NewUCID: 5 OldUCID: 0 PLID: 1
Host: TOC#: 2 NewUCID: 5 OldUCID: 0 PLID: 1
Host: TOC#: 3 NewUCID: 5 OldUCID: 0 PLID: 1
Could anyone confirm please if this is the way it should work or if there is a problem with LFS External or Insim?

Thank you and sorry for my english.

T-RonX
1st January 2009, 12:40
I can't reproduce that, though I tested with the new upcoming version of LFS External. But I doubt its an error in the current version tbh.

Note that the new version (which is absolutely great :nod:) is coming out soon.

mcgas001
1st January 2009, 13:05
I think this is the same problem I had a while ago. Basically, if you look at the code. You are looking through the players list for a PLID, but you are parsing a UCID to the code.

Replace the 2 lines of code that are ment to update the players list with the following and it should be fixed.

Players(GetPlyIdx(TOC.PLID)).UniqueID = TOC.NewUCID
Players(GetPlyIdx(TOC.PLID)).PlayerName = Connections(GetConnIdx(TOC.NewUCID)).PlayerName

HTH :)

Ramon F.
1st January 2009, 16:11
Thanks T-RonX, great news :thumb:, I'll wait for the new version.

@ mcgas001, thx for your help, the problem is not the Players list update but some extra code that I wrote, it's running 3 times instead of 1 because I'm getting 3 TOCs :(, I'm still wondering what could be wrong :scratchch

Happy new year!

emtark
1st January 2009, 16:31
Hello
I'm new to VB and I've just started a little OutGauge project with LFS External.
But now I've a problem with the "Flags" packet.

Example:

Select Case CInt(og.Flags)
Case Is = 49152
LBL_OG_Local.Text = "Local = Metric"
LBL_OG_Handbrake.Text = "Handbrake = Off"
LBL_OG_Shiftlight.Text = "Shiftlight = Off"
Case Is = 49156
LBL_OG_Local.Text = "Local = Metric"
LBL_OG_Handbrake.Text = "Handbrake = On"
LBL_OG_Shiftlight.Text = "Shiftlight = Off"
Case Is = 49157
LBL_OG_Local.Text = "Local = Metric"
LBL_OG_Handbrake.Text = "Handbrake = On"
LBL_OG_Shiftlight.Text = "Shiftlight = On"
Case Is = 49153
LBL_OG_Local.Text = "Local = Metric"
LBL_OG_Handbrake.Text = "Handbrake = Off"
LBL_OG_Shiftlight.Text = "Shiftlight = On"
Case Is = 0
LBL_OG_Local.Text = "Local = Imperial"
LBL_OG_Handbrake.Text = "Handbrake = Off"
LBL_OG_Shiftlight.Text = "Shiftlight = Off"
Case Is = 4
LBL_OG_Local.Text = "Local = Imperial"
LBL_OG_Handbrake.Text = "Handbrake = On"
LBL_OG_Shiftlight.Text = "Shiftlight = Off"
Case Is = 5
LBL_OG_Local.Text = "Local = Imperial"
LBL_OG_Handbrake.Text = "Handbrake = On"
LBL_OG_Shiftlight.Text = "Shiftlight = On"
Case Is = 1
LBL_OG_Local.Text = "Local = Imperial"
LBL_OG_Handbrake.Text = "Handbrake = Off"
LBL_OG_Shiftlight.Text = "Shiftlight = On"
End Select

This works but if I do this for ALL Flags it becomes very very long, so I think there must be something shorter, am i right? :)
Please help me ;)

EDIT: Nobody can help me? :( Please I just don't get it^^

MfG Reese


Hi MfgReese,

I have dug up this which I found recently which explains comparing bits in bytes, as this is how the flags work (as i understand..)

http://stackoverflow.com/questions/127027/how-to-check-my-byte-flag

Basically if you compare the flag you want (say OG_SHIFTLIGHT) or whatever it is, with the OG_FLAGS, you will get either a 0 or 1 result (true or false).


If OG_FLAGS AND OG_SHIFTLIGHT = TRUE THEN
'do something because the shiftlight is on
Else
'shift light is off
End If


Sorry my reply isn't earlier but I've only started reading this thread tonight.. and it's 4am at the moment so if the syntax in the code is wrong I apologise as well :scratchch

Tim.

T-RonX
1st January 2009, 16:39
This is how I check if a flag is set:

Flags.OutGaugeFlags _flags;

bool shiftlight = (_flags & Flags.OutGaugeFlags.OG_SHIFTLIGHT) == Flags.OutGaugeFlags.OG_SHIFTLIGHT;

In the next version of LFS External all flags are pre parsed, so no more issues with this. :)

DarkTimes
1st January 2009, 16:53
edit: irrelevant.

Ramon F.
1st January 2009, 18:49
That's it DarkTimes!!! thanks a million, I was fighting with delegates two weeks ago and wrote some Invokes, not too well I must say :doh:, I think it's time to read more tutorials :Kick_Can_

KlausAdam
2nd January 2009, 10:44
In the next version of LFS External all flags are pre parsed, so no more issues with this. :)

Very good to hear that LFS External is still in progress. I was pretty scared about it, cause I like to use it very much for my insim-applications. So :thumb:

Marco1
2nd January 2009, 15:44
whyt kinds of apps are oyu making "KlausAdam"?

Napalm Candy
2nd January 2009, 16:47
Please, anyone can to put an example to connect to InSim in VisualBasic? I have an example for OutGauge, and I extended this program.. but I don't know how to connect to InSim :(

T-RonX
2nd January 2009, 21:07
Please, anyone can to put an example to connect to InSim in VisualBasic? I have an example for OutGauge, and I extended this program.. but I don't know how to connect to InSim

There is an InSim example available for VB .NET in the first post. It should connect to an InSim host with default settings.

Is it an error you get or anything else? Is there a firewall between InSim host and external app? Are you trying yo connect to a dedi host or local? did you type /insim 29999? Is the admin password setup correctly?

KlausAdam
5th January 2009, 10:12
whyt kinds of apps are oyu making "KlausAdam"?

Some applications for the DoP like RaceTracker, HUD, SignIn-Tool, Qualify-Tool...

madrofiel
5th January 2009, 19:49
Hey,

i've seen in the InSim.txt that its possible to make Textboxes and Textbox dialogs in the game through insim, is this already implented becouse i couldnt find it ><

T-RonX
5th January 2009, 19:52
Hey,

i've seen in the InSim.txt that its possible to make Textboxes and Textbox dialogs in the game through insim, is this already implented becouse i couldnt find it ><

This might help:
http://www.lfsforum.net/showthread.php?p=577998#post577998

madrofiel
5th January 2009, 19:54
i did that already but when the ISB_CLICk is used it wont be a textbox

struct IS_BTN // BuTtoN - button header - followed by 0 to 240 characters
{
byte Size; // 12 + TEXT_SIZE (a multiple of 4)
byte Type; // ISP_BTN
byte ReqI; // non-zero (returned in IS_BTC and IS_BTT packets)
byte UCID; // connection to display the button (0 = local / 255 = all)

byte ClickID; // button ID (0 to 239)
byte Inst; // some extra flags - see below
byte BStyle; // button style flags - see below
byte TypeIn; // max chars to type in - see below <-----

byte L; // left : 0 - 200
byte T; // top : 0 - 200
byte W; // width : 0 - 200
byte H; // height : 0 - 200

// char Text[TEXT_SIZE]; // 0 to 240 characters of text
};

The TypeIn is what i'm missing

// TypeIn byte : if set, the user can click this button to type in text.

// Lowest 7 bits are the maximum number of characters to type in (0 to 95)
// Highest bit (128) can be set to initialise dialog with the button's text

// On clicking the button, a text entry dialog will be opened, allowing the specified number of
// characters to be typed in. The caption on the text entry dialog is optionally customisable using
// Text in the IS_BTN packet. If the first character of IS_BTN's Text field is zero, LFS will read
// the caption up to the second zero. The visible button text then follows that second zero.

and i dont get this really >< maybe you do lol

T-RonX
5th January 2009, 19:56
Parameter number 8 in the overloaded method, like in the picture.

madrofiel
5th January 2009, 19:59
yeah lol now i see it XD haha

thx lol

T-RonX
5th January 2009, 20:03
// Lowest 7 bits are the maximum number of characters to type in (0 to 95)
// Highest bit (128) can be set to initialise dialog with the button's text


This is not very well implemented in the current version, but you can set these bits manually with the Flags parameter. (edit: I ment BStyle flags)
In the new version these bits are more user friendly.

But I don't know what the highest bit in that byte does, I implemented it but I don't see any change when I set that bit

Does anybody know? :shrug:

madrofiel
5th January 2009, 20:08
well, if i read further it has to open a window with a textbox :S

EDIT1:
:O its now doing that. so there has to be a way to type it in the button itself ><

EDIT2:
hmm, if i understand this. bit 1 to 7 are for the length and if the 8th bit is set to 128 the dialog has to popup

EDIT3:
lol, i see changes ><, when i do at typein "95 | 128" it shows me a dialog with the text as dialogtext

dougie-lampkin
21st March 2009, 19:41
Am I missing something, or can REOs not be sent? REO is available to send as a TINY, but then you can't send the new grid PLID array. Should there be InSim.Send_REO_RaceStartOrder or similar, or am I doing it wrong? :shy:

T-RonX
22nd March 2009, 18:24
Yes its missing indeed. But I've already implemented this in the new version which is coming soon. If you really need this and can't use the new version for some reason I might consider adding it in the current.

dougie-lampkin
22nd March 2009, 19:20
No worries, there's no rush ;) Just to make sure I wasn't failing again :D

Init.A.D
25th May 2009, 17:32
Yes its missing indeed. But I've already implemented this in the new version which is coming soon. If you really need this and can't use the new version for some reason I might consider adding it in the current.

Hi, T!

Have we changes no LFS External for VB?

I would like implement HANDBRAKE, PITSPEED, HEADLIGHTS, etc... :D.

Thx!!:thumb:

gru
30th May 2009, 09:28
hello

does Lfs External have transfer meter and packets queueing functionality? (didnt find it in docs)

we are developing cruise system (based on dougie-lampkin's code, thx dougie :-), and we have lags when broadcasting multiple messages (our insim server has weak upload :\)
first we need transfer meter, so we could diagnose and improve our code.
and i think we also need some packets queueing, so we could decrease PPS and match to our poor connection

do U think, U could add this functionality for us, or pass me source code so i could add it myself?

thx in advance :)

edit:
nevermind, did it myself

broken
21st June 2009, 22:06
I do believe there is one mistake in the code.
Player swap is wrong imo. Let me show you what I mean:

// A player joins the race. If PLID already exists, then player leaves pit.
private void NPL_PlayerJoinsRace(Packets.IS_NPL NPL)
{
bool LeavesPits = AddToPlayersList(NPL); // Update Players[] list

// Your code here
}

// Car was taken over by an other player
private void TOC_PlayerCarTakeOver(Packets.IS_TOC TOC)
{
Players[GetPlyIdx(TOC.OldUCID)].UniqueID = TOC.NewUCID; // Update Players[] list
Players[GetPlyIdx(TOC.OldUCID)].PlayerID = TOC.PLID; // Update Players[] list

// Your code here
}

Players[GetPlyIdx(NEED.PLID.NOT.UCID)]

// A player joins the race. If PLID already exists, then player leaves pit.
private void NPL_PlayerJoinsRace(Packets.IS_NPL NPL)
{
bool LeavesPits = AddToPlayersList(NPL); // Update Players[] list
//And tiny addon
Connections[GetConnIdx(NPL.UCID)].PLID = NPL.PLID;

// Your code here
}

// Car was taken over by an other player
private void TOC_PlayerCarTakeOver(Packets.IS_TOC TOC)
{
try
{
Players[GetPlyIdx(Connections[GetConnIdx(TOC.OldUCID)].PLID)].UniqueID = TOC.NewUCID; // Update Players[] list
Players[GetPlyIdx(Connections[GetConnIdx(TOC.OldUCID)].PLID)].PlayerID = TOC.PLID; // Update Players[] list
//And another tiny addon
Connections[GetConnIdx(TOC.OldUCID)].PLID = TOC.PLID; // Update Connections[] list

// Your code here
}
catch (Exception EX)
{
//If you want to catch exception info do it here... If not -> Remove try and catch codes. Easy ;)
}
}

Of course to make this work you have to add byte(I have added is as an int idk why) PLID in clsConnection and I will leave this easy job to you. :)

vane
2nd July 2009, 21:30
I have just got back into LFS and with it, into LFS programming again, my query is:

It may have been mentioned early but can this be set up as purely a client side Insim? eg outside of the server, i may have forgotten somethign that is really silly :) haven't done it for so long!

DarkTimes
2nd July 2009, 22:59
I don't know LFS_External personally, but I see no reason why not. InSim works almost identically for local clients and hosts, so it shouldn't be a problem. I do almost all my testing against a local client.

broken
6th July 2009, 19:11
Hi again. I have this weird problem with the newer library. Just want to know if I'm doing something wrong. When I send a longer message or want to send a button with a longer length of the text I get this:

System.ArgumentException: The output byte buffer is too small to contain the encoded data, encoding 'US-ASCII' fallback 'System.Text.EncoderReplacementFallback'.
Parameter name: bytes

I have this issue since I updated LFS_External library to 1.1.1.4. I don't want to revert back to old version because I can't send tinys there. But in this I can't make buttons with longer text(at least not yet xD). Thanks. :)

DarkTimes
6th July 2009, 20:56
How long is the string you are trying to send? MST messages are only up to 64 chars in length, MSX 96 chars, and BTN up to 240 chars. The exception message would suggest to me you were trying to send a string longer than it was expecting.

broken
7th July 2009, 10:44
Thanks for the reply.

The button I tried to send had about 70-80 characters. And, yes, about messages... I know the limit is around that but still - in the previous version it used to cut the message for you. And now it just throws an exception. Anyway the exception on MST and messages to connection is not such a big deal, but the thing with the button.. It's kinda weird.

DarkTimes
7th July 2009, 16:48
Well it sounds like a bug. Button and message text need to be handled differently internally, so it's not surprising you can have an error in one and not the other. Of course I'm not the author and I don't know the code, so I should probably shutup. :p

broken
8th July 2009, 18:14
Well now I got version 1.1.0.0 and it all works fine. Except that there are no TINYs but I can live with that. Thanks for the help tho. :)

vane
10th July 2009, 14:11
Is there any way i can start a button underneath a 'private void button1_Click(object sender, EventArgs e)'?

I was thinking about the UCID problem, can anyone help me?

danthebangerboy
10th July 2009, 20:23
I must learn how to do this kind of stuff one day. Amazing to think that there are people who are 10 years younger than me who can do this stuff with their eyes shut practically.

vane
10th July 2009, 23:34
I can't quite do it with my eyes shut but... :)

broken
11th July 2009, 03:04
I must learn how to do this kind of stuff one day. Amazing to think that there are people who are 10 years younger than me who can do this stuff with their eyes shut practically.

It's like learning different type of english. Well also you need some logical thinking, but as I can see you have passed 5th grade some long time ago, and so I believe it wouldn't be a hard thing to do.. but who knows. Good luck :thumb:

vane
12th July 2009, 01:51
Can anyone answer my question?

I will repost it incase it got lost

Is there any way i can start a button underneath a 'private void button1_Click(object sender, EventArgs e)'?

I was thinking about the UCID problem, can anyone help me?

broken
12th July 2009, 09:16
Can anyone answer my question?

I will repost it incase it got lost

It is possible. Just when declaring InSim put "static public " in front of it and you can access it from any thread and any class you want and need. :thumb:

If you can't understand what I mean then I'm going to post the exact code some time later(when I open up C#).

vane
12th July 2009, 22:04
is that what you mean?
private void button1_Click(object sender, EventArgs e)
{
static public InSim.Send_BTN_CreateButton("Button Text", "Title", Flags.ButtonStyles.ISB_DARK | Flags.ButtonStyles.ISB_CLICK, 5, 30, 100, 10, 96, 1, ???, 40, false);
}

broken
13th July 2009, 06:39
is that what you mean?
private void button1_Click(object sender, EventArgs e)
{
static public InSim.Send_BTN_CreateButton("Button Text", "Title", Flags.ButtonStyles.ISB_DARK | Flags.ButtonStyles.ISB_CLICK, 5, 30, 100, 10, 96, 1, ???, 40, false);
}

I just opened C#.. Give me just a seconds to find the code.
Found it. It's the 1st line of code on your form. There:
public partial class Form1 : Form
{
// Main InSim object
static public InSimInterface InSim;
[.............................]
}

But when rethinking if the button is on the same form then you shouldn't need this. You would just need to do:
private void button1_Click(object sender, EventArgs e)
{
InSim.Send_BTN_CreateButton("Button Text", "Title", Flags.ButtonStyles.ISB_DARK | Flags.ButtonStyles.ISB_CLICK, 5, 30, 100, 10, 96, 1, ???, 40, false);
}
Anyway to create a insim button when pressing a form button then you would need the UCID of the user you want it to be sent to. But if you want it for everyone then as you know you can just use 255. ;)

gru
13th July 2009, 07:37
InSim doesnt have to be static if its declared in MainForm (Form1?)

Anyway to create a insim button when pressing a form button then you would need the UCID of the user you want it to be sent to. But if you want it for everyone then as you know you can just use 255
vane, if U want to send button to just one connection, then i suppose U need some control containing all players. ListBox maybe?
ListBox.Items is typeof ObjectCollection, so U can make custom item class:


public class ListBoxItem
{
private string _name;
private ushort _id;

public ListBoxItem(string playerName, ushort connectionId)
{
_name = playerName;
_id = connectionId;
}

public override string ToString()
{
return _name;
}

public ushort ConnectionId
{
get
{
return _id;
}
}
}


adding new item to ListBox (NCN_Received event handler)


_listBox.Items.Add(new ListBoxItem(NCN.PName, NCN.UCID));


getting id on button click


private void button1_Click(object sender, EventArgs e)
{
if (_listBox.SelectedItem == null)
return;

ListBoxItem item = (ListBoxItem)_listBox.SelectedItem;
InSim.Send_BTN_CreateButton("Button Text", "Title", Flags.ButtonStyles.ISB_DARK | Flags.ButtonStyles.ISB_CLICK, 5, 30, 100, 10, 96, 1, item.ConnectionId, 40, false);
}


code not tested

vane
13th July 2009, 12:09
thank you for the large amounts of code, but this is only mean to be a client side insim, creating buttons only on the client's lfs, not meant to be run on a server or anything. I have tried setting the UCID to 0 and 1 but that didnt work, i will try 255.

broken
13th July 2009, 12:25
thank you for the large amounts of code, but this is only mean to be a client side insim, creating buttons only on the client's lfs, not meant to be run on a server or anything. I have tried setting the UCID to 0 and 1 but that didnt work, i will try 255.

UCID = 0 -> Host
UCID = 1 -> 1st player that has connected after the start of the server(not 100% sure if that's true)
Maybe if you give us some more information of what you are trying to do we may be able to help you out. :scratchch

vane
13th July 2009, 12:50
well basically i am trying to find out how to make the insim buttons from say a timer ticking or a form button press. I am attempting to make an interface which is controlled by the scroll wheel on the DFGT steering wheel, and the insim part is so you can control features while in game, so effectively the insim isn't doing much more than just displaying buttons

broken
13th July 2009, 14:16
Oh now I see what you mean by client-side insim. Well... In this case if you aren't the host there should be no problem in using 255 as UCID. I am not familiar with client-side insims tho so I can't say for sure. :shrug:

vane
13th July 2009, 17:37
I have tried changing the BTN.UCID to 255 but it still did not make the button appear when the form button was pressed.

I have succesfully coded the part that interfaces with the controller and all the ancillary systems such as saving the data into an xml file to be loaded next time the program is loaded

vane
13th July 2009, 23:59
Also, is there any way of viewing this insim on a server that has an insim?

gru
14th July 2009, 07:02
I have tried changing the BTN.UCID to 255
handle NCN_Received event, struct IS_NCN has field Flags, bit 2 tells U if its local or remote connection. if its local, store UCID in some global variable, then use it for button send
but 255 should work, are U sure rest of code is proper?

Also, is there any way of viewing this insim on a server that has an insim?
sure, of course Your program must know address, port and admin password

edit:
sorry, didnt get Ya, thought U asked for using insim with remote dedi server

vane
14th July 2009, 12:47
when i tried to open my insim in a server that already had an insim, the buttons from my insim did not show up :s

broken
14th July 2009, 12:51
when i tried to open my insim in a server that already had an insim, the buttons from my insim did not show up :s

Show us the code of how you send the buttons maybe?

DarkTimes
14th July 2009, 17:55
when i tried to open my insim in a server that already had an insim, the buttons from my insim did not show up :s

Sorry, not been following this thread, but if you are connecting to a local client, then you need to set the flag ISF_LOCAL in the IS_ISI packet, otherwise the buttons will clash with those sent by a host.

// The ISF_LOCAL flag is important if your program creates buttons.
// It should be set if your program is not a host control system.
// If set, then buttons are created in the local button area, so
// avoiding conflict with the host buttons and allowing the user
// to switch them with SHIFT+B rather than SHIFT+I.

This could be your error...

vane
14th July 2009, 21:04
ah thank you dark times, that is probably what i want, i will try it now

EDIT: ok i have tried:

InSim.Send_BTN_CreateButton("^7LFS SC ^3v1.0", "text", Flags.ButtonStyles.ISB_DARK|Flags.InSimFlags.ISF_L OCAL, 3, 10, 190, 160, 96, 1, BFN.UCID, 40, false);

it says i can't use insimflags in it :s

EDIT 2: ah i got you, need to enter it like this:

InSimSettings Settings = new InSimSettings("127.0.0.1", 29999, 0, Flags.InSimFlags.ISF_MSO_COLS | Flags.InSimFlags.ISF_MCI | Flags.InSimFlags.ISF_LOCAL, '!', 500, "4576537535", "^7LFS CS", 5);

vane
14th July 2009, 22:15
OK thats working now, although it still says that the admin password is wrong

tmehlinger
21st July 2009, 04:50
I'm having some trouble getting OutGauge to work with LFS_External. I have it set to listen on port 30001 and my LFS config is as follows:


OutGauge Mode 2
OutGauge Delay 10
OutGauge IP 127.0.0.1
OutGauge Port 30001
OutGauge ID 0


Even the OutGauge sample application does nothing, the RPM and Pitch fields remain blank. If I look at netstat output in a terminal, it shows a service listening on UDP port 30001, so I know it's listening, it just never seems to call the event handler.

Any ideas?

DarkTimes
21st July 2009, 08:03
Make sure you are using an internal car view, as it only works when you are viewing from the cockpit.

bunder9999
6th August 2009, 19:15
i'm working on a c# project. is it possible to move the LFS_External.dll file into my app's resources and makes calls to it from within my program? (to save on having to distribute the dll separately)

thanks

DarkTimes
7th August 2009, 10:36
Someone can correct me if I'm wrong, but I don't think it's possible to do this. You can add a DLL to your main assembly as an embedded resource, but if you use that DLL as a reference then I believe it needs to be separate.

That said there is a tool called ILMerge (http://www.microsoft.com/downloads/details.aspx?FamilyID=22914587-b4ad-4eae-87cf-b14ae6a939b0&displaylang=en) which can merge multiple assemblies into one, but I've never personally used it and don't know if it would work for your intentions.

bunder9999
7th August 2009, 12:00
someone had mentioned ilmerge to me but i'm a little unsure as to how i use it... do i code my app normally with the dll outside, and then stuff it inside with this app? :shrug:

DarkTimes
7th August 2009, 12:49
As I say I've never used it myself, I don't know. :)

DavidTiger
7th August 2009, 12:59
Someone can correct me if I'm wrong, but I don't think it's possible to do this. You can add a DLL to your main assembly as an embedded resource, but if you use that DLL as a reference then I believe it needs to be separate.

Maybe you can embed it as a resource and on first run, extract it to a folder, eg LFS root, but I'm not sure about refrencing it that way.

bunder9999
7th August 2009, 13:01
that's another idea i hadn't thought about... i'm already extracting a skin and a setup file, what's one more file gong to hurt? :D

bunder9999
14th August 2009, 19:04
just wanted to bump this to let people know it is possible to use resource-embedded dll's... you put the dll into resources and call it like this:

namespace My_Prog_Name
{
public partial class Form1 : Form
{
[DllImport(My_Prog_Name.Properties.Resources.NameOf DLL)]
...
...
...

cheers

broken
15th August 2009, 09:34
just wanted to bump this to let people know it is possible to use resource-embedded dll's... you put the dll into resources and call it like this:

namespace My_Prog_Name
{
public partial class Form1 : Form
{
[DllImport(My_Prog_Name.Properties.Resources.NameOf DLL)]
...
...
...

cheers

Now that would come in very handy, when I decide to continue my projects. Thanks! :thumb:

Naruto06
19th August 2009, 22:24
i would like to know if anyone can post a string here for insim that only allows a specific person to use a command. currently all i want to do is make !happyhour on my insim so only i can activate it. THANKS! :thumb:

broken
20th August 2009, 12:22
i would like to know if anyone can post a string here for insim that only allows a specific person to use a command. currently all i want to do is make !happyhour on my insim so only i can activate it. THANKS! :thumb:

if (Connections[GetConnIdx(MSO.UCID)].Username == "Naruto06") {
//Your code here
}
Upper code: Will work only for you username

Code below: Will work with your username or if the user is an admin. Hope I've(with the help and idea of Silox) helped. ;)
if (Connections[GetConnIdx(MSO.UCID)].Username == "Naruto06" || Connections[GetConnIdx(MSO.UCID)].IsAdmin == 1) {
//Your code here
}
Note: Not tested, but it should work.
Someone correct me if something's wrong.

Fixed and added one more example: Thanks, Silox. :)

Silox
20th August 2009, 17:13
You forgot a " after the username ;)

If you want that only admins can use it, you can check through: MSO.Isadmin = 1

misiek08
25th August 2009, 14:54
Can someone rewrite InSim sample to Console in C#? I need to run InSim on VPS (Debian 5.0).

Thx. Misiek

danbbt
4th September 2009, 21:10
Hi guys!

Anyone know how get and set the player status in the start grid with
LFS_External library or similar? The idea is make a custom Start Grid...
Helpme please! ;)

Thanks!

danbbt
7th September 2009, 00:30
Please guys...

How can I send a Tiny packet??? I want send a IS_REO packect in C#, but i cant find the sintaxis for Send_TINY... Please helpme... :(

Thankyou!

danbbt
7th September 2009, 00:47
Please,

How can I send a REO packet in C#. What method can I use?

Thanks.

misiek08
7th September 2009, 14:25
Can someone rewrite InSim sample to Console in C#? I need to run InSim on VPS (Debian 5.0).

Thx. Misiek

I really need it and I think is not so hard for some people to do.

kyler
3rd November 2009, 00:39
Does anyone know how i can make the LFS_External.dll accept the new outgauge flags? or is there a LFS_External.dll for z25?

DavidTiger
3rd November 2009, 11:54
I know how to do this using, a socket control VB6, see if you can use any of this..

Public Type OutGaugePacket
Time(0 To 3) As Byte 'time in milliseconds (to check order)
Car(0 To 3) As Byte 'Car name
Flags As Integer '(0 To 1) As Byte 'Combination of OG_FLAGS, see below
Gear As Byte 'Reverse:0, Neutral:1, First:2...
SpareB As Byte 'Spare
Speed As Single 'M/S
Rpm As Single 'RPM
Turbo As Single 'BAR
EngTemp As Single 'C
Fuel As Single '0 to 1
OilPress As Single 'BAR
OilTemp As Single 'C
DashLights As Long
ShowLights As Long
Throttle As Single '0 to 1
Brake As Single '0 to 1
Clutch As Single '0 to 1
Display1(0 To 15) As Byte 'Usually Fuel
Display2(0 To 15) As Byte 'Usually Settings
ID As Long '(optional ID - if specified in cfg.txt)
End Type

Public Const DL_SHIFT = 1 '; // bit 0 - shift light
Public Const DL_FULLBEAM = 2 '; // bit 1 - full beam
Public Const DL_HANDBRAKE = 4 '; // bit 2 - handbrake
Public Const DL_PITSPEED = 8 '; // bit 3 - pit speed limiter
Public Const DL_TC = 16 '; // bit 4 - TC active or switched off
Public Const DL_SIGNAL_L = 32 '; // bit 5 - left turn signal
Public Const DL_SIGNAL_R = 64 '; // bit 6 - right turn signal
Public Const DL_SIGNAL_ANY = 128 '; // bit 7 - shared turn signal
Public Const DL_OILWARN = 256 '; // bit 8 - oil pressure warning
Public Const DL_BATTERY = 512 '; // bit 9 - battery warning
Public Const DL_ABS = 1024 ' ; // bit 10 - ABS active or switched off
Public Const DL_SPARE = 2048 '; // bit 11
Public Const DL_NUM = 4096 '; //noinfo
Public Const OG_TURBO = 8192 '; // show turbo gauge
Public Const OG_KM = 16384 '; // if 0 set - user prefers MILES
Public Const OG_BAR = 32768 '; // if 0 set - user prefers PSI

then just do the same as you did in prevous patches, but use the new variables

If (Packet.ShowLights And DL_HANDBRAKE) > 0 Then
HandbrakeLightON.Visible = True
HandbrakeLightOFF.Visible = False
Else
HandbrakeLightON.Visible = False
HandbrakeLightOFF.Visible = True
End If

*note: Public Packet As OutGaugePacket

Hope that helps...
-David:thumb:

kyler
4th November 2009, 00:27
I'm using VB 2008 u have any suggestion? on doing that?

kyler
5th November 2009, 07:07
Anyone? Please help me.

DavidTiger
5th November 2009, 10:26
It should be pretty similar since LFS_External has OutGauge functions in it..
I've thought about updating the program to 2008 as VB6 is very very buggy on windows 7 even in compatability modes :shrug:

I'll look into it and post my findings :D

-David:thumb:

DavidTiger
5th November 2009, 14:12
The DLL would need to be updated for z25??

kyler
5th November 2009, 22:12
yeah because atm the DLL is only set for getting OG_Headlights, OG_Flashers (just examples) so u would need to redo the dll to read the DL_Headlights and stuff...

DarkTimes
5th November 2009, 23:37
It would need to be updated by T-RonX as far as I know. The program is closed source.

T-RonX
6th November 2009, 07:11
It would need to be updated by T-RonX as far as I know. The program is closed source.

I'm working on version 1.3 which is based on version 1.2 (which i never released because of a bug i couldn't fix) and rewrote the core of it.

Obviously it will be Z25 compatible and will have some very nice features like requesting a packet directly instead of calling an event. All flags will be pre-parsed, and finally it will have UTF-8 support.

kyler
7th November 2009, 05:23
Thanks dude that will be really cool! i cant wait i have some BIG! plans ;) but thanks for letting us know hope it comes soon :)

kyler
16th November 2009, 03:33
Any new? when to expect a release?

dawesdust_12
16th November 2009, 08:37
I'm working on version 1.3 which is based on version 1.2 (which i never released because of a bug i couldn't fix) and rewrote the core of it.

Obviously it will be Z25 compatible and will have some very nice features like requesting a packet directly instead of calling an event. All flags will be pre-parsed, and finally it will have UTF-8 support.

That sounds actually very fantastic, especially for my applications I intend on writing.

:)

broken
16th November 2009, 14:14
I'm working on version 1.3 which is based on version 1.2 (which i never released because of a bug i couldn't fix) and rewrote the core of it.

Obviously it will be Z25 compatible and will have some very nice features like requesting a packet directly instead of calling an event. All flags will be pre-parsed, and finally it will have UTF-8 support.
Awesome! I can finally get rid of some files in the folder, made for the only purpose to store special characters in case I need the insim hosted on other PC ...I hope? :D

gru
17th November 2009, 06:06
not sure if it was reported already
there is bug in 1.1.1.4, button text is limited to 64 chars (it should allow 240), sending longer text throws exception (method Send_BTN_CreateButton)

Reese
26th November 2009, 19:23
I just don't understand how to use the flags. I posted this here some time ago and got a few replies... thanks so far! But it just won't work for me :)
If I try:

If (og.Flags & Flags.OutGaugeFlags.OG_PITSPEED) > 0 Then
MsgBox("ON")
Else
MsgBox("OFF")
End If

or

If (og.Flags & Flags.OutGaugeFlags.OG_PITSPEED) = True Then
MsgBox("ON")
Else
MsgBox("OFF")
End If

I ALWAYS get a MsgBox telling me the pitspeed limiter is ON...

If I try:

If (og.Flags And Flags.OutGaugeFlags.OG_PITSPEED) > 0 Then
MsgBox("ON")
Else
MsgBox("OFF")
End If

or

If (og.Flags And Flags.OutGaugeFlags.OG_PITSPEED) = True Then
MsgBox("ON")
Else
MsgBox("OFF")
End If

I ALWAYS get a MsgBox telling me the pitspeed limiter is OFF...

Please help me :)

EDIT: I've tested this with Z28 and the BF1 so there isn't ABS or something like that^^

EDIT2:

If (og.Flags & Flags.OutGaugeFlags.OG_PITSPEED) = Flags.OutGaugeFlags.OG_PITSPEED Then
MsgBox("ON")
Else
MsgBox("OFF")
End If

ALWAYS leads to "OFF" no matter whether "&" or "And"

MfG Reese

Azzano62
26th November 2009, 21:08
I have the same problem i cant get it to read the flags when someone disconnects but it someone times out it says they disconnected can anyone give me a hand with this i never thought i needed the flags till recent when ive been trying to implement added mass and other things

VeGe-
27th November 2009, 10:40
LFS currently uses DL's, not OG's anymore. LFS Extrenal is unfortunately yet to be updated as it only supports old OG's. T-RonX is on it, so hopefully it's only matter of time when new lib is released. I have project of my own (new gauge lights) so I'm waiting this too.

Here is chapter from LFS\Doc\InSim.txt which contains the updated flags:

DL_SHIFT, // bit 0 - shift light
DL_FULLBEAM, // bit 1 - full beam
DL_HANDBRAKE, // bit 2 - handbrake
DL_PITSPEED, // bit 3 - pit speed limiter
DL_TC, // bit 4 - TC active or switched off
DL_SIGNAL_L, // bit 5 - left turn signal
DL_SIGNAL_R, // bit 6 - right turn signal
DL_SIGNAL_ANY, // bit 7 - shared turn signal
DL_OILWARN, // bit 8 - oil pressure warning
DL_BATTERY, // bit 9 - battery warning
DL_ABS, // bit 10 - ABS active or switched off
DL_SPARE, // bit 11
DL_NUM

jto93
5th December 2009, 15:29
Hello!

im trying to learn some C# while making this, so dont shoot me :p

i have managed to copy/paste the code below:
InSim.Send_BTN_CreateButton("^7Drift Angle: " + Convert.ToInt16((MCI.Info[i].Heading * (180f / 16384f)) - (MCI.Info[i].Direction * (180f / 16384f))), Flags.ButtonStyles.ISB_DARK, 5, 30, 0, 64, 171, (Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID), 2, false);

what im trying to do is to show drift angle of car. i think its working a bit, but weird numbers suddenly appear. sorry to bother you guys

EDIT: found the problem... stupid me it wasnt 180f / 16384f but 180f / 32768f

broken
5th December 2009, 22:18
Hello!

im trying to learn some C# while making this, so dont shoot me :p

i have managed to copy/paste the code below:
InSim.Send_BTN_CreateButton("^7Drift Angle: " + Convert.ToInt16((MCI.Info[i].Heading * (180f / 16384f)) - (MCI.Info[i].Direction * (180f / 16384f))), Flags.ButtonStyles.ISB_DARK, 5, 30, 0, 64, 171, (Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID), 2, false);what im trying to do is to show drift angle of car. i think its working a bit, but weird numbers suddenly appear. sorry to bother you guys

EDIT: found the problem... stupid me it wasnt 180f / 16384f but 180f / 32768f
Good work there.. thinking learners are a rare situation here. Especially ones that re-check their code while waiting for replies instead of making someone else do it for them. :)

Actually, you're the first one that I, personally see. Good luck with your application and keep it up like this. :thumb:

I'm just so impressed... :D

jto93
6th December 2009, 10:21
Good work there.. thinking learners are a rare situation here. Especially ones that re-check their code while waiting for replies instead of making someone else do it for them. :)

Actually, you're the first one that I, personally see. Good luck with your application and keep it up like this. :thumb:

I'm just so impressed... :D

ooo, thanks man :D

kyler
10th December 2009, 06:12
Any news when the release is coming of the new update?

broken
10th December 2009, 07:30
Any news when the release is coming of the new update?
It's not that hard to reach the conclusion that when it is released, T-RonX (http://www.lfsforum.net/member.php?u=8887) will probably post a reply about it and bump the thread.

Also, logically, the first post will also be updated. So just watch the thread. :shrug:

kyler
11th December 2009, 04:16
I know. i was just asking if he knew kinda like when. a eta.

Whiskey
12th December 2009, 19:05
EDIT: I sorted this out. See next post

Hi.
First of all, I must say my knowledge of VB is very poor.

I want to make something similar to LFS Rev Limiter (just for learn). The problem is I want LFS to press "i". So I looked in google a found this:
My.Computer.Keyboard.SendKeys("i")But this command does not work well, because LFS don't do anything (apart for changing the shifmode if I write a "G")


So I thought using the packet SCH, but I don't know how to send it to the game.

Anyone could help me?

Whiskey
12th December 2009, 20:33
Ok, I found how to do it, but it only work with fixed keys (V, H, 3...), the same as /press

How can I press a configurable key?

[P]oli
13th December 2009, 02:53
Private Declare Sub keybd_event Lib "user32.dll" _
(ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Const KEYEVENTF_KEYUP = &H2
Const VK_I = &H49


that sets the constant key for VK_I... ( %H49 = the key i)


keybd_event(VK_I, 0, KEYEVENTF_KEYUP, 0)
System.Threading.Thread.Sleep(100)
keybd_event(VK_I, 0, 0, 0)
System.Threading.Thread.Sleep(100)

1st line = key up the key "i" (if it's pressed, it's released)
2nd line = a delay between 1st and 3rd line
3rd line = pressing the key "i"
4th line = another delay

:) i've just made my outgauge rev limiter some days ago :D

http://www.youtube.com/watch?v=vPLYHc4ZkGU
that's it's video :D

i'm waiting for the Outgauge update, for z28 :D hehehe


Greets from Argentina and sorry for my bad english!

Bass-Driver
13th December 2009, 06:41
hmm
demoer drives @ South City with an Modified UF1

Theres something wrong here

Heiko1
13th December 2009, 06:45
cool application
but why you can use Barriers on other vids?:shrug:
and UF1000?
and South City?

Marco1
13th December 2009, 07:08
i beat with you, he will say he posted with Demo Account coz he forgott his S2 webpasswort or he was to lazy xD

nice app is this app ingame? as InSim Menue or as a picture edit ?

Whiskey
13th December 2009, 09:55
Gracias Poli!!!! :)

Thanks

EDIT: since my last modification in the program it didn't lost the syncronization. 0% errors by now, thanks again

[P]oli
18th December 2009, 15:39
Another account, a friend's one.

The app is totally apart from the game, it only reads the data and shows what it reads. What's more, when the rpm are over the rpm set at the program, it gives an "i" key stroke (the code i've put before)

-----------------------

De nada, Whiskey! (You're welcome!)
I'm glad it works :D any doubt, ask, we could find a solution :D

PoVo
25th December 2009, 13:34
oli;1332814']Another account, a friend's one.

The app is totally apart from the game, it only reads the data and shows what it reads. What's more, when the rpm are over the rpm set at the program, it gives an "i" key stroke (the code i've put before)

-----------------------

De nada, Whiskey! (You're welcome!)
I'm glad it works :D any doubt, ask, we could find a solution :D
Whats your "friends" licence?

broken
25th December 2009, 15:51
Ok, can we please not turn into another demo user-flame thread? At least take in mind that this thread doesn't deserve it.

[P]oli
28th December 2009, 19:20
Whats your "friends" licence?

I Don't know, it's his problem. Isn't it? :shrug:

----

I only tried to help a mate, so, try to be better ppl and HELP! ;)

avedawg213
4th January 2010, 03:26
How do you edit the .cs files and then them actually work cause you cant compile them... Well at least if you can I dont know how to... so confusing... I tried to edit them but the changes have no effect what do i use to make the changes actually show up?

EDIT: I have all the needed applications... I open the files they just dont compile or whatever they need to do to actually change.

broken
4th January 2010, 12:50
.csproj

Tsuka
9th January 2010, 08:42
I found the bug.
It return wrong pit work. :(

LFS_External.InSim.Flags.PitWorkFlags
PSE_RI_RE_DAM = 4094,

maybe fixed :
PSE_RI_RE_DAM = 4096,

sorry, my bad english :x

DavidTiger
3rd March 2010, 20:36
I'm working on version 1.3 which is based on version 1.2 (which i never released because of a bug i couldn't fix) and rewrote the core of it.

Obviously it will be Z25 compatible and will have some very nice features like requesting a packet directly instead of calling an event. All flags will be pre-parsed, and finally it will have UTF-8 support.

Excuse the bump but I was wondering if you managed to update for z25, z28 etc ??
Im using this in VS2008 and doesnt have the updated OutGuage bits...

Could you update and release the 1.3 version, or maybe release the source :shrug:

Cheers
-David

DavidTiger
5th March 2010, 20:56
Can you please update this? Would only take 2 minutes :D

Do I have to decompile and edit it myself?? Seems no-one cares about this anymore :shrug:

Shagrathx
16th March 2010, 10:38
Can you please update this? Would only take 2 minutes :D

Do I have to decompile and edit it myself?? Seems no-one cares about this anymore :shrug:

Would be nice to have an update indeed :(

OutSim only updates when I'm in certain "views" (cockpit view for instance, but no follow view). Is that an issue related to the lack of update too?

DarkTimes
19th March 2010, 21:04
OutSim only updates when I'm in certain "views" (cockpit view for instance, but no follow view). Is that an issue related to the lack of update too?
No that's a part of the OutSim protocol by design.

// OutSim - MOTION SIMULATOR SUPPORT
// ======

// The user's car in multiplayer or the viewed car in single player or
// single player replay can output information to a motion system while
// viewed from an internal view.

Shagrathx
30th March 2010, 22:09
No that's a part of the OutSim protocol by design.

Oh I see, thanks for the explaining :)

Got a new question tho; does anyone have a VB.NET kit that works with VS.Net 2008?
As the latest version available (OP) needs conversion when I open it, resulting in a billion errors, as usual.

Please pretty please? anyone?

DarkTimes
30th March 2010, 22:34
I find that the Visual Studio conversion process works pretty well actually. What errors are you getting when you try to convert it? In my experience once you've converted a project, you then need to build it before the errors and warnings will go away. Many of the errors you see are just a result of Visual Studio looking for .NET references and assemblies which haven't been built yet.

Shagrathx
30th March 2010, 22:54
I find that the Visual Studio conversion process works pretty well actually. What errors are you getting when you try to convert it? In my experience once you've converted a project, you then need to build it before the errors and warnings will go away. Many of the errors you see are just a result of Visual Studio looking for .NET references and assemblies which haven't been built yet.

Here's a screenie of what I get. Seems like it fails to find all references.. ?
I thought this would be a good practice for my rusty VB.NET skills, but you wouldn't believe the hours I've spent on this forum trying to find ANY insim/outsim tutorials, SDK Libs, examples... that is at least a bit up to date, or even just works at all :(

I don't have the time to work out everything from scratch... and there are plenty of out-dated tools, examples, tutorials etc. etc. so there must be something that still works? Right? Am I really missing something obvious? (wouldn't be the first time ^^)
If there's any useful VB.NET stuff for InSim (or C#, PHP, hell even C++ if I have to), I beg you to put an end to my suffering.

DarkTimes
30th March 2010, 23:11
OK - the first error listed there says:

- Could not locate the assembly 'LFS_External'. Check to make sure this assembly exists on disk

So... the problem is that the compiler is being told to use the LFS_External library, but it doesn't know where to find it. A reference to that library has not been added to the project yet. All of the other errors on that screenshot are just a result of it not being able to find that one library. It actually warns you those errors might happen! :)

- You may get compilation errors

Now, I don't know VB.NET at all, but you should be able to right-click on the project in the solution explorer and select 'add reference'. On the references dialog, select the 'browse' tab and then find the LFS_External.dll which should have been included in the zip file you downloaded from this thread.

I believe that once the reference to the library has been added, you should be able to build the project without any problems.

Shagrathx
30th March 2010, 23:38
OK - the first error listed there says:

- Could not locate the assembly 'LFS_External'. Check to make sure this assembly exists on diskSo... the problem is that the compiler is being told to use the LFS_External library, but it doesn't know where to find it. A reference to that library has not been added to the project yet. All of the other errors on that screenshot are just a result of it not being able to find that one library. It actually warns you those errors might happen! :)

- You may get compilation errorsNow, I don't know VB.NET at all, but you should be able to right-click on the project in the solution explorer and select 'add reference'. On the references dialog, select the 'browse' tab and then find the LFS_External.dll which should have been included in the zip file you downloaded from this thread.

I believe that once the reference to the library has been added, you should be able to build the project without any problems.

It was a bit more complicated than that, but I got it working just now.
I'm now testing it on my server and I succesfully made a form with a button that can be clicked.
Mentioned button then throws a simple messagebox with a snapshot of some basic info about Players.ToArray(0) like used car etc etc.

Would there be any documentation/tutorials available for this VB.NET SDK lib?
As it is totally awesome, even after just 2 minutes experience with it, but it's a challenge to find out everything on my own.
Right now I'm trying to create a button or something in LFS (through the external app... or... well...)

My goal is to make an InSim app for my server, a bit like the cruise systems that we all know (no physical access to the machine tho).
Is this possible with this?

Yes, I'm a total n00b :thumb:

DarkTimes
31st March 2010, 00:24
It was a bit more complicated than that, but I got it working just now.
You might want to enumerate on how you got it working, as it's likely other people will have the same problem in the future.

pezia
4th April 2010, 17:15
Hi!

This lib is very useful. Thank you for your work.
Here is a feature request:
it would be nice if the PType would be a FlagsAttribute field in the IS_NPL packet struct.

Cheers, pezia.

Jsm
5th April 2010, 22:09
I was just wondering, does this still work (I assume it does)? Mainly the OutGauge stuff, as I don't seem to get any sort of OutGauge packet at all and I'm not sure if I am just setting it up wrong or if it doesn't work. I tried both setting it in the cfg file and connecting via InSim and attempting to start OutGauge (It said "OutGauge Enabled" in game, but still nothing was received)

Thanks in advanced.

Edit: Nevermind it seems to work, I changed the ID from 0 to 1 and it suddenly started to work. Did I fail to read some instructions somewhere?

DavidTiger
6th April 2010, 19:14
Is this updated for the updated OutGuage struct?
I have a great idea for a program im working on but Im halted by not having the correct structs through LFS_External :(

If not please update it :)

PoVo
9th April 2010, 20:26
I was looking at the documentation in OutGauge but couldn't find in what Speed is displayed. Its certainly not MPh or KMh :x

Thanks.

yankman
9th April 2010, 21:02
InSim.txt says M/S (meter per second).

PoVo
10th April 2010, 07:08
InSim.txt says M/S (meter per second).

Thank you! Didn't think of reading the Insim.txt :thumbsup:

DarkTimes
10th April 2010, 16:19
Is this updated for the updated OutGuage struct?
I have a great idea for a program im working on but Im halted by not having the correct structs through LFS_External :(

If not please update it :)

It's fairly easy to roll your own OutGauge code. All you need to do is create a UDP socket, bind it to the correct port, and then unpack each packet that is received. UDP is a very simple protocol to work with, and not much code is required.

DavidTiger
10th April 2010, 18:58
I had tried before but always came back to this error:

"only one usage of each socket address protocol network address port is normally permitted"

Meaning that it cant use the port becuase its used (by LFS)

DarkTimes
10th April 2010, 21:00
I'm not sure what the error is, but that message suggests you are either trying to use a port which is already in use or one that hasn't been correctly shutdown. With UDP it shouldn't matter that LFS is using that port, in fact that's the whole idea! LFS is broadcasting packets on that UDP port, which you're trying to listen out for. Check that you app is the only program listening on that port and you are not trying to reuse a port used by LFS_External or anything else. Also make sure you are using the same port number you have specified in CFG.txt or in the ISI packet.

jto93
13th May 2010, 18:11
Hello, can someone see whats wrong with this bit of code?
Im trying to make a drift insim, all thats left is to finish the point system.
The problem is that its calculating wrong, it does not stop to count points when it should.

Fart=Speed
Vinkel=Angel

if(Fart>30&&Vinkel>10)
{ Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].NewScore = Convert.ToInt32(0 + (Vinkel * Fart) / 50);
}
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].TotalScore =0 + (Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].TotalScore + Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].NewScore);
if(Fart<30&&Vinkel<10)
{
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].TotalScore = 0;
}
I think the problem is in the TotalScore, but i cant find out what it is..
hope some of you could help me on this :)

Edit: i found out what it was, it was the NewScore that did not return to 0, it was stuck at the last value.

DarkKostas
17th May 2010, 15:24
Can someone give an example of Outgauge in C++? Something similar to the C# example but in C++.

DarkTimes
17th May 2010, 19:25
Heya - I posted a short C++ OutGauge example a while back.

http://www.lfsforum.net/showthread.php?p=1352574#post1352574

DarkKostas
18th May 2010, 08:33
Heya - I posted a short C++ OutGauge example a while back.

http://www.lfsforum.net/showthread.php?p=1352574#post1352574
Thanks it works great :)
But it wasnt working while i was Adding to link ws2_32.lib

So i added this to your code
#pragma comment(lib, "ws2_32.lib")

sll88
24th July 2010, 00:29
Hello,
External LFS I'm trying, but all data are updated very slowly, such as RPM does not go through all the numbers pasted on 1000 1000 jumps around, what can be done to that data is updated more frequently and has no such as sudden changes?

A greeting and thank you very much for your work T-RonX.

DavidTiger
24th July 2010, 02:29
Whats you OutGauge CFG Settings??

I use (see below) and with the dash im making (I might release it, who knows :shrug:) its very smooth and instant updating with no lag ;)

OutGauge Mode 2
OutGauge Delay 1
OutGauge IP 127.0.0.1
OutGauge Port 35555
OutGauge ID 1

VeGe-
24th July 2010, 18:16
No one has anything new about VB libraries? Got very nice example of handling OutGauge with C++ from DarkTimes but C++ serial communications is waaay beyond my skills. On the other hand I have perfectly working VB software but it doesn't support new flags becose of T-RonX's library is out of date. And make things even more frustrating I'm able to use serial communication in C# but it lacks of any understandable OutGauge example...

DavidTiger
24th July 2010, 18:35
I tried de-compiling the dll but it doesn't work correctly :shrug:

We really need it updated *hint* *hint*

kyler
25th July 2010, 01:29
Does anyone have a tutorial on how to update this or does someone have a tutorial on how to make a UDP socket and receive the packets? Thanks.

VeGe-
25th July 2010, 08:58
Does anyone have a tutorial on how to update this or does someone have a tutorial on how to make a UDP socket and receive the packets? Thanks.I'm also interested in getting the UDP socket to work in VB. Spent hours and hours yesterday trying to get over this problem somehow, but without any final breakthrough. Any VB experts around here to give us a clue how to start? I'm not completely newbie in VB, but UDP without any sign where to start is too much for my skills.

DarkTimes
25th July 2010, 10:16
I don't have a VB version, but here is a simple C# example of how to receive OutGauge packets.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;

namespace OutGauge
{
class Program
{
const int BufferSize = 1024;
const string Host = "127.0.0.1";
const ushort Port = 30000;

static void Main()
{
// Create UDP socket.
Socket socket = new Socket(
AddressFamily.InterNetwork,
SocketType.Dgram,
ProtocolType.Udp);
byte[] buffer = new byte[BufferSize];

try
{
// Create EndPoint for LFS and bind the socket to it.
IPEndPoint endPoint = new IPEndPoint(
IPAddress.Parse(Host),
Port);
socket.Bind(endPoint);

while (true)
{
// Receive packet data.
int received = socket.Receive(buffer);
if (received > 0)
{
// Copy data from buffer into correctly sized array.
byte[] data = new byte[received];
Buffer.BlockCopy(buffer, 0, data, 0, received);

// Packet received...
OutGaugePack packet = new OutGaugePack(data);
OutGaugePacketReceived(packet);
}
else
{
Console.WriteLine("Lost connection to OutGauge");
break;
}
}
}
catch (SocketException ex)
{
Console.WriteLine("Socket Error: {0}", ex.Message);
}
}

static void OutGaugePacketReceived(OutGaugePack packet)
{
// Do stuff with packet etc..

Console.WriteLine(packet.RPM);

if (packet.DashLights.HasFlag(DashLightFlags.DL_SHIFT ))
{
Console.WriteLine("Shift-light on!");
}
}

class OutGaugePack
{
public TimeSpan Time { get; private set; }
public string Car { get; private set; }
public OutGaugeFlags Flags { get; private set; }
public int Gear { get; private set; }
public int SpareB { get; private set; }
public float Speed { get; private set; }
public float RPM { get; private set; }
public float Turbo { get; private set; }
public float EngTemp { get; private set; }
public float Fuel { get; private set; }
public float OilPressure { get; private set; }
public float OilTemp { get; private set; }
public DashLightFlags DashLights { get; private set; }
public DashLightFlags ShowLights { get; private set; }
public float Throttle { get; private set; }
public float Brake { get; private set; }
public float Clutch { get; private set; }
public string Display1 { get; private set; }
public string Display2 { get; private set; }
public int ID { get; private set; }

public OutGaugePack(byte[] data)
{
Time = TimeSpan.FromMilliseconds(BitConverter.ToUInt32(da ta, 0));
Car = ASCIIEncoding.ASCII.GetString(data, 4, 4).TrimEnd(char.MinValue);
Flags = (OutGaugeFlags)BitConverter.ToUInt16(data, 8);
Gear = data[10];
SpareB = data[11];
Speed = BitConverter.ToSingle(data, 12);
RPM = BitConverter.ToSingle(data, 16);
Turbo = BitConverter.ToSingle(data, 20);
EngTemp = BitConverter.ToSingle(data, 24);
Fuel = BitConverter.ToSingle(data, 28);
OilPressure = BitConverter.ToSingle(data, 32);
OilTemp = BitConverter.ToSingle(data, 36);
DashLights = (DashLightFlags)BitConverter.ToUInt32(data, 40);
ShowLights = (DashLightFlags)BitConverter.ToUInt32(data, 44);
Throttle = BitConverter.ToSingle(data, 48);
Brake = BitConverter.ToSingle(data, 52);
Clutch = BitConverter.ToSingle(data, 56);
Display1 = ASCIIEncoding.ASCII.GetString(data, 60, 16).TrimEnd(char.MinValue);
Display2 = ASCIIEncoding.ASCII.GetString(data, 76, 16).TrimEnd(char.MinValue);

if (data.Length == 96)
{
ID = BitConverter.ToInt32(data, 92);
}
}
}

[Flags]
enum OutGaugeFlags
{
OG_TURBO = 8192,
OG_KM = 16384,
OG_BAR = 32768,
}

[Flags]
enum DashLightFlags
{
DL_SHIFT = 1,
DL_FULLBEAM = 2,
DL_HANDBRAKE = 4,
DL_PITSPEED = 8,
DL_TC = 16,
DL_SIGNAL_L = 32,
DL_SIGNAL_R = 64,
DL_SIGNAL_ANY = 128,
DL_OILWARN = 256,
DL_BATTERY = 512,
DL_ABS = 1024,
DL_SPARE = 2048,
}
}
}

VeGe-
25th July 2010, 11:45
Damn! I took that DarkTimes C# OutGauge example and combined it with this (http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.aspx) and I have excatly what I need!

Now my (or DarkTimes's and Microsoft's) C# program sends data to my microcontroller. It's WIP thingy but I have now RPM, Speed and emulated gear "N" (Edit: wrote it really, so it works now, see the code) on external LCD. I did all this with VB too, but outdated lib didn't understand new flags so this is as far as I got. Next I'll hook few LEDs to my uC and see how ABS, TC and stuff like that gives me signals. :)

My analog tacho is working somehow too, but it's old and slow. I'm more interested in this LCD and LEDs right now. I'll post some pics and videos when I'm far enough with this. Thank you DarkTimes, once again!!


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;
using System.IO.Ports;
using System.Threading;

namespace OutGauge
{
class Program
{
const int BufferSize = 1024;
const string Host = "127.0.0.1";
const ushort Port = 35555;

static SerialPort _serialPort;

static void Main()
{
StringComparer stringComparer = StringComparer.OrdinalIgnoreCase;

// Create a new SerialPort object with default settings.
_serialPort = new SerialPort();

// Allow the user to set the appropriate properties.
_serialPort.PortName = "COM3";
_serialPort.BaudRate = 57600;
_serialPort.DataBits = 8;
_serialPort.Parity = (Parity)Enum.Parse(typeof(Parity), "None");
_serialPort.StopBits = (StopBits)Enum.Parse(typeof(StopBits), "Two");

// Set the read/write timeouts
_serialPort.ReadTimeout = 500;
_serialPort.WriteTimeout = 500;

_serialPort.Open();

// Create UDP socket.
Socket socket = new Socket(
AddressFamily.InterNetwork,
SocketType.Dgram,
ProtocolType.Udp);
byte[] buffer = new byte[BufferSize];

try
{
// Create EndPoint for LFS and bind the socket to it.
IPEndPoint endPoint = new IPEndPoint(
IPAddress.Parse(Host),
Port);
socket.Bind(endPoint);

while (true)
{
// Receive packet data.
int received = socket.Receive(buffer);
if (received > 0)
{
// Copy data from buffer into correctly sized array.
byte[] data = new byte[received];
Buffer.BlockCopy(buffer, 0, data, 0, received);

// Packet received...
OutGaugePack packet = new OutGaugePack(data);
OutGaugePacketReceived(packet);
}
else
{
Console.WriteLine("Lost connection to OutGauge");
break;
}
}
}
catch (SocketException ex)
{
Console.WriteLine("Socket Error: {0}", ex.Message);
}
}

static void OutGaugePacketReceived(OutGaugePack packet)
{
// Do stuff with packet etc..

_serialPort.Write("S"); // Start-byte for uC

if ((int)packet.RPM < 10){
_serialPort.Write("000");
} else if ((int)packet.RPM < 100){
_serialPort.Write("00");
} else if ((int)packet.RPM < 1000){
_serialPort.Write("0");
}

_serialPort.Write(((int)packet.RPM).ToString());

Int32 speed_kph = (int)(packet.Speed *3.6);

if (speed_kph < 10)
{
_serialPort.Write("00");
}
else if (speed_kph < 100)
{
_serialPort.Write("0");
}

_serialPort.Write(speed_kph.ToString());

if (packet.Gear == 0){
_serialPort.Write("R");
} else if (packet.Gear == 1){
_serialPort.Write("N");
} else if (packet.Gear > 1){
_serialPort.Write((packet.Gear - 1).ToString());
}
}

class OutGaugePack
{
public TimeSpan Time { get; private set; }
public string Car { get; private set; }
public OutGaugeFlags Flags { get; private set; }
public int Gear { get; private set; }
public int SpareB { get; private set; }
public float Speed { get; private set; }
public float RPM { get; private set; }
public float Turbo { get; private set; }
public float EngTemp { get; private set; }
public float Fuel { get; private set; }
public float OilPressure { get; private set; }
public float OilTemp { get; private set; }
public DashLightFlags DashLights { get; private set; }
public DashLightFlags ShowLights { get; private set; }
public float Throttle { get; private set; }
public float Brake { get; private set; }
public float Clutch { get; private set; }
public string Display1 { get; private set; }
public string Display2 { get; private set; }
public int ID { get; private set; }

public OutGaugePack(byte[] data)
{
Time = TimeSpan.FromMilliseconds(BitConverter.ToUInt32(da ta, 0));
Car = ASCIIEncoding.ASCII.GetString(data, 4, 4).TrimEnd(char.MinValue);
Flags = (OutGaugeFlags)BitConverter.ToUInt16(data, 8);
Gear = data[10];
SpareB = data[11];
Speed = BitConverter.ToSingle(data, 12);
RPM = BitConverter.ToSingle(data, 16);
Turbo = BitConverter.ToSingle(data, 20);
EngTemp = BitConverter.ToSingle(data, 24);
Fuel = BitConverter.ToSingle(data, 28);
OilPressure = BitConverter.ToSingle(data, 32);
OilTemp = BitConverter.ToSingle(data, 36);
DashLights = (DashLightFlags)BitConverter.ToUInt32(data, 40);
ShowLights = (DashLightFlags)BitConverter.ToUInt32(data, 44);
Throttle = BitConverter.ToSingle(data, 48);
Brake = BitConverter.ToSingle(data, 52);
Clutch = BitConverter.ToSingle(data, 56);
Display1 = ASCIIEncoding.ASCII.GetString(data, 60, 16).TrimEnd(char.MinValue);
Display2 = ASCIIEncoding.ASCII.GetString(data, 76, 16).TrimEnd(char.MinValue);

if (data.Length == 96)
{
ID = BitConverter.ToInt32(data, 92);
}
}
}

[Flags]
enum OutGaugeFlags
{
OG_TURBO = 8192,
OG_KM = 16384,
OG_BAR = 32768,
}

[Flags]
enum DashLightFlags
{
DL_SHIFT = 1,
DL_FULLBEAM = 2,
DL_HANDBRAKE = 4,
DL_PITSPEED = 8,
DL_TC = 16,
DL_SIGNAL_L = 32,
DL_SIGNAL_R = 64,
DL_SIGNAL_ANY = 128,
DL_OILWARN = 256,
DL_BATTERY = 512,
DL_ABS = 1024,
DL_SPARE = 2048,
}
}
}

VeGe-
25th July 2010, 12:44
It seems that DarkTimes's code tells that "Shift light is ON!" all the time, even it isn't. Is there some small problem?

My OutGauge settings:

OutGauge Mode 2
OutGauge Delay 4
OutGauge IP 127.0.0.1
OutGauge Port 30000
OutGauge ID 2


Edit: Ah, yeah, it should be "if (packet.ShowLights.HasFlag(DashLightFlags.DL_ABS))", not DashLights.

kyler
26th July 2010, 06:54
I don't have a VB version, but here is a simple C# example of how to receive OutGauge packets.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;

namespace OutGauge
{
class Program
{
const int BufferSize = 1024;
const string Host = "127.0.0.1";
const ushort Port = 30000;

static void Main()
{
// Create UDP socket.
Socket socket = new Socket(
AddressFamily.InterNetwork,
SocketType.Dgram,
ProtocolType.Udp);
byte[] buffer = new byte[BufferSize];

try
{
// Create EndPoint for LFS and bind the socket to it.
IPEndPoint endPoint = new IPEndPoint(
IPAddress.Parse(Host),
Port);
socket.Bind(endPoint);

while (true)
{
// Receive packet data.
int received = socket.Receive(buffer);
if (received > 0)
{
// Copy data from buffer into correctly sized array.
byte[] data = new byte[received];
Buffer.BlockCopy(buffer, 0, data, 0, received);

// Packet received...
OutGaugePack packet = new OutGaugePack(data);
OutGaugePacketReceived(packet);
}
else
{
Console.WriteLine("Lost connection to OutGauge");
break;
}
}
}
catch (SocketException ex)
{
Console.WriteLine("Socket Error: {0}", ex.Message);
}
}

static void OutGaugePacketReceived(OutGaugePack packet)
{
// Do stuff with packet etc..

Console.WriteLine(packet.RPM);

if (packet.DashLights.HasFlag(DashLightFlags.DL_SHIFT ))
{
Console.WriteLine("Shift-light on!");
}
}

class OutGaugePack
{
public TimeSpan Time { get; private set; }
public string Car { get; private set; }
public OutGaugeFlags Flags { get; private set; }
public int Gear { get; private set; }
public int SpareB { get; private set; }
public float Speed { get; private set; }
public float RPM { get; private set; }
public float Turbo { get; private set; }
public float EngTemp { get; private set; }
public float Fuel { get; private set; }
public float OilPressure { get; private set; }
public float OilTemp { get; private set; }
public DashLightFlags DashLights { get; private set; }
public DashLightFlags ShowLights { get; private set; }
public float Throttle { get; private set; }
public float Brake { get; private set; }
public float Clutch { get; private set; }
public string Display1 { get; private set; }
public string Display2 { get; private set; }
public int ID { get; private set; }

public OutGaugePack(byte[] data)
{
Time = TimeSpan.FromMilliseconds(BitConverter.ToUInt32(da ta, 0));
Car = ASCIIEncoding.ASCII.GetString(data, 4, 4).TrimEnd(char.MinValue);
Flags = (OutGaugeFlags)BitConverter.ToUInt16(data, 8);
Gear = data[10];
SpareB = data[11];
Speed = BitConverter.ToSingle(data, 12);
RPM = BitConverter.ToSingle(data, 16);
Turbo = BitConverter.ToSingle(data, 20);
EngTemp = BitConverter.ToSingle(data, 24);
Fuel = BitConverter.ToSingle(data, 28);
OilPressure = BitConverter.ToSingle(data, 32);
OilTemp = BitConverter.ToSingle(data, 36);
DashLights = (DashLightFlags)BitConverter.ToUInt32(data, 40);
ShowLights = (DashLightFlags)BitConverter.ToUInt32(data, 44);
Throttle = BitConverter.ToSingle(data, 48);
Brake = BitConverter.ToSingle(data, 52);
Clutch = BitConverter.ToSingle(data, 56);
Display1 = ASCIIEncoding.ASCII.GetString(data, 60, 16).TrimEnd(char.MinValue);
Display2 = ASCIIEncoding.ASCII.GetString(data, 76, 16).TrimEnd(char.MinValue);

if (data.Length == 96)
{
ID = BitConverter.ToInt32(data, 92);
}
}
}

[Flags]
enum OutGaugeFlags
{
OG_TURBO = 8192,
OG_KM = 16384,
OG_BAR = 32768,
}

[Flags]
enum DashLightFlags
{
DL_SHIFT = 1,
DL_FULLBEAM = 2,
DL_HANDBRAKE = 4,
DL_PITSPEED = 8,
DL_TC = 16,
DL_SIGNAL_L = 32,
DL_SIGNAL_R = 64,
DL_SIGNAL_ANY = 128,
DL_OILWARN = 256,
DL_BATTERY = 512,
DL_ABS = 1024,
DL_SPARE = 2048,
}
}
}

Is there a way to convert this from a Console to Windows App?

I'm new to programing sorry for all the questions. I'm slowly learning =)

Thanks, Kyler

DavidTiger
26th July 2010, 20:15
Hey guys :thumb:

I converted DarkTimes' C# code into VB.NET 2008 :D:D
Its still a console app, but I'm sure those of you who want VB.NET code can make a console app :nod:

Cheers
-Dave

EDIT: Added rar with VB.NET 2008 Source

kyler
26th July 2010, 22:53
Got a tutorial on how to convert this from console to an app. ?

Thanks, Kyler

DavidTiger
27th July 2010, 01:22
I don't but as you see from my previous posts in this thread, I really want an z28 VB.NET version of outgauge...

I'm not too good with the whole UDP connections etc and I only know VB, C#
But preferably use VB.NET

I'm working on making a form/GUI version of this, but as im quite busy it may be a few days.. So if someone can do that before then, Kudos to you :thumb:

roki60
29th July 2010, 07:21
I would like to try some older LFS External versions like 1.1.1.2 or 1.1.1.3. Where i can find them?

Ant0niS
31st August 2010, 14:29
Hey guys :thumb:

I converted DarkTimes' C# code into VB.NET 2008 :D:D
Its still a console app, but I'm sure those of you who want VB.NET code can make a console app :nod:

Cheers
-Dave

EDIT: Added rar with VB.NET 2008 Source


Thank you very much Darktimes for the code and you DavidTiger for converting it to vb.net :)

Bose321
4th December 2010, 11:37
Hi all,

The insim running in my drift server is using LFS External, and it's going quite well so far, but I was wondering, the people using mouse can't seem to hide their cursor. There are no clickable buttons on the screen, just normal buttons, and still the mouse appears... Is this something not possible in LFS External, or some kind of option, or did I do something wrong?

Thanks in advance,

Bose

broken
4th December 2010, 12:12
Hi all,

The insim running in my drift server is using LFS External, and it's going quite well so far, but I was wondering, the people using mouse can't seem to hide their cursor. There are no clickable buttons on the screen, just normal buttons, and still the mouse appears... Is this something not possible in LFS External, or some kind of option, or did I do something wrong?

Thanks in advance,

Bose

Have they tried to press Shift+Z?
When the connections list is open (pressing N) it happens too.

Bose321
4th December 2010, 13:23
Have they tried to press Shift+Z?
When the connections list is open (pressing N) it happens too.
I'm trying it out myself. Connections list is not on the screen, and the mouse is hidden with Shift+Z. Still a cursor on screen.

skywatcher122
4th December 2010, 14:00
I'm trying it out myself. Connections list is not on the screen, and the mouse is hidden with Shift+Z. Still a cursor on screen.

even the insim is off the mouse still shows?

broken
4th December 2010, 14:39
I'm trying it out myself. Connections list is not on the screen, and the mouse is hidden with Shift+Z. Still a cursor on screen.

These are the 3 factors I know:
Shift+Z
Connections list
Clickable button

If it is not the first two, have a really good look at your application, and make sure none of the buttons it sends are clickable.

Sysadmin
26th January 2011, 01:20
Here is a simple C# example of how to receive OutGauge packets.


Can someone please convert this code to a C# WinForms project?

I have tried for hours on end but for the life of me I can't get it to work.

I've modified the LFS_External example project to show some of the data I want, but it's to outdated to show things such as lights or the current car.
Because of this it's impossible to scale the tachometer for example.

I have enough "experience" with C# to kludge something together, but this is way beyond my abilities.

Whiskey
26th January 2011, 09:41
Well, you can use og_relay (http://www.lfsforum.net/showthread.php?p=1329031#post1329031) to solve the problem with dashboard lights

OR

use Spark, or wait a few weeks until the release of InSim.NET (the succesor of Spark)

vforce
15th February 2011, 13:47
regarding variable spare1 in the: - LFS External 1.1 with OutSim and OutGauge example for VB.NET
How can you convert the single floating point to separate bits?
Because I want to see the dashboard lights

is it possible to have the full code and not the dll??

kind regards

MadCatX
15th February 2011, 14:05
(double post)

MadCatX
15th February 2011, 14:06
You don't have to be concerned about any "spare" variables 'cause they serve no purpose now. They're there just in case they'll be needed in the future.

Regarding the OutGauge dashLights, I believe you meant integer, not a float. There are multiple ways how to check if a certain bit is set, but I guess the simplest one is using a set of constants like this:

const int DL_SHIFT = 1
const int DL_FULLBEAM = 2
const int DL_HANDBRAKE = 4
... and so on


and using logical AND to check if a certain bit is set like this:

if (OutGaugePacket.DashLights & DL_SHIFT)
{
(do something when shift light is on)
}


I'm not great with C#, but I guess this approach should work in almost any language.

vforce
17th February 2011, 14:24
But there is no OutGaugePacket.DashLights in the c# file ( I started working whit c# instead of vb) I have everything working except for the dashboard lights.
There is no og.Dashlights ore something of that kind. I noticed that the spare3 changes value if you put on a dashboard light.Sow that is why I thought a need to work whit this variable fore the lights

MadCatX
17th February 2011, 15:46
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.

vforce
18th February 2011, 10:16
I know, however there is now function" Dashlights". In the LFS External 1.1 with OutSim and OutGauge example for C#

dougie-lampkin
18th March 2011, 13:28
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.

DarkTimes
18th March 2011, 15:49
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.

dougie-lampkin
18th March 2011, 16:29
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.

DarkTimes
18th March 2011, 17:14
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;

dougie-lampkin
18th March 2011, 17:59
Not really, except for disassembling library and recompiling it with a couple of changes.

Never occurred to me :shy:

Thanks DarkTimes, works a treat now.

gazastrike
7th May 2011, 15:20
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

gazastrike
7th May 2011, 15:42
what one do i need to download mate im pretty new to this

broken
7th May 2011, 18:38
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 (http://www.lfsforum.net/showthread.php?t=68564), 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).

DarkTimes
8th May 2011, 15:52
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 my flagship library InSim.NET (http://insimdotnet.codeplex.com/).

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.

skywatcher122
8th May 2011, 16:17
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 :thumb:

DarkTimes
8th May 2011, 16:23
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);
}
}

DarkTimes
8th May 2011, 17:42
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 (http://www.lfsforum.net/showthread.php?p=1589388#post1589388).

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
8th May 2011, 18:22
Tested it and so far seems to be working excellent, thanks Darktimes! :thumbsup:

skywatcher122
9th May 2011, 06:12
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

broken
9th May 2011, 07:55
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".

skywatcher122
9th May 2011, 08:23
oh I apologize if i say that way anyways, im not using this library either.

Ant0niS
10th May 2011, 20:02
First of all, thanks DarkTimes for your time to update the library :thumb:

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

DarkTimes
11th May 2011, 09:40
First of all, thanks DarkTimes for your time to update the library :thumb:

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

Ant0niS
11th May 2011, 12:30
Thank you DarkTimes :thumb:
Now works fine :)


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.:)


http://www.box.net/shared/ykmkeljvu6

skywatcher122
12th May 2011, 13:27
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
public static byte[] ISP_BTN(string ButtonText, LFS_External.InSim.Flags.ButtonStyles Style, byte Height, byte Width, byte Top, byte Left, byte ClickID, byte UniqueID, byte RequestID, bool 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.H = Height;
sourceStruct.W = Width;
sourceStruct.T = Top;
sourceStruct.L = Left;
return Util.PacketToData(sourceStruct);
}

public static byte[] ISP_BTN(string ButtonText, string DialogCaption, LFS_External.InSim.Flags.ButtonStyles Style, byte Height, byte Width, byte Top, byte Left, byte TypeIn, byte ClickID, byte UniqueID, byte RequestID, bool AlwaysVisible)
{
LFS_External.Packets.IS_BTN sourceStruct = new LFS_External.Packets.IS_BTN();
char ch = '\0';
string str = string.Concat(new object[] { ch, DialogCaption, ch, ButtonText });
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.H = Height;
sourceStruct.W = Width;
sourceStruct.T = Top;
sourceStruct.L = Left;
return Util.PacketToData(sourceStruct);
}

DavidTiger
15th May 2011, 21:02
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:

'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..)

PoVo
15th May 2011, 21:04
Set the InSim Flag with an IS_CON :)

DavidTiger
15th May 2011, 21:09
Ah :P Works now.. Cheers :thumb:

Amazing the amount of collisions the AI have when starting from in their pits, lol

DavidTiger
16th May 2011, 15:37
Sorry for double but wouldn't get attention if I just edited :D

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 :/

DarkKostas
19th May 2011, 08:50
Here is my code from MCI packet

Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].PlayerName


Example with username auto-clearing PIT Penalty @ PLA Packet

private void PLA_PitLaneChanged(Packets.IS_PLA PLA)
{
if (PLA.Fact == 0)
{
InSim.Send_MST_Message("/p_clear " + Connections[GetConnIdx(Players[GetPlyIdx(PLA.PLID)].UniqueID)].Username);
}
}

DarkTimes
21st May 2011, 13:24
I updated the LFS_External example program to better reflect how I believe .NET programs should be written.

I uploaded the project to the library post (http://www.lfsforum.net/showthread.php?p=1589388#post1589388). It requires VS2010 (express or better) to run it.

Beaver08
14th June 2011, 14:58
Hey , me and kamijou have been editing the

1.1.1.7 source

and have added the new packets from lfs

but constantly getting this error code from insim

[6/14/2011 3:49:54 PM] - AdminCmd - The output byte buffer is too small to contain the encoded data, encoding 'US-ASCII' fallback 'System.Text.EncoderReplacementFallback'.
Parameter name: bytes

it only does it if you type i think more than 6characters

any ideas?

skywatcher122
17th June 2011, 13:16
Hey , me and kamijou have been editing the

1.1.1.7 source

and have added the new packets from lfs

but constantly getting this error code from insim

[6/14/2011 3:49:54 PM] - AdminCmd - The output byte buffer is too small to contain the encoded data, encoding 'US-ASCII' fallback 'System.Text.EncoderReplacementFallback'.
Parameter name: bytes

it only does it if you type i think more than 6characters

any ideas?

the packet i added is IS_ACR

[StructLayout(LayoutKind.Sequential)]
public struct IS_ACR // Admin Command Report - any user typed an admin command
{
internal byte Size; // 72
internal byte Type; // ISP_ACR
public byte ReqI; // 0
internal byte Zero;

public byte UCID; // connection's unique id (0 = host)
public byte Admin; // set if user is an admin
public byte Result; // 1 - processed / 2 - rejected / 3 - unknown command
internal byte Sp3;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
public string Text;
}

is there any problems regarding about this?

E: I fixed the problem

broken
17th June 2011, 14:10
E: I fixed the problem

How?

You can't just request help and retreat as soon as your question has been resolved. And if you have replaced the problematic code with the new one - note it somewhere.

gazastrike
28th June 2011, 00:26
where do i set what cars i want

Beaver08
28th June 2011, 13:51
depends on wat you mean by set the cars..

you can set the servers cars by using the /car command within the setup.cfg

or you can program it within the NPL packet and file saving to check and add which vehicles they have.

i'm not at home so i cannot show you an example of what i mean but i hope it helps :)

Beaver08
5th July 2011, 17:34
first of all sorry for double post and completly off-topic

but there is a guy calls himself Captain Slow (Username: pro_drift_93)

he is going around claiming ownership of LFS_External and the copyright of the whole programme he tried threatning with courts and legal stuff aswell.

These are his claims.


Jul 05 17:55:25 Captain Slow : the fact of me making this insim makes me think i need to know
Jul 05 17:55:29 Captain Slow : could take it down
Jul 05 17:55:47 Captain Slow : and beav in court for copyright infringement
Jul 05 17:56:31 Captain Slow : okay il get on the phone to my solicitor
Jul 05 17:56:36 Captain Slow : find out the ip this is hosted on
Jul 05 17:57:35 Captain Slow : its okay
Jul 05 17:57:38 Captain Slow : kick or whatever
Jul 05 17:57:45 Captain Slow : emailing devs now
Jul 05 17:58:02 Captain Slow : to have the server removed
Jul 05 17:58:07 Captain Slow : for breach of copyrtight laws
Jul 05 17:58:21 Captain Slow : as i own half the coding on this insim
Jul 05 17:58:27 Captain Slow : all in copyright


i thought you guys should see that this person is believing that he created the LFS_External and how stupid he has made himself look.

DarkTimes
5th July 2011, 18:01
Well, as the guy who 'owns' this program, he clearly hasn't read the license it's released under.

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

Dygear
5th July 2011, 19:38
This is why I release all of my stuff under the MIT license.

gazastrike
12th August 2011, 01:06
looking for someone who no how to code insims im starting a team and ive got my own dedi box

LFSCruise
13th November 2011, 15:54
Do you know what coordinates Pit EXIT and Pit ENTRY AS1Y track?

AS5Y track
// Pit EXIT
if (((MCI.Info[i].X / 196608) <= -203) && ((MCI.Info[i].Y / 196608) >= -65) && ((MCI.Info[i].Y / 196608) <= -45) && (Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].IsInPitZone == 0))
{
if (((MCI.Info[i].Direction / 180) < 80) || ((MCI.Info[i].Direction / 180) > 280))
{
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].IsInPitZone = 1;

InSim.Send_MST_Message("/spec " + Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].Username);
}
}
if (((MCI.Info[i].Y / 196608) < -65) || ((MCI.Info[i].Y / 196608) > -45))
{
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].IsInPitZone = 0;
}

// Pit ENTRY
if (((MCI.Info[i].X / 196608) <= -203) && ((MCI.Info[i].Y / 196608) >= -158) && ((MCI.Info[i].Y / 196608) <= -145) && (Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].IsInPitZone2 == 0))
{
if (((MCI.Info[i].Direction / 180) < 80) || ((MCI.Info[i].Direction / 180) > 280))
{
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].IsInPitZone2 = 1;

InSim.Send_MST_Message("/spec " + Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].Username);
}
}
if (((MCI.Info[i].Y / 196608) < -158) || ((MCI.Info[i].Y / 196608) > -145))
{
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].IsInPitZone2 = 0;
}

How to make it work and AS1Y on track?

kdo
13th November 2011, 18:31
use the X-Y-Node of the incim by add that for the location:

case "yourtrack":
for (int i = 0; i < Players.Count; i++)
{
if (Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].Username == "yourusername")
{
InSim.Send_BTN_CreateButton("^1X: " + MCI.Info[i].X / 196608 + " ^2Y: " + MCI.Info[i].Y / 196608, Flags.ButtonStyles.ISB_DARK, 5, 15, 6, 90, 6, (Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID), 2, false);
InSim.Send_BTN_CreateButton("^3Node: " + MCI.Info[i].Node, Flags.ButtonStyles.ISB_DARK, 5, 15, 12, 90, 170, (Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID), 2, false); // Spare Button
}

this will say to you the location

LFSCruise
13th November 2011, 19:25
But I do not go exactly does that do good work. Can you help?

DarkKostas
14th November 2011, 08:22
AS1Y track?

Demo user. Hmm?

LFSCruise
14th November 2011, 13:52
Demo user. Hmm?

No. It does not have a large bearing on the answer.
Can anyone help? In addition to these issues.

Robert_RO
11th January 2012, 14:21
Can someone please help me with a link to LFS external 1.1.1.4 ? Can't find it and links from 1st post are dead.

KillerTier
5th February 2012, 18:13
OutSim and Outgauge Example
- LFS External 1.1 with OutSim and OutGauge example for VB.NET (http://www.lfsmods.net/lfs_external/lfs_external_outsim_outgauge_vbf11.zip)


Can anybody Re-Upload this. The Link is Dead :-(

Greetings :-)

EDIT: Ah Okay, I found it allready on Page 16 :-)

tigsimulator
24th March 2012, 07:27
Hi,
i looked for every insim packet but couldn't find a way to get wheel temps,damage info like we see with F9-F10.
How can we get this type of car info?

NotAnIllusion
24th March 2012, 07:34
Damage, no. Temperature, not "live". Closest would probably be "Air temperature" in "Dynamic Wheel Info" in a RAF. http://www.lfs.net/?page=RAF