AddElementDataSubscriber

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

This function subscribes a player to specific element data. This function is used together with setElementData in "subscribe" mode.

[[{{{image}}}|link=|]] Note: Before using this function you need to setup an initial value of element data in "subscribe" mode, otherwise the subscriber will not be added.
[[{{{image}}}|link=|]] Note: Calling removeElementData or setElementData with other sync mode will automatically remove all subscribers of specified element data.

Syntax

bool addElementDataSubscriber ( element theElement, string key, player thePlayer )

OOP Syntax Help! I don't understand this!

Method: element:addDataSubscriber(...)
Counterpart: removeElementDataSubscriber


Required Arguments

  • theElement: The element you wish to subscribe the player to.
  • key: The key you wish to subscribe the player to.
  • thePlayer: The player you wish to subscribe.

Returns

Returns true if the player was subscribed, false otherwise.

Example

Click to collapse [-]
Server
addEventHandler("onVehicleEnter", getRootElement(), function(thePlayer, seat)
   if seat==0 then -- if the player is a driver
      addElementDataSubscriber(source, "id", thePlayer) -- subscribe the player to element
   end
end)

Requirements

Minimum server version 1.5.7-9.20477
Minimum client version n/a

Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version server="1.5.7-9.20477" />

See Also