GetPlayerVelocity

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
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



GetPlayerVelocity 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 player is moving in the three directions, X, Y and Z. This can be useful for speedometers.


Parameters:
(playerid, &Float:x, &Float:y, &Float:z)
playeridThe player to get the speed from.
&Float:xThe float to store the X velocity in, passed by reference.
&Float:yThe float to store the Y velocity in, passed by reference.
&Float:zThe 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.

In other languages