GetVehicleVelocity
From SA-MP Wiki
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. |
| Returns | 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; }
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.
