M MY Multiplayer: Wiki
Side
Kind

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

NameTypeDescription
elementelementThe element holding the data.
keystringThe data's key. Keys longer than 128 characters are cut, with a warning.
playerplayerThe 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)

See also