The online racing simulator
Flags (bitwise comparision)
Quote from Reese :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/quest ... 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

Tim.
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.
edit: irrelevant.
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_
Quote from T-RonX :
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
whyt kinds of apps are oyu making "KlausAdam"?
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
Quote from Napalm Candy :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?
Quote from Marco1 :whyt kinds of apps are oyu making "KlausAdam"?

Some applications for the DoP like RaceTracker, HUD, SignIn-Tool, Qualify-Tool...
Parameter number 8 in the overloaded method, like in the picture.
Quote from madrofiel :
// 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?
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?
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.
No worries, there's no rush Just to make sure I wasn't failing again
Quote from T-RonX :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... .

Thx!!
Attached images
WinGI.PNG
#317 - gru
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
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.
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!
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.
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.
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.
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.
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.
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.

FGED GREDG RDFGDR GSFDG