The online racing simulator
Well, TAA isn't like normal people. Look at that beard, Jesus...

Anyway my point was that programming isn't about being smart, it's about using your intelligence in meaningful way. Some people can knock great code together in their sleep, some of us need to pour over it for painstaking hours. Nobody finds it easy, if they did it wouldn't be any fun. It's like racing, if you didn't have to try really hard and practice for hundreds of laps, there would be no impetus to keep trying and improving and no sense of achievement. Anyone who says it's easy is either lying or trying to motivate you. Anyway, we've spamed this forum more than enough for tonight.
Quote from DarkTimes :Well, TAA isn't like normal people. Look at that beard, Jesus...

Anyway my point was that programming isn't about being smart, it's about using your intelligence in meaningful way. Some people can knock great code together in their sleep, some of us need to pour over it for painstaking hours. Nobody finds it easy, if they did it wouldn't be any fun. It's like racing, if you didn't have to try really hard and practice for hundreds of laps, there would be no impetus to keep trying and improving, and no sense of achievement. And anyone who says it's easy is either lying or trying to motivate you. Anyway, we've spamming this forum more than enough for tonight.

Hahaha, I do agree though. Programming wouldnt be fun if you didnt sit there countless hours and then finally achive something. When i get this code finally done, I shall throw a party and your all invited

Like you say enough spam, Time to code and then sleep
Eehii lol, he just wants a counter on the top like he saw on my server (i think) btw Heiko it's Impulser, and repace your MCI Packet Recived with this:

private void MCI(Packets.IS_MCI MCI)
{
for (int i = 0; i < Players.Count; i++)
{
decimal Speed = (decimal)((MCI.Info[i].Speed * (100f / 32768f)) * 3.6f);
decimal ConvSpeed = (decimal)(Speed * 25 / 1000);
Players[GetPlyIdx(MCI.Info[i].PLID)].Payout += ConvSpeed;
String CarSpeed = Speed * 5 / 8 + "";
string[] StrMsg = CarSpeed.Split('.');
Players[GetPlyIdx(MCI.Info[i].PLID)].RoundedSpeed = int.Parse(StrMsg[0]);
InSim.Send_BTN_CreateButton("^1Car Speed: ^7" + int.Parse(StrMsg[0]) + " MPH", Flags.ButtonStyles.ISB_DARK, 5, 30, 6, 130, 9, Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID, 2, false);
}
}

Quote from DarkTimes :I'm guessing you're using C#, as you have been posting in the LFS_External threads. If you want to convert the speed into KPH and MPH you can do something like this.

// Convert speed into meters per second.
float mps = (speed / 32768f) * 100f);

// Convert meters per second into MPH/KPH...
float mph = mps * 2.2369362920544f;
float kph = mps * 3.6f;

If you are looking at distance travelled, then you can use the X, Y and Z positions. You need to store the players last X, Y and Z co-ordinates and when when you receive a new MCI packet, you just check to see how far the player has travelled since the last one you received.


// Convert X, Y and Z into meters.
float currentX = x / 65536f;
float currentY = y / 65536f;
float currentZ = z / 65536f;

// Figure out how many meters we have moved since the previous MCI packet was received.
float distanceX = currentX - previousX;
float distanceY = currentY - previousY;
float distanceZ = currentZ - previousZ;
double metersTravelled = Math.Sqrt((distanceX * distanceX) + (distanceY * distanceY) + (distanceZ * distanceZ));

// Add this to our total.
totalMetersTravelled += metersTravelled.

// Convert the total into MPH/KPH...
double kilometersTravelled = totalMetersTravelled / 1000;
double milesTravelled = totalMetersTravelled / 1609.344;

Hope that helps some.

How do I do a button for the distance?
Please help
If you're using the old version of LFS_External, MCI packets come in at 1000ms intervals. In the new version (1.0.0+), they come in at 500ms intervals.

Assuming you haven't changed these values, then it's quite easy to work out distance travelled, by using Distance = Speed X Time.

Convert the received speed value into m/s ((speed / 32768f) * 100f), then divide by 2 if you have the new version, otherwise leave it. This value is then the distance travelled since the last received event
Quote from dougie-lampkin :If you're using the old version of LFS_External, MCI packets come in at 1000ms intervals. In the new version (1.0.0+), they come in at 500ms intervals.

