GetVehicleVelocity

GetVehicleVelocity

Description:
Function GetVehicleVelocity get the velocity of a vehicle on the X, Y and Z axes.
Function GetVehicleVelocity was added in 0.3a and will not work in earlier versions!
This function can be used to retrieve a vehicle's speed (km/h, m/s or mph). For more info look here (The link is temporarily unavailable).


Parameters:
(vehicleid, &Float:x, &Float:y, &Float:z)
int vehicleid The ID of the vehicle to get the velocity of.
float X A float variable in to which to store the vehicle's X velocity, passed by reference.
float Y A float variable in to which to store the vehicle's Y velocity, passed by reference.
float Z A float variable in to which to store the vehicle's Z velocity, passed by reference.


Return Values:
  • 1: The function was executed successfully.
  • 0: The function failed to execute. This means the vehicle specified does not exist.
  • The vehicle's velocity is stored in the specified variables.


Examples:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp("/GetMyCarVelocity", cmdtext) && IsPlayerInAnyVehicle(playerid))
    {
        new Float:Velocity[3], output[80];
	GetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0], Velocity[1], Velocity[2]);
        format(output, sizeof(output), "You are going at a velocity of X%f, Y%f, Z%f", Velocity[0], Velocity[1], Velocity[2]);
        SendClientMessage(playerid, 0xFFFFFFFF, output);
	return 1;
    }
    return 0;
}


Related Functions
The following functions may be useful, as they are related to this function in one way or another.