SetElementVelocity: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Updated the page according to r6658)
Line 3: Line 3:
This function sets the velocity (movement speeds) along each axis, for an element.
This function sets the velocity (movement speeds) along each axis, for an element.


This is not compatible with all elements. The following elements are compatible:
This is not compatible with all elements. Only the following elements are compatible:
* [[Ped]]s
* [[Ped]]s.
* [[Vehicle]]s
* [[Vehicle]]s.
* [[Object]]s (Clientside only)
* [[Object]]s.
* [[Projectile]]s (Clientside only)
* [[Projectile]]s.
 
{{Deprecated feature|3.0140|1.4|
Objects and projectiles' velocity can only be set clientside.}}


==Syntax==
==Syntax==

Revision as of 11:44, 9 July 2014

This function sets the velocity (movement speeds) along each axis, for an element.

This is not compatible with all elements. Only the following elements are compatible:

Syntax

bool setElementVelocity ( element theElement, float speedX, float speedY, float speedZ )

Required Arguments

  • theElement: The element you wish to set the velocity of.
  • speedX: A floating point value determining the speed along the X axis.
  • speedY: A floating point value determining the speed along the Y axis.
  • speedZ: A floating point value determining the speed along the Z axis.

Returns

Returns true if the speed was set successfully, false if a bad element was specified or other bad arguments.

Example

This example 'copies' the speed of a specific player (called someguy in this example) to another player (called Ted in this example).

local randomPlayer = getRandomPlayer()
speedx, speedy, speedz = getElementVelocity (randomPlayer) -- get the velocity of the player named "someguy"
setElementVelocity (randomPlayer , speedx, speedy, speedz )      -- copy the velocity to a player named "Ted"

See Also