Assuming you haven't changed these values, then it's quite easy to work out distance travelled, by using Distance = Speed X Time.

Convert the received speed value into m/s ((speed / 32768f) * 100f), then divide by 2 if you have the new version, otherwise leave it. This value is then the distance travelled since the last received event

Sorry for nagging you but I don't understand
Ok...Assuming you're using the old version of LFS_External, this is what you need to do:

Convert the received speed value (MCI.Info[index].Speed) into m/s ((Speed / 32768f) * 100f). This value is then the distance travelled by the player in the last second, in metres. You can have a variable that you can then add this on to...
So what would the code be? Sorry I'm nagging I just don't understand

EDIT: I'm using 1.04
Short of doing it for you, that is the code...

The speed value that you receive in an MCI packet isn't a normal unit that you would deal with. By converting it into m/s (metres per second), you then know how far the person has travelled in the last second (MCI packets arrive once every second). To convert LFS speed units into m/s, use this:

float SpeedMS = ((MCI.Info[index].Speed / 32768f) * 100f);

I don't know what you want the code for, so I can't advise on the next part. But if you are making a total distance counter, you can then add this onto it...

Distance += SpeedMS;

#36 - XmaX
private void MCI(Packets.IS_MCI MCI)
{

float mph = mps * 2.2369362920544f;
float kph = mps * 3.6f;

// Convert X, Y and Z into meters.
float currentX = x / 65536f;
float currentY = y / 65536f;
float currentZ = z / 65536f;

// Figure out how many meters we have moved since the previous MCI packet was received.
float distanceX = currentX - previousX;
float distanceY = currentY - previousY;
float distanceZ = currentZ - previousZ;
double metersTravelled = Math.Sqrt((distanceX * distanceX) + (distanceY * distanceY) + (distanceZ * distanceZ));


// Convert the total into MPH/KPH...
double kilometersTravelled = totalMetersTravelled / 1000;
double milesTravelled = totalMetersTravelled / 1609.344;

// Convert speed into meters per second.
float mps = (speed / 32768f) * 100f;
// Add this to our total.
totalMetersTravelled += metersTravelled.;
}
}
}

What i do wrong? Get always one error <.<
I'm doing a Total distance button

I mean how do I put that information into a button?
#38 - XmaX
hmm good question. I wait for the answer too :P
Erm...send a button with it as the text? It's no different to sending a normal text button...
Quote from XmaX :
private void MCI(Packets.IS_MCI MCI)
{

float mph = mps * 2.2369362920544f;
float kph = mps * 3.6f;

// Convert X, Y and Z into meters.
float currentX = x / 65536f;
float currentY = y / 65536f;
float currentZ = z / 65536f;

// Figure out how many meters we have moved since the previous MCI packet was received.
float distanceX = currentX - previousX;
float distanceY = currentY - previousY;
float distanceZ = currentZ - previousZ;
double metersTravelled = Math.Sqrt((distanceX * distanceX) + (distanceY * distanceY) + (distanceZ * distanceZ));


// Convert the total into MPH/KPH...
double kilometersTravelled = totalMetersTravelled / 1000;
double milesTravelled = totalMetersTravelled / 1609.344;

// Convert speed into meters per second.
float mps = (speed / 32768f) * 100f;
// Add this to our total.
totalMetersTravelled += metersTravelled.;
}
}
}

What i do wrong? Get always one error <.<

The code was just a generic example, you can't just copy and paste it into your own program, you will need to rewrite it for your own purposes.
#41 - XmaX
Quote from dougie-lampkin :Erm...send a button with it as the text? It's no different to sending a normal text button...

Yes thats not the problem but how make in the button the distance ?
Well, the distance is set soemwhere as a variable. If you need one for every player, you can make a new variable in the connection list (ClsConnection.cs in 1.1.0+), and then you can access it through:

Connections[GetConnIdx(UCID)].VARIABLENAME

#43 - XmaX
Hmm i dont understand. Must i do a new .cs?
No, the Clients.cs contains the variables found in Connections[GetConnIdx..., so you can add a new one there that can contain a player's distance...
This is just confusing Any chance you could unblock me on MSN so we can talk?
2

FGED GREDG RDFGDR GSFDG