From SA-MP Wiki

Jump to: navigation, search

SetPlayerVelocity was added in SA-MP 0.3a This function was added in SA-MP 0.3a and will not work in earlier versions!


Set a player's velocity on the X, Y and Z axes.

(playerid, Float:X, Float:Y, Float:Z)
playeridThe player to apply the speed to.
Float:XThe velocity (speed) on the X axis.
Float:YThe velocity (speed) on the Y axis.
Float:ZThe velocity (speed) on the Z axis.

Return Values:

  • 1: The function was executed successfully.
  • 0: The function failed to execute. This means the player is not connected.

Example Usage:

public OnPlayerCommandText(playerid, cmdtext[])
    if (!strcmp("/jump", cmdtext))
	SetPlayerVelocity(playerid, 0.0, 0.0, 0.2); // Forces the player to jump (Z velocity + 0.2)
	return 1;
    return 0;

Related Functions

The following functions may be helpful as they relate to this function in one way or another.

In other languages