addMPEventHandler: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "<code>([^ ]*)\[\[([a-zA-Z0-9_]+)\]\]([^ ]*)<\/code>" to "<code>$1$2$3</code>")
m (Text replacement - "<code>([^ ]*)\[\[([a-zA-Z0-9_]+)\]\]([^ ]*)<\/code>" to "<code>$1$2$3</code>")
Line 35: Line 35:
|r1= [[Number]] - Eventhandler index
|r1= [[Number]] - Eventhandler index


|x1= <code>_index = player addMPEventHandler ["MPKilled", { [[Magic Variables#this|_this]] [[execVM]] "playerKilled.sqf"; }];</code>
|x1= <code>_index = player addMPEventHandler ["MPKilled", { [[Magic Variables#this|_this]] execVM "playerKilled.sqf"; }];</code>


|seealso= [[:Category:Event Handlers|EventHandlers List]] [[removeMPEventHandler]] [[removeAllMPEventHandlers]]
|seealso= [[:Category:Event Handlers|EventHandlers List]] [[removeMPEventHandler]] [[removeAllMPEventHandlers]]
}}
}}

Revision as of 11:02, 12 May 2022

Hover & click on the images for description

Description

Description:
Adds a multiplayer event handler (EH) to the given object and returns EH handle.
For more information, see Event Handlers/addMPEventHandler.
Multiplayer:
Multiplayer EHs are added globally to every client and the server and will fire on every client and server upon event. Only exception is the MPRespawn EH. That one only fires where the respawned unit is local. Make sure to check the locality of the EHs on EventHandlers List.
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 - Eventhandler index

Examples

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

Additional Information

See also:
EventHandlers List removeMPEventHandler removeAllMPEventHandlers

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