SetElementPosition: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 34: Line 34:
addCommandHandler ( "setpos", consoleSetPlayerPosition  )
addCommandHandler ( "setpos", consoleSetPlayerPosition  )
</syntaxhighlight>
</syntaxhighlight>
</section>
<section name="Example 3" class="server" show="false">
<section name="Example 3" class="server" show="false">
This example enables a player to type /warpto <playername> to warp to them. If the player being warped to is in a vehicle with a free passenger seat, it will warp into the vehicle.
This example enables a player to type /warpto <playername> to warp to them. If the player being warped to is in a vehicle with a free passenger seat, it will warp into the vehicle.

Revision as of 15:41, 26 August 2007

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

Syntax

bool setElementPosition ( element theElement, float x, float y, float z )  

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.

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  )

<section name="Example 2" class="client" show="false"> This example adds a "setpos" command to console, which allows setting of the local player's position.

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

See Also