Vehicle speed
#7

Here's what I use in my GM to get the vehicle speed in both MPH and KPH (please note that I use a player variable which holds that information, so I only use one of the two), and I'd say its enough optimized, and precise for what I use it to.
pawn Код:
#define MPH_KMH 1.609344

stock GetVehicleSpeed( vehicleid )
{
    // Function: GetVehicleSpeed( vehicleid )
   
    new
        Float:x,
        Float:y,
        Float:z,
        vel;

    GetVehicleVelocity( vehicleid, x, y, z );

    vel = floatround( floatsqroot( x*x + y*y + z*z ) * 180 );           // KM/H
//  vel = floatround( floatsqroot( x*x + y*y + z*z ) * 180 / MPH_KMH ); // MPH

    return vel;
}
Reply


Messages In This Thread
Vehicle speed - by Scenario - 14.01.2012, 22:18
Re: Vehicle speed - by Jakku - 14.01.2012, 22:20
Re: Vehicle speed - by Laronic - 14.01.2012, 22:20
Re: Vehicle speed - by Steven82 - 14.01.2012, 22:21
Re: Vehicle speed - by Scenario - 14.01.2012, 22:21
Re: Vehicle speed - by iTorran - 14.01.2012, 22:36
Re: Vehicle speed - by Virtual1ty - 14.01.2012, 22:40
Re: Vehicle speed - by Scenario - 14.01.2012, 23:21

Forum Jump:


Users browsing this thread: 2 Guest(s)