getElementPosition
Client-side
Server-side
Shared
Pair: setElementPosition
This function allows you to retrieve the position coordinates of an element. This can be any real world element, including:
OOP Syntax Help! I don't understand this!
- Method: element:getPosition(...)
- Variable: .position
Syntax
float, float, float getElementPosition ( element theElement )
Required Arguments
- theElement: The element which you'd like to retrieve the position of.
Returns
- float: x
- float: y
- float: z
Returns three floats indicating the position of the element, x, y and z respectively.
Code Examples
This example will print the player position to chat using /pos command.
function whatsMyPosition() -- get the position of local player local fX, fY, fZ = getElementPosition(localPlayer);
-- output it to chat outputChatBox("My current position is X: "..fX.." Y: "..fY.." Z: "..fZ);endaddCommandHandler("pos", whatsMyPosition);
This example will teleport the player 50 units above current position using /tpme command.
function teleportMePlease(uPlayer) -- get the position from the player executing the command local fX, fY, fZ = getElementPosition(uPlayer);
-- set player position 50 units higher setElementPosition(uPlayer, fX, fY, fZ + 50);endaddCommandHandler("tpme", teleportMePlease);
See Also
Element Functions
- getElementPosition
- setElementHealth
- getElementHealth
- setElementPosition