GetVehicleVelocity

From SA-MP Wiki

Jump to: navigation, search


GetVehicleVelocity was added in SA-MP 0.3a This function was added in SA-MP 0.3a and will not work in earlier versions!


Gets the velocity at which the vehicle is moving in the three directions, X, Y and Z.


Parameters:
(vehicleid, &Float:x, &Float:y, &Float:z)
vehicleidThe vehicle to get the velocity of.
&Float:xThe Float variable to save the velocity in the X direction to.
&Float:yThe Float variable to save the velocity in the Y direction to.
&Float:zThe Float variable to save the velocity in the Z direction to.


ReturnsThe function itself doesn't return a specific value. The X, Y and Z velocities are stored in the referenced variables.


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.

Personal tools