The online racing simulator
.NET - InSim.NET - InSim library
(731 posts, started )
DarkTimes or others, can explain about the packets OutSim


i use Arduino, and i can print the values of Sim.

But i have many question below,

int time, ----- is ok to me
Angular Velocity : 3 floats, ----- Where i use it ??
Orientation :3 floats Heading, Pitch, Roll, ----- is ok to me
Acceleration :3 floats X, Y, Z ----- same that accelerometer
Velocity :3 floats X, Y, Z ----- velocity in axes ??
Position :3 ints X, Y, Z (metres x 65536) ----- position of what ?
what the reference ?

Game ID :1 int, ----- is ok to me

Can anyone help me ??, or have a document do read about it ??

TKS
Can someone give me a hand please?

I need a code that when a user goes through node 53 on the Blackwood track, he sends it directly to the pits.
and also to show the reaction time of a user when leaving when the traffic light turns green.

This is a part of the traffic light code and the green light...


<?php 
                
else if (LuzSpeed == 2)
                {
                    if (
C.Counter == 15)
                    {
                        
C.Counter 0;
                        if (
C.DragStage == 2)
                        {
                            
C.DragStage 3;
                            
InSim.Send_BTN_CreateButton("^3•"Flags.ButtonStyles.ISB_C121219317419C.UniqueID2false); //LUZ1-IZQUIERDA - GRANDE
                            
InSim.Send_BTN_CreateButton("^3•"Flags.ButtonStyles.ISB_C121219318520C.UniqueID2false); //LUZ1-DERECHA - GRANDE
                        
}
                        else if (
C.DragStage == 3)
                        {
                            
C.DragStage 4;
                            
InSim.Send_BTN_CreateButton("^3•"Flags.ButtonStyles.ISB_C1212110317421C.UniqueID2false); //LUZ2-IZQUIERDA - GRANDE
                            
InSim.Send_BTN_CreateButton("^3•"Flags.ButtonStyles.ISB_C1212110318522C.UniqueID2false); //LUZ2-DERECHA - GRANDE
                        
}
                        else if (
C.DragStage == 4)
                        {
                            
C.DragStage 5;
                            
InSim.Send_BTN_CreateButton("^3•"Flags.ButtonStyles.ISB_C1212111317423C.UniqueID2false); //LUZ3-IZQUIERDA - GRANDE
                            
InSim.Send_BTN_CreateButton("^3•"Flags.ButtonStyles.ISB_C1212111318524C.UniqueID2false); //LUZ3-DERECHA - GRANDE
                        
}
                        else if (
C.DragStage == 5)
                        {
                            
C.DragStage 6;
                            
InSim.Send_BTN_CreateButton("^2•"Flags.ButtonStyles.ISB_C1212112317425C.UniqueID2false); //LUZ4-IZQUIERDA - GRANDE
                            
InSim.Send_BTN_CreateButton("^2•"Flags.ButtonStyles.ISB_C1212112318526C.UniqueID2false); //LUZ4-DERECHA - GRANDE
                        
}
                        else if (
C.DragStage == 6)
                        {
?>

If someone could make me a code with those functions, I'd really appreciate it since I'm learning how to use Insim.Net
Just build something in the MCI package where you check if the current node is 53. Then send the /spec command with the corresponding username.
Quote from Bose321 :Just build something in the MCI package where you check if the current node is 53. Then send the /spec command with the corresponding username.

Thanks for answering, but what I'm going to do is that I still do not program well in InSim.Net, so I ask someone who can create a code with those functions for me in the future to guide me in that code to build other things. .
Quote from NakaTech :Thanks for answering, but what I'm going to do is that I still do not program well in InSim.Net, so I ask someone who can create a code with those functions for me in the future to guide me in that code to build other things. .

InSim insim = new InSim();

// Bind Received Packets to your methods.
// <IS_XXX> is the name of the packet, (XXX_Handler) is the method that is executed everytime a IS_XXX packet is received.
insim.Bind<IS_MCI>(MCI_Handler);

// Connect InSim (read about IS_ISI in InSim.txt doc for more info)
insim.Initialize(new InSimSettings {Host = "127.0.0.1", Port = 29999, IName = "InSimName", Flags = InSimFlags.ISF_MCI, Interval = 500});

// Method that is executed everytime a MCI packet is received.
// (Read InSim.txt doc to understand what is contained inside InSim Packets and hence how to handle them).
void MCI_Handler(InSim insim_var, IS_MCI MCI)
{
for (int n = 0; n < MCI.NumC; n++)
{
if (MCI.Info[n].Node == 53)
{
// Retrieve the Username of the player which has "MCI.Info[n].PLID" as current PlayerID...

// Pitlane him...
insim.Send("/pitlane " + Username);
}
}
}

Quote from Comomillo :
InSim insim = new InSim();

// Bind Received Packets to your methods.
// <IS_XXX> is the name of the packet, (XXX_Handler) is the method that is executed everytime a IS_XXX packet is received.
insim.Bind<IS_MCI>(MCI_Handler);

// Connect InSim (read about IS_ISI in InSim.txt doc for more info)
insim.Initialize(new InSimSettings {Host = "127.0.0.1", Port = 29999, IName = "InSimName", Flags = InSimFlags.ISF_MCI, Interval = 500});

// Method that is executed everytime a MCI packet is received.
// (Read InSim.txt doc to understand what is contained inside InSim Packets and hence how to handle them).
void MCI_Handler(InSim insim_var, IS_MCI MCI)
{
for (int n = 0; n < MCI.NumC; n++)
{
if (MCI.Info[n].Node == 53)
{
// Retrieve the Username of the player which has "MCI.Info[n].PLID" as current PlayerID...

// Pitlane him...
insim.Send("/pitlane " + Username);
}
}
}


Thanks for answering, I've put it that way but when going through the node it does not do any action: /

void MCI_Handler(Packets.IS_MCI MCI)
{
for (int n = 0; n < MCI.NumC; n++)
{
if (MCI.Info[n].Node == 56)
{
// Retrieve the Username of the player which has "MCI.Info[n].PLID" as current PlayerID...

// Pitlane him...
foreach (clsConnection Conn in Connections)
InSim.Send_MST_Message("/pitlane " + Conn.Username);
}
}
}


<?php 
foreach (clsConnection Conn in Connections) {
                    
InSim.Send_MST_Message("/pitlane " Conn.Username);
}
?>

That's not how you should do it

You're pitlaning everyone that way.
Quote from racerss :

<?php 
foreach (clsConnection Conn in Connections) {
                    
InSim.Send_MST_Message("/pitlane " Conn.Username);
}
?>

That's not how you should do it

You're pitlaning everyone that way.

How would the correct form be?

Similarly, in that mode, it does not send to the pits
Quote :
I need a code that when a user goes through node 53 on the Blackwood track

1) You're checking for 56 in your code
2) Do some researches about for/foreach loops; you want to only pick the element that corresponds to what you're looking for, use an if statement; if (playerA.PLID == element.PLID) // Example
Quote from racerss :1) You're checking for 56 in your code
2) Do some researches about for/foreach loops; you want to only pick the element that corresponds to what you're looking for, use an if statement; if (playerA.PLID == element.PLID) // Example

