SetElementPosition: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
m (→‎Syntax: OOP)
Line 12: Line 12:
bool setElementPosition ( element theElement, float x, float y, float z [, bool warp = true ] )   
bool setElementPosition ( element theElement, float x, float y, float z [, bool warp = true ] )   
</syntaxhighlight>  
</syntaxhighlight>  
{{OOP|This function is also a static function underneath the Element class.|[[element]]:setPosition|position|}}


===Required Arguments===  
===Required Arguments===  

Revision as of 16:43, 16 August 2014

This function sets the position of an element to the specified coordinates.

Attention: Do not use this function to spawn a ped/player. It will cause problems with other functions like warpPedIntoVehicle.
Use spawnPlayer and createPed instead.

Syntax

bool setElementPosition ( element theElement, float x, float y, float z [, bool warp = true ] )  

OOP Syntax Help! I don't understand this!

Note: This function is also a static function underneath the Element class.
Method: element:setPosition(...)
Variable: .position


Required Arguments

  • theElement: A valid element to be moved.
  • x: The x coordinate of the destination.
  • y: The y coordinate of the destination.
  • z: The z coordinate of the destination.

Optional Arguments

  • warp: teleports players, resetting any animations they were doing. Setting this to false preserves the current animation.

Returns

Returns true if the function was successful, false otherwise.

Example

Click to collapse [-]
Example 1

This example adds a "setpos" command to console, which allows setting of a player's position.

function consoleSetPlayerPosition ( source, commandName, posX, posY, posZ )
	setElementPosition ( source, posX, posY, posZ )
end
addCommandHandler ( "setpos", consoleSetPlayerPosition  )
Click to expand [+]
Example 2
Click to expand [+]
Example 3

See Also