SetElementData: Difference between revisions
(Correct newly added note) |
Tag: Undo |
||
Line 12: | Line 12: | ||
{{New items|5.0154|1.5.8|A subscription mode has been introduced for [[setElementData]] serverside. When setting data in subscription mode, only clients that are added through [[addElementDataSubscriber]] will receive the data. | {{New items|5.0154|1.5.8|A subscription mode has been introduced for [[setElementData]] serverside. When setting data in subscription mode, only clients that are added through [[addElementDataSubscriber]] will receive the data. | ||
Note this mode only works when setting element data serverside. Setting data clientside | Note this mode only works when setting element data serverside. Setting data clientside still sends the update to all clients if 'synchronize' is set to true. | ||
}} | }} | ||
Revision as of 20:59, 2 July 2020
This function stores element data under a certain key, attached to an element. Element data set using this is then synced with all clients and the server. The data can contain server created elements, but you should avoid passing data that is not able to be synced such as xmlnodes, acls, aclgroups etc.
As element data is synced to all clients, it can generate a lot of network traffic and be heavy on performance. Events are much more efficient for sending data from a client to the server only, or from the server to a specific client.
Usage of element data should be disencouraged where your goal can be achieved with events like above, and tables for storing and retrieving data.
Tip: A simple and efficient way to make a variable known to the server and clients is to use setElementData on the root element. |
Syntax
bool setElementData ( element theElement, string key, var value [, bool synchronize = true ] )
OOP Syntax Help! I don't understand this!
- Method: element:setData(...)
- Counterpart: getElementData
Required Arguments
- theElement: The element you wish to attach the data to.
- key: The key you wish to store the data under. (Maximum 31 characters.)
- value: The value you wish to store. See element data for a list of acceptable datatypes.
Optional Arguments
- synchronize: Determines whether or not the data will be synchronized with the clients(server-side variation) or server(client-side variation)
Returns
Returns true if the data was set succesfully, false otherwise.
Issues
Issue ID | Description |
---|---|
#7389 | [Fixed in 1.3.5-7389] Problem with floating numbers |
Example
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