GetPlayerVelocity

From SA-MP Wiki

Jump to: navigation, search

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.


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.


ReturnsThe 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.

Personal tools