The online racing simulator
XY Positioning / AU1
(3 posts, started )
XY Positioning / AU1
Hey guys, looking for some help with this little bit of code. I was never too sure on how the XY Positioning worked with InSim but I now do know how to position it etc. My problem is, stating from a brand new InSim 'template' my XY is not working for for the Autocross. Here is my code:

// Detailed car information packet (max 8 per packet)
private void MCI_CarInformation(Packets.IS_MCI MCI)
{
for (int i = 0; i < Players.Count; i++)
{
if (Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].Username == "imthebestracerthereis")
{
InSim.Send_BTN_CreateButton("^1X: " + MCI.Info[i].X / [B]196608[/B] + " ^2Y: " + MCI.Info[i].Y / [B]196608[/B], Flags.ButtonStyles.ISB_DARK, 5, 15, 12, 90, 8, (Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID), 2, false);
}

if (((MCI.Info[i].X / [B]196608[/B]) >= -7) && ((MCI.Info[i].X / [B]196608[/B]) <= 17) && ((MCI.Info[i].Y / [B]196608[/B]) >= 287) && ((MCI.Info[i].Y / [B]196608[/B]) <= -243))
{
InSim.Send_BTN_CreateButton("^2Area 1", Flags.ButtonStyles.ISB_DARK, 5, 20, 145, 28, 7, (Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID), 2, false);
}
else
{
InSim.Send_BTN_CreateButton("^1Area 2", Flags.ButtonStyles.ISB_DARK, 5, 20, 145, 28, 7, (Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID), 2, false);

}
}

}

It always shows as Area 2
The thing that would make me curious is in bold
Any help would be greatly appreciated!
#2 - gru
(MCI.Info[i].Y / 196608) [COLOR="Red"]>=[/COLOR] 287) && ((MCI.Info[i].Y / 196608) [COLOR="Red"]<=[/COLOR] -243)

number cant be bigger than 287 and smaller than -243
correct comparison operators

Quote :The thing that would make me curious is in bold

[MCI.Info[i].Y / 65536 is convertion to meters, so i quess it converts position to 3 meters units (?!)

but i really dont know why. wouldnt it be better to use float values instead of integer?

float x = (float)MCI.Info[i].X / 65536;
float y = (float)MCI.Info[i].Y / 65536;

if ((x >= -24.1) && (x <= 51.2) && (y >= -729.3) && (y <= 861.4))
{
...
}

now U operate on real units and can compare with higher precission
Ah, I looked into it, and figured out that I had the negative in the wrong spot Thanks!

XY Positioning / AU1
(3 posts, started )
FGED GREDG RDFGDR GSFDG