The online racing simulator
C++ - CInsim - A basic C++ InSim library
(157 posts, started )
How can I do to add that tells you the time from 0 to 100 km / h?
I'm not sure the language this script uses. I just came to the last page to see the last post, to be honest.

To calculate user acceleration, you need to know the time between 0 and 100 (obvious =)).

Below I will give you an example about how I calculate it:


if (C.PosSpeed > 1 && C.OutPits == 1)
{
C.AccTimer += 100;
}

if (C.PosSpeed >= 100 && C.AccStage == 0)
{
C.AccStage = 1;
double Aceleracao = ((C.AccTimer * 100.0) / C.PosSpeed) / 1000;
InSim.Send_MTC_MessageToConnection("^3› ^7Aceleração 0-100: ^3" + Math.Round(Aceleracao, 1) + "^7 segundos", C.UniqueID, 0);
}



Explanation:

This script is inside a 100ms timer. So, every 100ms, it add 100 to a specific player's variable (AccTimer += 100).

Then, when the player reaches 100Km/H (PosSpeed >= 100), it calculates the time player took to reach 100, considering actual speed (because the speed can be 105 for example on the actual scan).

For example, on the actual scan, the user speed is 110 Km/H and the AccTimer is 600.

So, it means the user reach 110 in 600ms. On the proportion: ((600 * 100) / 110) / 1000 = 0,54545454...

Finally, I do a math.round to remove digits after the coma. The result in the case above will be 0,5 seconds.

I tried to explain everything, and it may be useful for other players. But I hope I answered your question Wink
Quote from Skinzinho :I'm not sure the language this script uses. I just came to the last page to see the last post, to be honest.

To calculate user acceleration, you need to know the time between 0 and 100 (obvious =)).

Below I will give you an example about how I calculate it:


if (C.PosSpeed > 1 && C.OutPits == 1)
{
C.AccTimer += 100;
}

if (C.PosSpeed >= 100 && C.AccStage == 0)
{
C.AccStage = 1;
double Aceleracao = ((C.AccTimer * 100.0) / C.PosSpeed) / 1000;
InSim.Send_MTC_MessageToConnection("^3› ^7Aceleração 0-100: ^3" + Math.Round(Aceleracao, 1) + "^7 segundos", C.UniqueID, 0);
}



Explanation:

This script is inside a 100ms timer. So, every 100ms, it add 100 to a specific player's variable (AccTimer += 100).

Then, when the player reaches 100Km/H (PosSpeed >= 100), it calculates the time player took to reach 100, considering actual speed (because the speed can be 105 for example on the actual scan).

For example, on the actual scan, the user speed is 110 Km/H and the AccTimer is 600.

So, it means the user reach 110 in 600ms. On the proportion: ((600 * 100) / 110) / 1000 = 0,54545454...

Finally, I do a math.round to remove digits after the coma. The result in the case above will be 0,5 seconds.

I tried to explain everything, and it may be useful for other players. But I hope I answered your question Wink

Thanks for the help, but it did not work for me. :/
Hello, I am trying to fix one project using InSim but cant get it built. Tried your event control project for the reference but just cant build it either. (I even downloaded codeblocks to have the least IDE work but somehow there is still a lot of IDE/compiler work to just build it)

Iam using:
-Win 10
-code::blocks
-MinGW using TDM32 installer

I am getting problems around pthread. I am getting warnings of redefined pthread.h definitions as there is one pthread / libpthreadGC2.a related to project and one in search directory of compiler. it looks like it always conflicts. Conflicting struct definitions result in errors

How you setup your compiler / IDE to compile your projects?

Thank you.
pthread library bundled with Event Control is outdated and unnecessary. Development toolchain that comes with CodeBlocks should include a working pthread library. Just use that one and you should be good to go.
Thanks. It really works without that.

I deleted linking of libpthreadGC2.a
pthread.h

And it builts and works. Great!

C++ - CInsim - A basic C++ InSim library
(157 posts, started )
FGED GREDG RDFGDR GSFDG