The bad thing is that I'm just starting to create insims... and I do not understand very well how the codes go, for that reason I am requesting if someone could make me a functional code so I can be guided by that code to do more things...

Thanks for answering
Quote from NakaTech :Thanks for answering, I've put it that way but when going through the node it does not do any action: /

void MCI_Handler(Packets.IS_MCI MCI)
{
for (int n = 0; n < MCI.NumC; n++)
{
if (MCI.Info[n].Node == 56)
{
// Retrieve the Username of the player which has "MCI.Info[n].PLID" as current PlayerID...

// Pitlane him...
foreach (clsConnection Conn in Connections)
InSim.Send_MST_Message("/pitlane " + Conn.Username);
}
}
}


With "Retrieve the Username of the player..." I meant the following: everytime a player joins the track or leaves the pits he gets a PlayerID number. You have to keep track of which number is assigned to which player. So then from a PlayerID number you can find who is the corresponding player that has that PlayerID, and finally you can pitlane him.

In your case those info are stored in the Connections List. So you have to do something like this:
// Retrieve the Username of the player...
foreach (clsConnnection Conn in Connections)
{
if (Conn.PlayerID == MCI.Info[n].PLID)
{
insim.Send("/pitlane " + Conn.Username);
}
}

How can I make the connection to the insim, automatically read the name of the server and the name of the server appears on a button?
Quote from NakaTech :How can I make the connection to the insim, automatically read the name of the server and the name of the server appears on a button?

