GetElementType: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 1: | Line 1: | ||
__NOTOC__ | {{Server client function}} | ||
This function is used to retrieve the type of an | __NOTOC__ | ||
This function is used to retrieve the type of an element. | |||
==Syntax== | ==Syntax== | ||
Line 24: | Line 25: | ||
*'''"unknown":''' Unknown element type | *'''"unknown":''' Unknown element type | ||
This function will return ''false'' if ''theElement'' is invalid. | This function will return ''false'' if '''theElement''' is invalid. | ||
==Example== | ==Example== | ||
This example destroys a haystack when a player targets it | This example destroys a haystack when a player targets it | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function onPlayerTargeted ( targetElem ) | |||
-- if the targeted object is a haystack remove it from the game. | |||
if ( getElementType ( targetElem ) == "object" ) and ( getObjectModel ( targetElem ) == 3374 ) then | |||
function onPlayerTargeted ( | destroyElement ( targetElem ) | ||
-- | |||
if ( getElementType ( | |||
destroyElement ( | |||
end | end | ||
end | end | ||
addEventHandler ( "onPlayerTargeted", getRootElement(), onPlayerTargeted ) -- add above function as handler for targeting event | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Element functions}} | {{Element functions}} |
Revision as of 19:09, 19 August 2007
This function is used to retrieve the type of an element.
Syntax
string getElementType ( element theElement )
Required Arguments
- theElement: The element you wish to get the type of.
Returns
There are a total of 11 strings this function returns:
- "player": A player connected to the server
- "vehicle":: A vehicle
- "object": An object
- "pickup": A pickup
- "blip": A blip
- "marker": A marker
- "spawnpoint": A spawnpoint
- "remoteclient": A remote client connected to the server
- "colshape": A collision shape
- "console": The server Console
- "unknown": Unknown element type
This function will return false if theElement is invalid.
Example
This example destroys a haystack when a player targets it
function onPlayerTargeted ( targetElem ) -- if the targeted object is a haystack remove it from the game. if ( getElementType ( targetElem ) == "object" ) and ( getObjectModel ( targetElem ) == 3374 ) then destroyElement ( targetElem ) end end addEventHandler ( "onPlayerTargeted", getRootElement(), onPlayerTargeted ) -- add above function as handler for targeting event
See Also
- 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