The "Real" vehicle speed thread
#34

I've taken care of that issue and here is my solution:

I used the LS airport runway and mapped 100 of them behind each other above the sea to get a perfectly flat, long straight road. I placed the Infernus at the beginning of the track and ran this code:

pawn Код:
new Float:oldvel;
new Float:startX, Float:startY, Float:startZ;
new Float:endX, Float:endY, Float:endZ;

//This function is called every 250 milliseconds (4 times a second)
public Speedo(playerid)
{
    new Float:newX, Float:newY, Float:newZ;
    if(IsPlayerInAnyVehicle(playerid)) //Player is inside a vehicle
    {
        GetVehicleVelocity(GetPlayerVehicleID(playerid), newX, newY, newZ); //Gets the X Y and Z velocity of the vehicle
        new Float:newvel = floatsqroot(floatmul(newX, newX) + floatmul(newY, newY) + floatmul(newZ, newZ)); //Calculates the velocity of the vehicle
        if(newvel > oldvel) //The newly recorded velocity is bigger than the perviously recorded velocity (At the very beginning oldvel is 0.0 obviously).
        {
            new msg[128];
            format(msg, sizeof(msg), "Velocity: %.4f", newvel);
            oldvel = newvel; //The old velocity is new the newly recorded velocity. This is saved to use the value again the next time the velocity is checked
            SendClientMessage(playerid, -1, msg);
        }
        else if(newvel <= oldvel) //The newly recorded velocity is smaller or equal to the previously recorded velocity, which means the vehicle topped out and will not gain any more velocity. It's arrived at it's topspeed
        {
            KillTimer(timer); //The timer is stopped
            timetimer = SetTimerEx("Time", 1000, false, "i", playerid); //Sets up a timer that calls "Time" after 1 second.
            GetPlayerPos(playerid, startX, startY, startZ); //Saves the position of the vehicle
            SendClientMessage(playerid, -1, "Starting to record");
           
        }
    }
    return 1;
}

public Time(playerid)
{
    GetPlayerPos(playerid, endX, endY, endZ); //Saves the new position of the vehicle (1 second after it was saved the first time)
    new Float:distance = floatsub(startX, endX); //Calculates the distance between the 1st and 2nd saved position of the vehicle. I can simply subtract the X coordinates because the vehicle drove perfectly parallel to the X-axis.
    //We now have the distance the vehicle travelled in 1 second with topped out speed (max. velocity). The unit is m/s
    new Float:speed = floatmul(distance, 3.6); //Converts m/s in km/h
    new msg[128];
    format(msg, 128, "You travelled %.4f m in 1 second, that makes %.4f km/h", distance, speed);
    SendClientMessage(playerid, -1, msg);
    KillTimer(timetimer);
    return 1;
}
What I basically did is I accelerated the Infernus until it didn't get any faster. I then saved it's position and did it again after 1 second. I can now calculate the distance the vehicle travelled in this second. Since the GTA: SA distance unit is meter, the unit is m/s.
Having this done, the Infernus topped at 247.5km/h.
For the sake of it I also tested the DFT-30 and Rumpo. They topped out at 145km/h and 122km/h, which, to be fair, seems pretty legit to me.

Dividing max. velocity/associated speed gives me ~199, which pretty much confirms previous calculations here.
Which leads to: Speed in km/h = sqrt(max X velocity^2 + max Y velocity^2 + max Z velocity^2) * 199
To get an accurate value all vehicles should be tested though.
Reply


