The online racing simulator
#1 - sun
coding the x, y co-ordiantes (problem)
Hi people,

I have a slite problem with the x, y co-ordiantes of my lotto ticket place, what i'am making, and it is that when i build the square. When i go in the middle it shows the message i want it to show. Right i'all get to the point... first of all i created the x, y co-ordiante code for the lotto ticket place

if ((MCI.Info[0].X / 196608 >= 46176313) && (MCI.Info[0].Y / 196608 >= 15915129))

above that i have

if (MCI.Info[0].X = 3) & (MCI.Info[0].Y = 3);



and its saying that i have n error with the MCI method i used.

Errors:

Error 1 Cannot implicitly convert type 'int' to 'bool' C:\Documents and Settings\Owen\Desktop\Cruise Tutorial\LFS_External_Client\LFS_External_Client\Form1.cs 557 17 LFS_External_Client
Error 2 Only assignment, call, increment, decrement, and new object expressions can be used as a statement C:\Documents and Settings\Owen\Desktop\Cruise Tutorial\LFS_External_Client\LFS_External_Client\Form1.cs 557 36 LFS_External_Client
Error 3 Pointers and fixed size buffers may only be used in an unsafe context C:\Documents and Settings\Owen\Desktop\Cruise Tutorial\LFS_External_Client\LFS_External_Client\Form1.cs 557 36 LFS_External_Client
Error 4 Cannot take the address of the given expression C:\Documents and Settings\Owen\Desktop\Cruise Tutorial\LFS_External_Client\LFS_External_Client\Form1.cs 557 36 LFS_External_Client

Big error really, but i'am trying to figure it out for my self. Just thought if you guys could point me in the right direction of what i've done wrong

Thanks...

Regards

Owen.
You have to put == for comparison, not =

if (MCI.Info[0].X == 3) & (MCI.Info[0].Y == 3)
#3 - sun
Thanks,

But now its underlined
& (MCI.Info[0].Y == 3);


if (MCI.Info[0].X = 3) & (MCI.Info[0].Y = 3);

should be

if ((MCI.Info[0].X == 3) && (MCI.Info[0].Y == 3))
{

}
#5 - sun
Thanks for the help guys
#6 - sun
only yes or no on this : P

would
if
((MCI.Info[0].X == 3)&(MCI.Info[0].Y == 3));

if ((MCI.Info[0].X / 196608 >= 46176313) && (MCI.Info[0].Y / 196608 >= 15915129))
{
InSim.Send_MST_Message(
"/msg ^7You have found your daily lottery ticket!");
}

that code work if i go inside the 3 boxes
if ((MCI.Info[0].X == 3)&(MCI.Info[0].Y == 3));


would it say You have found your daily lottery ticket!

?


To be honest, I really don't understand what that code is supposed to do. Especially the if statements that just end with a semicolon, thus doing nothing.

If you want to check if the player is within a certain "box" on the track, then you first have to define the coordinates of the box, like this:


Rectangle box = new Rectangle();
box.Top = 6 * 65536; //6 metres to the north of the track centre point
box.Left = 3 * 65536; //3 metres to the east
box.Right = 6 * 65536; //6 metres to the east
box.Bottom = 3 * 65536; //3 metres to the north

... or you do it with coordinates and width/height

box.X = 3 * 65536; //3 metres east
box.Y = 6 * 65536; //6 metres north
box.Width = 3 * 65536; //3 metres
box.Height= 3 * 65536; //3 metres

... respectively negative values if you want to go to south/west

Then you can check if the player is inside the box with:

if(box.Contains(MCI.Info[0].X, MCI.Info[0].Y))
{
//do stuff
}

You code is compiling but not running in anyway you want it to. & and && are two completely different things. Ending an if () with a ; is pointless as it will never do anything. Thats as far as I am going to go because it seems your looking for someone to tell you every step of the way whats wrong.
Out of intrest Android, is Rectangle part of the .Net or an object you created and defined?
.Net
Can be found in the System.Drawing namespace
Quote from AndroidXP :.Net
Can be found in the System.Drawing namespace

Aha, Thanks!


E: That doesnt exist?!!?
Quote from AndroidXP :To be honest, I really don't understand what that code is supposed to do. Especially the if statements that just end with a semicolon, thus doing nothing

