The online racing simulator
C# Coordiantes!
Well I am having difficulty doing a simple thing. I am trying to do coordinates for an action in C#. Here is the code:

if ((Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].Lotto == 0) && ((MCI.Info[i].X / 13021738) >= -103) && ((MCI.Info[i].X / 13044727) <= -100) && ((MCI.Info[i].Y / 10070602) >= -6) && ((MCI.Info[i].Y / 10621978) <= -5) && ((MCI.Info[i].Speed / 147) <= 3))
{
InSim.Send_MST_Message("/msg ^7" + (Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].Username) + " found a lottery ticket!");
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].Lotto = 1;
}

There are no errors reported in C#, but it doesn't do the action in LFS. Please can you help?
Why are you dividing the coordinates by random numbers?

Anyway, first create a Rectangle object, which you use to define the area something should happen in.


//Creates a 10x10m block that is offset 20m to the north and 50m to the
//east of the map centre (offset measured from upper left corner)
Rectangle r = new Rectangle();
r.Left = 50;
r.Top = 20;
r.Right = 60;
r.Bottom = 10;

//Alternatively, you can also set it up like this, which does the same as above
r.X = 50;
r.Y = 20;
r.Width = 10;
r.Height = 10;

Then you use the .Contains() function of the Rectangle to check whether the player coordinates are within that area.

int plX = MCI.Info[i].X / 65535; //Convert X coordinate to metres
int plY = MCI.Info[i].Y / 65535; //Convert Y coordinate to metres

if (r.Contains(plX, plY))
{ /* Do your fancy lottery code */ }

With this example the accuracy is only in whole metres, so if you need something more accurate while still using metres as base, then use the RectangleF object, which uses float instead of int.

Don't forget to also include a check for .Lotto != 1, to make sure each player passes the check only once. Otherwise this check will spam the message as long as the player is within the lottery area.
Shaun u know u can ask me in msn Im wondering why u dont asked me...

FGED GREDG RDFGDR GSFDG