The online racing simulator
Brand Newb C# / Visual C# 2008 Express help
Hullo.

I've been playing with Lapper (basically just ripping the code to bits and making it up as I'm going along when I'm not annoying Gai) and I've kinda gotten myself a hankering for making my own InSim app.

In fact, any kind of app

I am not even close top a programmer - but... I have downloaded the Open Source Cruise InSim app along with Microsoft Visual C# 2008 Express and want to hack about with it and asee what the crack is.

I'll be playing with it and learning as I go, using tutorials I find on the web and on here begging for help no doubt.

Here's where I ask you for your help

I need a push in the right direction - and the direction I need is the one in which I can edit the source files and recompile them into something I can run so that I can see my changes.

There are lots of files, and talk of Solutions and suchlike, and I'm a bit lost in it all.

I'd love to learn how to do this properly - but at the moment I want to play with it before I try to learn it the proper way - I intend to learn by editing and progress as I can.

So folks, who's feeling helpful?

Which files do I need to edit to change stuff - and once I edit them, how do I go about recompiling them?

Here's where I got to.

I opened the Form1.cs file with VS (as I believe it is written) and changed a few things - but I don't know where to go next - the compile button appears to be greyed out - and every tutorial I have seen has assumed more knowledge than I have

Help?

You cannot compile single files, only projects.

