Description
Adds a multiplayer event handler (EH) to the given object and returns EH handle. See Event Handlers.
Important
A Multiplayer Event Handler is not saved in a save file and therefore will not be restored on load - use it accordingly.
Syntax
object addMPEventHandler [type, expression]
Parameters:
-
object: Object - object to monitor -
type: String - event handler name -
expression: String or Code - expression to execute.If EH has some data to return upon event (e.g. the "MPKilled" EH will return an array with 2 elements: the killed unit, and the killer), it is passed in
_thisvariable.Note
Arma 3: Since Arma 3 v.1.64 the EH handle is also stored in
_thisEventHandlervariable and is available during EH code execution.- Event Handler parameters are accessible via
_this - The Event Handler type is available as
_thisEvent - The Event Handler index is available as
_thisEventHandler
- Event Handler parameters are accessible via
Returns: Number - event handler index
Examples
Example 1
_index = player addMPEventHandler ["MPKilled", { _this execVM "playerKilled.sqf"; }];
Multiplayer
Multiplayer EHs are added globally to every client and the server will fire on itself and every client upon event. The only exception is the MPRespawn EH that one only fires where the respawned unit is local. Make sure to check the EHs' locality in Event Handlers pages.
See also
removeMPEventHandler · removeAllMPEventHandlers · getEventHandlerInfo