GetPlayerVelocity
From SA-MP Wiki
GetPlayerVelocity
Warning: This function was added in SA-MP version 0.3. It is not available in previous versions.
Gets the velocity at which the player is moving in the three directions, X, Y and Z. This can be useful for speedometers.
(playerid, &Float:x, &Float:y, &Float:z)
| playerid | The player to get the speed from. |
| &Float:x | The float to store the X velocity in, passed by reference. |
| &Float:y | The float to store the Y velocity in, passed by reference. |
| &Float:z | The float to store the Z velocity in, passed by reference. |
| Returns | The function itself doesn't return a specific value. The X, Y and Z velocities are stored in the specified variables. |
public OnPlayerCommandText(playerid, cmdtext[]) { if (!strcmp("/velocity", cmdtext)) { new Float:Velocity[3], string[80]; GetPlayerVelocity(playerid, Velocity[0], Velocity[1], Velocity[2]); format(string, sizeof(string), "You are going at a velocity of X: %f, Y: %f, Z: %f", Velocity[0], Velocity[1], Velocity[2]); SendClientMessage(playerid, 0xFFFFFFFF, string); return 1; } }
Related Functions
The following functions might be useful as well, as they're related to this function in one way or another.
- SetPlayerVelocity: Set a player's velocity.
- SetVehicleVelocity: Set a vehicle's velocity.
- GetVehicleVelocity: Get a vehicle's velocity.