Messages In This Thread
The "Real" vehicle speed thread - by Sinner - 29.07.2012, 17:54
Re: The "Real" vehicle speed thread - by Arca - 29.07.2012, 20:13
Re: The "Real" vehicle speed thread - by Sinner - 30.07.2012, 07:31
Re: The "Real" vehicle speed thread - by Mauzen - 30.07.2012, 09:34
Re: The "Real" vehicle speed thread - by Vince - 30.07.2012, 12:06
Re: The "Real" vehicle speed thread - by playbox12 - 06.08.2012, 18:23
Re: The "Real" vehicle speed thread - by Joe Staff - 06.08.2012, 20:03
Re: The "Real" vehicle speed thread - by Vince - 06.08.2012, 21:14
Respuesta: The "Real" vehicle speed thread - by zugg48 - 12.08.2012, 09:07
Re: Respuesta: The "Real" vehicle speed thread - by Mauzen - 14.08.2012, 23:56
Respuesta: The "Real" vehicle speed thread - by zugg48 - 17.09.2012, 03:00
Re: The "Real" vehicle speed thread - by [ABK]Antonio - 17.09.2012, 08:59
Re: The "Real" vehicle speed thread - by Edix - 02.08.2013, 12:06
Re: The "Real" vehicle speed thread - by Konstantinos - 02.08.2013, 12:13
Re: The "Real" vehicle speed thread - by [ABK]Antonio - 02.08.2013, 18:17
Re: The "Real" vehicle speed thread - by Pottus - 04.08.2013, 17:47
Re: The "Real" vehicle speed thread - by -Prodigy- - 04.08.2013, 18:53
Re: The "Real" vehicle speed thread - by Kar - 04.08.2013, 18:55
Re: The "Real" vehicle speed thread - by -Prodigy- - 04.08.2013, 18:57
Re: The "Real" vehicle speed thread - by Kar - 04.08.2013, 19:00
Re: The "Real" vehicle speed thread - by Pottus - 04.08.2013, 19:52
Re: The "Real" vehicle speed thread - by Mauzen - 05.08.2013, 00:47
Re: The "Real" vehicle speed thread - by Edix - 07.08.2013, 01:59
Re: The "Real" vehicle speed thread - by Pottus - 07.08.2013, 04:53
Re: The "Real" vehicle speed thread - by Edix - 07.08.2013, 12:05
Re: The "Real" vehicle speed thread - by Pottus - 07.08.2013, 17:29
Re: The "Real" vehicle speed thread - by sgoten - 13.08.2013, 10:13
Re: The "Real" vehicle speed thread - by Edix - 13.08.2013, 19:00
Re: The "Real" vehicle speed thread - by Pottus - 13.08.2013, 20:38
Re: The "Real" vehicle speed thread - by Pottus - 13.08.2013, 23:56
Re: The "Real" vehicle speed thread - by Edix - 14.08.2013, 10:10
Re: The "Real" vehicle speed thread - by Mauzen - 14.08.2013, 11:03
Re: The "Real" vehicle speed thread - by Pottus - 14.08.2013, 19:24
AW: The "Real" vehicle speed thread - by Drebin - 04.09.2013, 01:38
Re: The "Real" vehicle speed thread - by Squash - 09.09.2013, 05:20
Re: The "Real" vehicle speed thread - by Pottus - 09.09.2013, 05:27
Re: The "Real" vehicle speed thread - by Squash - 09.09.2013, 05:50
Re: The "Real" vehicle speed thread - by Pottus - 09.09.2013, 06:14
Re: The "Real" vehicle speed thread - by Squash - 09.09.2013, 06:53
Re: The "Real" vehicle speed thread - by Pottus - 09.09.2013, 07:03
Re: The "Real" vehicle speed thread - by Cypog - 13.09.2013, 21:05
Re: The "Real" vehicle speed thread - by Pottus - 13.09.2013, 23:14
Re: The "Real" vehicle speed thread - by Kimossab - 08.11.2013, 22:23
Re: The "Real" vehicle speed thread - by Pottus - 09.11.2013, 04:04
Re: The "Real" vehicle speed thread - by PowerPC603 - 09.02.2014, 20:51
Re: The "Real" vehicle speed thread - by Pottus - 10.02.2014, 00:34
Re: The "Real" vehicle speed thread - by Anzipane - 09.03.2014, 18:04
Re: The "Real" vehicle speed thread - by Pottus - 09.03.2014, 18:50
Re: The "Real" vehicle speed thread - by VerticalGaming - 09.04.2014, 09:36
Re: The "Real" vehicle speed thread - by VerticalGaming - 09.04.2014, 11:57
Respuesta: The "Real" vehicle speed thread - by Siralos - 08.08.2014, 09:02
Re: Respuesta: The "Real" vehicle speed thread - by [XST]O_x - 08.08.2014, 10:15
Respuesta: Re: Respuesta: The "Real" vehicle speed thread - by Siralos - 08.08.2014, 10:50
Re: The "Real" vehicle speed thread - by Kar - 08.08.2014, 16:56
Re: The "Real" vehicle speed thread - by Pottus - 09.08.2014, 15:59
Re: The "Real" vehicle speed thread - by Kar - 09.08.2014, 16:21
Re: The "Real" vehicle speed thread - by Pottus - 09.08.2014, 17:35
Re: The "Real" vehicle speed thread - by Kar - 09.08.2014, 17:45
Re: The "Real" vehicle speed thread - by Kar - 11.08.2014, 17:31
Re: The "Real" vehicle speed thread - by n0minal - 30.12.2014, 16:41
Re: The "Real" vehicle speed thread - by Kimossab - 30.12.2014, 17:14
Re: The "Real" vehicle speed thread - by n0minal - 30.12.2014, 18:44
Re: Respuesta: The "Real" vehicle speed thread - by eikzdej - 30.03.2016, 08:38
Re: Respuesta: The "Real" vehicle speed thread - by RyanKingstone - 10.06.2016, 09:01
Re: The "Real" vehicle speed thread - by Crayder - 03.09.2016, 12:13
Re: The "Real" vehicle speed thread - by AmigaBlizzard - 19.05.2018, 10:36

Forum Jump:


Users browsing this thread: 7 Guest(s)