open.mp | GetVehicleVelocity
  • Home
  • FAQ
  • Forum
  • Servers
  • Docs
  • Blog
  • Login
  • Englishاللغة العربيةar-TNবাংলাbosanski jezikDeutschΕλληνικάEspañoleestiفارسیFrançaisHrvatskimagyarBahasa IndonesiaItaliano日本語ქართულიlietuvių kalbaNederlandsNorskjęzyk polskiPortuguêsRomânăРусскийslovenski jezikсрпски језикไทยWikang TagalogTürkçeУкраїнськаاردوTiếng Việt简体中文繁體中文
warning Not Translated

This page has not been translated into the language that your browser requested. The English content is being shown as a fallback.

If you want to contribute a translation for this page then please click here.

GetVehicleVelocity

warning

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

Description

Get the velocity of a vehicle on the X, Y and Z axes.

NameDescription
vehicleidThe ID of the vehicle to get the velocity of.
&Float:xA float variable in to which to store the vehicle's X velocity, passed by reference.
&Float:yA float variable in to which to store the vehicle's Y velocity, passed by reference.
&Float:zA float variable in to which to store the vehicle's Z velocity, passed by reference.

Returns

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: vehVelocity[3],
            clientMessage[80];

        GetVehicleVelocity(GetPlayerVehicleID(playerid), vehVelocity[0], vehVelocity[1], vehVelocity[2]);
        format(clientMessage, sizeof(clientMessage), "You are going at a velocity of X%f, Y%f, Z%f", vehVelocity[0], vehVelocity[1], vehVelocity[2]);
        SendClientMessage(playerid, 0xFFFFFFFF, clientMessage);
        return 1;
    }
    return 0;
}

Notes

tip

This function can be used to retrieve a vehicle's speed (km/h, m/s or mph). For more info look here.

Related Functions

  • GetPlayerVelocity: Get a player's velocity.
  • SetVehicleVelocity: Set a vehicle's velocity.
  • SetPlayerVelocity: Set a player's velocity.

Community

  • Discord
  • Instagram
  • Twitter
  • Twitch
  • YouTube
  • Facebook
  • VK

More

  • SA-MP
  • Blog
  • GitHub