GetVehicleVelocity

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 20:50, 4 September 2013
Drebin (Talk | contribs)

← Previous diff
Revision as of 01:17, 5 February 2014
Connor Mead (Talk | contribs)

Next diff →
Line 1: Line 1:
{{Scripting}} {{Scripting}}
-{{Title}} 
{{0.3Added|function|}} {{0.3Added|function|}}
Line 37: Line 36:
[[Category:Scripting Functions]] [[Category:Scripting Functions]]
 +
 +[[fr:GetVehicleVelocity]]

Revision as of 01:17, 5 February 2014



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


Description:

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.


Return Values:

The 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;
}
Tip

Image:Light_bulb_icon.png

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


Related Functions

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

In other languages