It reads as an attempt to do the exact same thing that the bounding example you've given, however there's no actual checking of the 2 diagonal x and y coordinates, only a single one.
#15 - sun
So that code of mine doesnt do nothing ?
Yes. Well, it might produce weird messages at seemingly random times, but definitely not what you wanted it to do.
#17 - sun
ok,

when i do my lotto ], i might do a bank to, but that might be in the future when i'am better at programming....
#18 - sun
ok

Error 2 The name 'Box' does not exist in the current context C:\Documents and Settings\Owen\Desktop\Cruise Tutorial\LFS_External_Client\LFS_External_Client\Form1.cs 565 17 LFS_External_Client

if (box.Contains(MCI.Info[0]

theres somthing wrong with the 'box' thing
Quote from sun :ok

Error 2 The name 'Box' does not exist in the current context C:\Documents and Settings\Owen\Desktop\Cruise Tutorial\LFS_External_Client\LFS_External_Client\Form1.cs 565 17 LFS_External_Client

if (box.Contains(MCI.Info[0]

theres somthing wrong with the 'box' thing

Quote from AndroidXP :To be honest, I really don't understand what that code is supposed to do. Especially the if statements that just end with a semicolon, thus doing nothing.

If you want to check if the player is within a certain "box" on the track, then you first have to define the coordinates of the box, like this:


[B]Rectangle box = new Rectangle();[/B]
[B]box.Top = 6 * 65536; //6 metres to the north of the track centre point[/B]
[B]box.Left = 3 * 65536; //3 metres to the east[/B]
[B]box.Right = 6 * 65536; //6 metres to the east[/B]
[B]box.Bottom = 3 * 65536; //3 metres to the north[/B]

... or you do it with coordinates and width/height

box.X = 3 * 65536; //3 metres east
box.Y = 6 * 65536; //6 metres north
box.Width = 3 * 65536; //3 metres
box.Height= 3 * 65536; //3 metres

... respectively negative values if you want to go to south/west

Then you can check if the player is inside the box with:

if(box.Contains(MCI.Info[0].X, MCI.Info[0].Y))
{
//do stuff
}


...
#20 - sun
Originally Posted by AndroidXP
To be honest, I really don't understand what that code is supposed to do. Especially the if statements that just end with a semicolon, thus doing nothing.

If you want to check if the player is within a certain "box" on the track, then you first have to define the coordinates of the box, like this:

Code:
Rectangle box = new Rectangle();box.Top = 6 * 65536; //6 metres to the north of the track centre pointbox.Left = 3 * 65536; //3 metres to the eastbox.Right = 6 * 65536; //6 metres to the eastbox.Bottom = 3 * 65536; //3 metres to the north ... or you do it with coordinates and width/height box.X = 3 * 65536; //3 metres eastbox.Y = 6 * 65536; //6 metres northbox.Width = 3 * 65536; //3 metres box.Height= 3 * 65536; //3 metres ... respectively negative values if you want to go to south/west


Is that VB code or C# ?

i tryed it and it didnt work

do you mean the if statement then the Rectangle Box = new Rectangle();

the rest here



Regards, Owen
You would need to put the box definition code before the if, otherwise the C# compiler will get very upset, as you'd be trying to access something that doesn't exist.

And yes, it's C# code.
your code, but the problem is create flood, change the values 442 for yours coordinates.


if ((MCI.Info[0].X >= 442) && (MCI.Info[0].Y >= 442))
{
InSim.Send_MST_Message("/msg ^7You have found your daily lottery ticket!");
}


for see coordinates, this code send your position for position the ticket.


{
InSim.Send_MST_Message("/msg ^3X " + MCI.Info[0].X);
InSim.Send_MST_Message("/msg ^4Y " + MCI.Info[0].Y);
}

#23 - sun
ahh ok

so when you go over it it will say the msg ?
#24 - sun
InSim.Send_MST_Message("/msg ^3X " + MCI.Info[0].X);
InSim.Send_MST_Message("/msg ^4Y " + MCI.Info[0].Y);

what does that do ?

do you mean

InSim.Send_MST_Message("X: " + MCI.Info[0].X);
InSim.Send_MST_Message("Y: " + MCI.Info[0].Y);

InSim.Send_MST_Message("/msg ^3X " + MCI.Info[0].X);
InSim.Send_MST_Message("/msg ^4Y " + MCI.Info[0].Y);

this is for see position what you need, the other code is for daily ticket.

The problem is flood, i dont know how to stop the flood.
1

FGED GREDG RDFGDR GSFDG