AddElementDataSubscriber: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 22: Line 22:
==Example==  
==Example==  
<section name="Server" class="server" show="true">
<section name="Server" class="server" show="true">
<syntaxhighlight>
<syntaxhighlight lang="lua">
TODO
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)
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>

Revision as of 11:34, 30 January 2021

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

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

This template will be deleted.

See Also