The online racing simulator
#1 - ab12
I don't understand
Hello guys, i don't understand why the code don't work Fap Confused

clsConn Conn = new clsConn();
var mph = car.Speed / 146;

Conn.InPlace1Dist = ((int)Math.Sqrt(Math.Pow(car.X - (- 102 * 196608), 2) + Math.Pow(car.Y - (-42 * 196608), 2)) / 65536);
if (Conn.InPlace1Dist <= 4 && (mph <= 4))
{
insim.Send(new IS_BTN {Text = "^7Welcome", BStyle = ButtonStyles.ISB_DARK, H = 15, W = 109, T = 55, L = 46, ClickID = 10, UCID = 0, ReqI = 10});
}

clsConn is a list from iC source, I have this source for documentation.
Can anyone help me please ? Frown
-
(cargame.nl) DELETED by cargame.nl : oops
First debug your speed detection, if this works debug your location detection.
#3 - ab12
Quote from cargame.nl :First debug your speed detection, if this works debug your location detection.

What you mean ?
Debugging your own code is one of the main skills any developer needs.
Debugging means checking your code for issues, by breaking it up into several pieces and add checks between them.
A check can be writing a message to a console, to see wether or not a loop has started or if a variable is filled with a value (or the correct value).

So, first check the part of the speed detection.
If that comes up with a correct value or enters the correct loop, then check if the location detection is working as intended.
Quote from ab12 :What you mean ?

Basically you need to check if the point of sending that button actually ever takes place.

If speed detection fails that button never gets send
If your location is incorrect that button also never get send

Like Yisc is saying, you need to echo some stuff to console to see if 'stuff really is happening'. You probably test this local but UCID = 0 is local.. So it fails when you try to test it while connected to a remote server.

So what I would do first is


if (mph <= 4)
{
print("hey, car is driving slower then 4mph");
}
if (Conn.InPlace1Dist <= 4)
{
print("near point X");
}

If the console is saying...

hey, car is driving slower then 4mph
near point X

Then I know that there is something wrong with button sending. If the console is saying nothing then.. If the console is saying hey, car is driving slower then 4mph but not near point X .. Etc etc.. You try to do too many stuff at the same time and not knowing what you actually are doing (it seems).

I don't know if print(""); is the correct command by the way. Just an assumption, I code in PHP.
#6 - ab12
Quote from cargame.nl :
I don't know if print(""); is the correct command by the way. Just an assumption, I code in PHP.

Is Console.WriteLine("");
I saw in console "hey, car is driving slower then 4mph" but when i go to InPlace1Dist.. nothing :| Fap
Print the current distance from the location and car's X,Y coordinates to console to check what values are you actually getting.
#8 - ab12
I printed the car's X and Y was big numbers lol, but i solved the problem Smile
Thank you guys !
Thumbs up

FGED GREDG RDFGDR GSFDG