GetVehicleVelocity
From SA-MP Wiki
(Difference between revisions)
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
Description:
Gets the velocity at which the vehicle is moving in the three directions, X, Y and Z.
(vehicleid, &Float:x, &Float:y, &Float:z)
vehicleid | The vehicle to get the velocity of. |
&Float:x | The Float variable to save the velocity in the X direction to. |
&Float:y | The Float variable to save the velocity in the Y direction to. |
&Float:z | The 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 | 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.
- GetPlayerVelocity: Get a player's velocity.
- SetVehicleVelocity: Set a vehicle's velocity.
- SetPlayerVelocity: Set a player's velocity.