GetPlayerVelocity
From SA-MP Wiki
(Difference between revisions)
Revision as of 13:53, 19 February 2013 Smithy (Talk | contribs) (Russian link) ← Previous diff |
Revision as of 23:02, 31 January 2014 Connor Mead (Talk | contribs) Next diff → |
||
Line 1: | Line 1: | ||
{{Scripting}} | {{Scripting}} | ||
- | {{Title}} | ||
{{0.3Added|function|}} | {{0.3Added|function|}} | ||
Line 35: | Line 34: | ||
[[Category:Scripting Functions]] | [[Category:Scripting Functions]] | ||
+ | [[fr:GetPlayerVelocity]] | ||
[[ru:GetPlayerVelocity]] | [[ru:GetPlayerVelocity]] |
Revision as of 23:02, 31 January 2014
Description:
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. |
Return Values:
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 may be useful, as they are 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.