GetElementPosition: Difference between revisions
Jump to navigation
Jump to search
m (→Example) |
m (|) |
||
(7 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
{{Server client function}} | |||
__NOTOC__ | __NOTOC__ | ||
The getElementPosition function allows you to retrieve the position coordinates of an element. This can be any real world element, including: | |||
* [[Element/Player|Players]] | |||
* [[Element/Vehicle|Vehicles]] | |||
* [[Element/Object|Objects]] | |||
* [[Element/Pickup|Pickups]] | |||
* [[Element/Marker|Markers]] | |||
* [[Element/Collision shape|Collision shapes]] | |||
* [[Element/Blip|Blips]] | |||
* [[Element/Radar area|Radar areas]] | |||
==Syntax== | ==Syntax== | ||
Line 6: | Line 15: | ||
float, float, float getElementPosition ( element theElement ) | float, float, float getElementPosition ( element theElement ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[element]]:getPosition|position|setElementPosition}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theElement:''' The element | *'''theElement:''' The element which you'd like to retrieve the location of | ||
===Returns=== | ===Returns=== | ||
Returns three | Returns three ''float''s indicating the position of the element, ''x'', ''y'' and ''z'' respectively. | ||
==Example== | ==Example== | ||
This example attaches a samsite on the player's vehicle. | |||
This example attaches a samsite on the | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- create the elegy; | -- create the elegy; | ||
myElegy = createVehicle ( 562, 1591.596680, -2495.323242, 18.098244 ) | |||
-- get the | -- get the vehicle's position; | ||
local x,y,z = getElementPosition( | local x,y,z = getElementPosition( myElegy ) | ||
-- | -- create the samsite; | ||
samsite = createObject ( 3267, x, y, z + 3 ) | samsite = createObject ( 3267, x, y, z + 3 ) | ||
-- attach the samsite to the elegy; | -- attach the samsite to the elegy; | ||
attachElementToElement ( samsite, | attachElementToElement ( samsite, myElegy, 0, 0, 0 ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Element functions}} | {{Element functions}} | ||
[[de:GetElementPosition]] |
Revision as of 03:36, 1 January 2015
The getElementPosition function allows you to retrieve the position coordinates of an element. This can be any real world element, including:
Syntax
float, float, float getElementPosition ( element theElement )
OOP Syntax Help! I don't understand this!
- Method: element:getPosition(...)
- Variable: .position
- Counterpart: setElementPosition
Required Arguments
- theElement: The element which you'd like to retrieve the location of
Returns
Returns three floats indicating the position of the element, x, y and z respectively.
Example
This example attaches a samsite on the player's vehicle.
-- create the elegy; myElegy = createVehicle ( 562, 1591.596680, -2495.323242, 18.098244 ) -- get the vehicle's position; local x,y,z = getElementPosition( myElegy ) -- create the samsite; samsite = createObject ( 3267, x, y, z + 3 ) -- attach the samsite to the elegy; attachElementToElement ( samsite, myElegy, 0, 0, 0 )
See Also
- addElementDataSubscriber
- clearElementVisibleTo
- cloneElement
- getAllElementData
- getElementSyncer
- getElementZoneName
- hasElementDataSubscriber
- isElementVisibleTo
- removeElementData
- removeElementDataSubscriber
- setElementSyncer
- setElementVisibleTo
Shared
- attachElements
- createElement
- destroyElement
- detachElements
- getAttachedElements
- getElementAlpha
- getElementAttachedOffsets
- getElementAttachedTo
- getElementByIndex
- getElementByID
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementCollisionsEnabled
- getElementColShape
- getElementData
- getAllElementData
- hasElementData
- getElementDimension
- getElementHealth
- getElementID
- getElementInterior
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRotation
- getElementsByType
- getElementsWithinColShape
- getElementsWithinRange
- getElementType
- getElementVelocity
- getLowLODElement
- getRootElement
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLowLOD
- isElementWithinColShape
- isElementWithinMarker
- setElementAlpha
- setElementAngularVelocity
- getElementAngularVelocity
- setElementAttachedOffsets
- setElementCallPropagationEnabled
- setElementCollisionsEnabled
- setElementData
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementModel
- setElementParent
- setElementPosition
- setElementRotation
- setElementVelocity
- setLowLODElement
- getPedContactElement
- getResourceDynamicElementRoot
- getResourceRootElement