addMPEventHandler

From Bohemia Interactive Community
Revision as of 14:06, 8 November 2023 by Lou Montana (talk | contribs) (Text replacement - "(\|[pr][0-9]+ *= *[^-]+) *- *E([a-z])" to "$1 - e$2")
Jump to navigation Jump to search
Hover & click on the images for description

Description

Description:
Adds a multiplayer event handler (EH) to the given object and returns EH handle. See Event Handlers.
A Multiplayer Event Handler is not saved in a save file and therefore will not be restored on load - use it accordingly.
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.
Groups:
MultiplayerEvent Handlers

Syntax

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 _this variable.
Arma 3
Since Arma 3 v.1.64 the EH handle is also stored in _thisEventHandler variable and is available during EH code execution.
Return Value:
Number - event handler index

Examples

Example 1:
_index = player addMPEventHandler ["MPKilled", { _this execVM "playerKilled.sqf"; }];

Additional Information

See also:
EventHandlers List removeMPEventHandler removeAllMPEventHandlers getEventHandlerInfo

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note