addElementDataSubscriber
Server
Subscribes a player to an element data key set with the "subscribe" sync mode. The player receives the current value at once and every change after that.
bool addElementDataSubscriber(element element, string key, player player)
Parameters
| Name | Type | Description |
|---|---|---|
| element | element | The element holding the data. |
| key | string | The data's key. Keys longer than 128 characters are cut, with a warning. |
| player | player | The player who starts receiving the data. |
Returns
true if the player was subscribed. false if the element has no data under that key, the data was not set with "subscribe", or the player is already subscribed.
Example
addEventHandler("onPlayerJoin", root, function()
setElementData(source, "money", 500, "subscribe")
addElementDataSubscriber(source, "money", source)
end)