RemoveElementData: Difference between revisions
Jump to navigation
Jump to search
m (→Syntax: OOP) |
m (→See Also) |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 2: | Line 2: | ||
__NOTOC__ | __NOTOC__ | ||
This function removes the [[element data]] with the given key for that element. The element data removal is synced with all the clients. | This function removes the [[element data]] with the given key for that element. The element data removal is synced with all the clients. | ||
{{Note|If you want to remove the data in client side you can use 'setElementData(element, key, nil)'.}} | |||
==Syntax== | ==Syntax== | ||
Line 7: | Line 9: | ||
bool removeElementData ( element theElement, string key ) | bool removeElementData ( element theElement, string key ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP| | {{OOP||[[element]]:removeData||}} | ||
===Required Arguments=== | ===Required Arguments=== | ||
Line 17: | Line 19: | ||
==Example== | ==Example== | ||
This will | This will set element data for player which spawned, and then remove it on death. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function | function onPlayerSpawn() | ||
setElementData(source," | setElementData(source, "playerSpawned", true) | ||
end | end | ||
addEventHandler ( "onPlayerSpawn", | addEventHandler("onPlayerSpawn", root, onPlayerSpawn) | ||
function | |||
removeElementData(source," | function onPlayerWasted() | ||
removeElementData(source, "playerSpawned") | |||
end | end | ||
addEventHandler ( "onPlayerWasted", | addEventHandler("onPlayerWasted", root, onPlayerWasted) | ||
</syntaxhighlight> | |||
==See Also== | ==See Also== | ||
{{Element_functions}} | {{Element_functions|server}} |
Latest revision as of 22:32, 6 September 2024
This function removes the element data with the given key for that element. The element data removal is synced with all the clients.
Syntax
bool removeElementData ( element theElement, string key )
OOP Syntax Help! I don't understand this!
- Method: element:removeData(...)
Required Arguments
- theElement: The element you wish to remove the data from.
- key: The key string you wish to remove.
Returns
Returns true if the data was removed succesfully, false if the given key does not exist in the element or the element is invalid.
Example
This will set element data for player which spawned, and then remove it on death.
function onPlayerSpawn() setElementData(source, "playerSpawned", true) end addEventHandler("onPlayerSpawn", root, onPlayerSpawn) function onPlayerWasted() removeElementData(source, "playerSpawned") end addEventHandler("onPlayerWasted", root, onPlayerWasted)
See Also
- addElementDataSubscriber
- clearElementVisibleTo
- cloneElement
- 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