The online racing simulator
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?
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.
I can't quite do it with my eyes shut but...
Quote from danthebangerboy :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
Can anyone answer my question?

I will repost it incase it got lost

Quote :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?

Quote from vane :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.

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#).
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);
}

Quote from vane :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.
#334 - gru
InSim doesnt have to be static if its declared in MainForm (Form1?)

Quote from broken :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
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.
Quote from vane :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.
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
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.
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
Also, is there any way of viewing this insim on a server that has an insim?
#341 - gru
Quote :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?

Quote :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
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
Quote from vane :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?
Quote from vane :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.

Quote from InSim.txt :// 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...
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_LOCAL, 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);

OK thats working now, although it still says that the admin password is wrong
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?
Make sure you are using an internal car view, as it only works when you are viewing from the cockpit.
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
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 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.

FGED GREDG RDFGDR GSFDG