HU/setElementPosition
From Multi Theft Auto: Wiki
This function sets the position of an element to the specified coordinates.
Warning: Do not use this function to spawn a player. It will cause problems with other functions like warpPedIntoVehicle. Use spawnPlayer instead. |
Syntax
bool setElementPosition ( element theElement, float x, float y, float z [, bool warp = true ] )
OOP Syntax Help! I don't understand this!
- Method: element:setPosition(...)
- Variable: .position
- Counterpart: getElementPosition
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 1This 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 2Click to expand [+]
Example 3Issues
Issue ID | Description |
---|---|
#9522 | Setting a ped's or player's position whilst occupying a jetpack will remove their jetpack, but not the jetpack sound |
See Also
- attachElements
- clearElementVisibleTo
- cloneElement
- createElement
- destroyElement
- detachElements
- getAllElementData
- getAttachedElements
- getElementAlpha
- getElementAttachedOffsets
- getElementAttachedTo
- getElementCollisionsEnabled
- getElementByID
- getElementByIndex
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementColShape
- getElementData
- getElementDimension
- getElementHealth
- getElementID
- getElementInterior
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRotation
- getElementSyncer
- getElementType
- getElementVelocity
- getElementZoneName
- getElementsByType
- getElementsWithinColShape
- getLowLODElement
- getRootElement
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLowLOD
- isElementVisibleTo
- isElementWithinColShape
- isElementWithinMarker
- removeElementData
- setElementAlpha
- setElementAngularVelocity
- getElementAngularVelocity
- setElementAttachedOffsets
- setElementCallPropagationEnabled
- setElementCollisionsEnabled
- setElementData
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementModel
- setElementParent
- setElementPosition
- setElementRotation
- setElementSyncer
- setElementVelocity
- setElementVisibleTo
- setLowLODElement