A project [.csproj] is a "container" (it doesn't actually contain files, it just points to them) for the C# source files [.cs] and all other files that belong to your project (images, etc.). It also has a certain output type, either Windows/Console Application [.exe] or Class Library [.dll], which defines what the result of a successful compilation is.

A solution [.sln] is merely a "container" pointing to different projects, so that related projects can be grouped together.


So what you want to do is, open either the solution or project, then locate the file you want to modify in the Solution Explorer (should be a tab on the right side, alternatively View > Solution Explorer). Open it and modify whatever you like, unless it already has the modifications, of course. Then go to the Build menu and select Build Solution (or equivalent, whatever is available. I think F6 is the shortcut). This will generate a new output in the "Debug" or "Release" subfolder of the project. Navigate there with normal Explorer, then replace whatever file the Lapper application is (I guess some .exe?) in the directory you installed Lapper to and try out your changes. Don't forget to back up the original .exe though, just in case you screw up.
I'm all over it like a cheap suit.

I actually binned the open source cruise InSim - there was like waaaaay loads in there, and it just ended up confusing me.

I ended up downloading the base InSim and am going from there, using the open source cruise server for reference.

Seems to be working OK so far - with a little help from someone in MSN who's a little further down the road than me - thanks Maruis mwah.

I've got a couple of buttons on the go - now it's just patching up the differences between c# and GLScript...

Advice? Start with Lapper After that, C# is so much easier to digest.

Anyone have any good links to cheat sheets?

What I'm after now is something like Gai Luron has in the beginning of the Lapper scripts, basically giving me enough innformation to really get it badly wrong
Yeah, I'm back

Probably very basic stuff, but I'm a little stuck.

I have a pop up button that happens when a player resets their car - and it works:

Quote :InSim.Send_BTN_CreateButton("^1You reset your car...", Flags.ButtonStyles.ISB_LIGHT, 7, 66, 2, 67, 0010, Connections[GetConnIdx(Players[GetPlyIdx(CRS.PLID)].UniqueID)].UniqueID, 2, false);

And I wanted one that did the same on hitting an Autocross object (in this case - a cone), so I used this:

Quote :InSim.Send_BTN_CreateButton("^7BLAMMO!", Flags.ButtonStyles.ISB_LIGHT, 10, 65, 5, 67, 0012, Connections[GetConnIdx(Players[GetPlyIdx(AXO.PLID)].UniqueID)].UniqueID, 2, false);

I assume this bit is wrong:

Quote :Connections[GetConnIdx(Players[GetPlyIdx(AXO.PLID)].UniqueID)].UniqueID

But have no idea why it's wrong.

There's no errors when debugging - it just doesn't do it.

Any ideas?
Quote from drew555 :Yeah, I'm back

Probably very basic stuff, but I'm a little stuck.

I have a pop up button that happens when a player resets their car - and it works:



And I wanted one that did the same on hitting an Autocross object (in this case - a cone), so I used this:



I assume this bit is wrong:



But have no idea why it's wrong.

There's no errors when debugging - it just doesn't do it.

Any ideas?

well i think i know why
InSim.Send_BTN_CreateButton("^1You reset your car...", Flags.ButtonStyles.ISB_LIGHT, 7, 66, 2, 67, 10, Connections[GetConnIdx(Players[GetPlyIdx(CRS.PLID)].UniqueID)].UniqueID, 2, false);

it doesnt allow more then 3 numerals in the buttons you had 0010 you should have it as 10
Thank you

Here's the revised code:

Quote : InSim.Send_BTN_CreateButton("^7BLAMMO!", Flags.ButtonStyles.ISB_LIGHT, 10, 65, 5, 67, 30, Connections[GetConnIdx(Players[GetPlyIdx(AXO.PLID)].UniqueID)].UniqueID, 2, false);

Still not happening

Oh.. and BTW, I have other buttons, example:

Quote : InSim.Send_BTN_CreateButton("^1You reset your car... ^7PANSY!", Flags.ButtonStyles.ISB_LIGHT, 7, 66, 2, 67, 0010, Connections[GetConnIdx(Players[GetPlyIdx(CRS.PLID)].UniqueID)].UniqueID, 2, false);

Using 4 figure button IDs and they work fine

I'd like to be able to use letters in there too
Quote from drew555 :I'd like to be able to use letters in there too

Create some constant variables to use for button IDs (BID_WHATEVER = 10) then you can call them what you like and make the code much easier to read.
So..... if I add something like:

Quote :const BID_WHATEVER = 10

...in my form1.cs file (in a specific place?), I can use BID_WHATEVER to call upon the value of '10'?

Or the other way round, using the value of '10' to call upon the value of 'BID_WHATEVER' or the value of 'WHATEVER'?

Working the same way as ISB_DARK for example?

Can you throw up a quick example please Elmo - I learn better by being shown
In exactly the same way as all the ISP_ and TINY_ constants are defined in the insim.txt (insim.h) file.

You would define BID_WHATEVER = 10 somewhere at the start of your code (not entirely sure in C#, but I would guess that the start of the main thread would work) then use
InSim.Send_BTN_CreateButton("^1You reset your car...", Flags.ButtonStyles.ISB_LIGHT, 7, 66, 2, 67, [b]BID_WHATEVER[/b], Connections[GetConnIdx(Players[GetPlyIdx(CRS.PLID)].UniqueID)].UniqueID, 2, false);

or similar, which uses the human readable BID_WHATEVER to refer to 10

How it works:
Constants are purely to make things readable (and easier to use and edit) to the programmer. When compiled, the compiler simply replaces every instance of "BID_WHATEVER" with "10".
Right, now I've sucessfully reinstalled, I have more questions.

This is a case issue.

I know it's possible to have a command open a button (!gui does it on lapper) but I'm missing something.

I have this:

Quote :case "!arr":
InSim.Send_MST_Message("I'm a PIRATE!");
InSim.Send_MST_Message("and I say G'arrrr!");
break;

and it's fine.

So, I thought I'd push it a bit and used this...

Quote :case "!button":
InSim.Send_BTN_CreateButton("^1Made this button with !button!", Flags.ButtonStyles.ISB_LIGHT, 7, 66, 2, 67, 0014, (MSO.UCID) 2, false);
break;

And it's telling me:

Quote :Error 1 The type or namespace name 'MSO' could not be found (are you missing a using directive or an assembly reference?)

Now, I've seen this error a few times - and I have no idea what it means.

Is it something basic and obvious? Am I showing my n00b status?
-
(MariusMM) DELETED by MariusMM
Quote from MariusMM :(Connections[GetConnIdx(MSO.UCID)].UniqueID)

One day I'll figure out what that bit is and what it does

Thanks Marry
Still on ther same subject - that piece of code Maruis just posted works for !case wirth no problems at all.

And when the same syntax was used for car reset it worked also.

But with an autocross object - it doesn't.

I replaced the event trigger code (MSO) with the one the InSim.txt lists as AXO and nothing happens. No errors, but no action either.

Obviously there are rules governing the use of these codes - where you can use it in a basic form such as (NCN.UCID) and where you need the more complicated version such as (Connections[GetConnIdx(MSO.UCID)].UniqueID)

What are the rules for this I am missing?
"MSO.UCID" has the very same value as "Connections[GetConnIdx(MSO.UCID)].UniqueID" though. What the second one does is iterates through the connections list until it finds a connection with the ID MSO.UCID, and then returns the ID, which is going to be the same as MCO.UCID. I can't see any reason why the second one would work where the first one would fail, the second one is dependent on the first one really

When using a packet that contains the PlayerID rather than the UniqueID, you have to use something like this to get a UCID from a PLID:

Players[GetPlyIdx(!PLID HERE!)].UniqueID

Generally, if a packet can only be sent when a player is on track, a PLID is included (such as hitting an autocross object), or if the player can be either on track or spectating a UCID is sent (such as typing a message). IS_AXO only contains a PLID, so you'll have to use the code above. In InSim.txt, if you search for the packet you're looking for, it'll tell you exactly what's sent, a UCID, or a PLID.

A player is only assigned a PLID when on track (and it can and probably will be different each time they join from spectate), but a UCID stays with them for as long as they are connected to the server. So you can't rely on a PLID, it's always best to use a UCID where possible
Brilliant. Thank you.

And a strange one now...

I'm using code that's tested on a remote host using this:

Quote : InSim.Send_BTN_CreateButton("^7BLAMMO!", Flags.ButtonStyles.ISB_LIGHT, 4, 30, 135, 4, 019, (Connections[GetConnIdx(Players[GetPlyIdx(AXO.PLID)].UniqueID)].UniqueID), 2, false);

And it works fine (if a little slow, we assume it's something to do with AXO packets perhaps being delivered slowly).

However.. on my local host it just wont do it - and InSim sniffer doesn't report any AXO packets.

Have I missed a setting or a checkbox somewhere?
There's no need for the "(Connections[GetConnIdx(Players[GetPlyIdx(AXO.PLID)].UniqueID)].UniqueID)" part btw, it's the same story as with MSO.UCID vs. Connections[GetConnIdx(MSO.UCID)].UniqueID.

"Players[GetPlyIdx(AXO.PLID)].UniqueID" would be all you need to return the UCID, the rest is just pointless CPU cycles. It mightn't make much of a difference here, but if you were to put something similar in an MCI function on a busy server, that's up to 1,024 wasted CPU cycles every 500ms, just to find one ID. That could mean 32,768 wasted cycles to ID each player on the server, just for a single function. Sorry if it seems I'm nitpicking, but it all adds up...

But that isn't causing the issue. If InSim sniffer isn't finding any AXO packets, your program isn't at fault. It might be a setting in LFS, I'm not sure. See if you're getting 2 second penalties for hitting the objects. If not, then LFS wouldn't send an AXO. It might be that LFS doesn't count it as a "true" autocross layout, and doesn't count hitting an object as a fault.
i still don't understand how to make message when someone hit autocross Object.

does it need messages like pitstop (repair msgs) or what ?

i tried everything

can anyone help me with it ?
Holy thread bump batman.

The IS_OBH (OBject Hit) packet is what you're after. However, you only receive IS_OBH packets if you set the ISF_OBH flag in your IS_ISI (InSim Init) packet.

As for how you do that, it depends the language and what, if any, libraries you're currently using.

I highly recommend reading InSim.txt (included in data/docs of your LFS installation, or on the wiki) as it details how InSim, OutSim and Outgauge work.
Quote from the_angry_angel :Holy thread bump batman.

The IS_OBH (OBject Hit) packet is what you're after. However, you only receive IS_OBH packets if you set the ISF_OBH flag in your IS_ISI (InSim Init) packet.

As for how you do that, it depends the language and what, if any, libraries you're currently using.

I highly recommend reading InSim.txt (included in data/docs of your LFS installation, or on the wiki) as it details how InSim, OutSim and Outgauge work.

as i understood from your msg that the IS_OBH packet what make msg for who crash the barrier or any object but isn't it AXO_PlayerHitsAutocrossObject ??

i will try it with IS_OBH
just information that nothing name IS_OBH i tried to add this packet to my InSim not working ....
Quote from HonzaQ4 :but isn't it AXO_PlayerHitsAutocrossObject ??

Without knowing what library you're using I cannot answer that question. All I can tell you is the underlying InSim protocol. I suggest you read the docs for your library.
dude, iam using InSim with C# Language with coding so if you want any another information i will tell you but i already have made everything ok..just need 1 help from you....

Quote :IS_CON reports contact between two cars (if ISF_CON is set)
IS_OBH reports information about any object hit (if ISF_OBH is set)

so 1 help from you how to set ISF_OBH and ISF_CON in iC InSim just it!

and thank you ..
Quote from HonzaQ4 :
so 1 help from you how to set ISF_OBH and ISF_CON in iC InSim just it!

You have to set these as flags in IS_ISI packets. I assume you're using some library for the InSim interface, so check out to its documentation for details.
Yeah iam using library for InSIm interface but i dont know anything about crash system so iam trying everything to make it....


dude, iam asking how to set it ?

can you help ?
Quote from HonzaQ4 :
can you help ?

I can't unless you tell us which InSim library and version are you using. For instance the latest official release of LFS_External 1.1.1.4 doesn't support any of the new packets introduced in LFS 0.6B.
iam using iC InSim here
1

FGED GREDG RDFGDR GSFDG