Request an IS_ISM packet, which contains HName. (All details in InSim.txt doc)
Hello everyone, i need assistance with my program. With this code i can add players to the dictionary and write the name in the console. I cant figure out how to write to console player name when player leaves the track. Its been a long time since i did any programming, so excuse me if this is a really simple solution.

static void NewPlayer(InSim insim, IS_NPL npl)
{
if (players.ContainsKey(npl.PLID)) // Adding players to players dict
{
// Player leaving pits, just updating NPL object
players[npl.PLID] = npl;
Console.WriteLine(npl.PName + " PLID updated");
}
else
{
// Add new player.
players.Add(npl.PLID, npl);
Console.WriteLine(npl.PName + " added");
}
}
static void PlayerLeft(InSim insim, IS_PLL pll)
{
// Remove player.
players.Remove(pll.PLID);
Console.WriteLine("Player removed: player left the track");
}

I think this should work, assuming the players dictionary is of type <int, IS_NPL>:

static void PlayerLeft(InSim insim, IS_PLL pll)
{
IS_NPL player = players[pll.PLID];

// Remove player.
players.Remove(pll.PLID);
Console.WriteLine(player.PName + "Player removed: player left the track");
}

players[pll.PLID].PName
Of course you'll have to use it before the "players.Remove"
Quote from Flame CZE :I think this should work, assuming the players dictionary is of type <int, IS_NPL>:

static void PlayerLeft(InSim insim, IS_PLL pll)
{
IS_NPL player = players[pll.PLID];

// Remove player.
players.Remove(pll.PLID);
Console.WriteLine(player.PName + "Player removed: player left the track");
}


Thank you very much.
-
(Flame CZE) DELETED by Flame CZE
Someone pointed out that the NuGet package was massively out of date, so I updated it to the the latest code on GitHub. Let me know if there are any problems.
The pyinsim library contains some critical errors, see the issue filed 10 months ago.

Thanks for updating.
OK - I've fixed that IS_MSO bug in pyinsim.
Is this library up to date?
How would I have to put to have a random number?

int numero_alea(int de, int ate)
{
//número aléatorio para semáforo en verde
int random;
ate -= de;
random = rand() % (ate + 1) + de;
return random;
}

I want to put a random number where that button appears

{
C.DragStage = 6;
int alea;
alea = numero_alea(1, 20);
if (C.Counter == 5 + alea)
InSim.Send_BTN_CreateButton("^2•", Flags.ButtonStyles.ISB_C1, 21, 21, 123, 174, 25, C.UniqueID, 2, false); //LUZ4-IZQUIERDA - GRANDE
InSim.Send_BTN_CreateButton("^2•", Flags.ButtonStyles.ISB_C1, 21, 21, 123, 185, 26, C.UniqueID, 2, false); //LUZ4-DERECHA - GRANDE
}
What does that have to do with this library? Just google how to get a random number with C#.
Quote from Bose321 :What does that have to do with this library? Just google how to get a random number with C#.

I looked it up but it didn't work for me and I thought they could help me here since I haven't been using visual studio for a long time.

.NET - InSim.NET - InSim library
(731 posts, started )
FGED GREDG RDFGDR GSFDG