addMPEventHandler: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " <h3 style="display:none">Notes</h3> <dl class="command_description"> <!-- Note Section BEGIN --> <!-- Note Section END --> </dl> " to "")
m (Text replacement - " *\| *([Cc]omments|COMMENTS|Game|[Gg]ame [Nn]ame|Game [Vv]ersion|Game Version \(number surrounded by NO SPACES\)|Multiplayer Arguments \("local" or "global"\)|Multiplayer Effects \("local" or "global"\)|Multiplayer Execution \("serv...)
Line 1: Line 1:
{{Command|Comments=
{{Command


| arma2oa |Game name=
| arma2oa


|1.55|Game version=
|1.55


|gr1 = Multiplayer |GROUP1=
|gr1 = Multiplayer


|gr2 = Event Handlers |GROUP2=
|gr2 = Event Handlers


|arg= global |Multiplayer Arguments=
|arg= global |Multiplayer Arguments=
Line 18: Line 18:
<br>
<br>
Since Arma 3 v.1.63.137807 the EH handle is also stored in <tt>_thisEventHandler</tt> variable and is available during EH code execution.<br><br>
Since Arma 3 v.1.63.137807 the EH handle is also stored in <tt>_thisEventHandler</tt> variable and is available during EH code execution.<br><br>
{{Informative | For more information, see [[Arma_3:_Event_Handlers#Multiplayer_Event_Handlers|Event Handlers/addMPEventHandler]].}} |DESCRIPTION=
{{Informative | For more information, see [[Arma_3:_Event_Handlers#Multiplayer_Event_Handlers|Event Handlers/addMPEventHandler]].}}


| object [[addMPEventHandler]] [type, expression] |SYNTAX=
| object [[addMPEventHandler]] [type, expression]


|p1= object: [[Object]] - object to monitor |Parameter1=
|p1= object: [[Object]] - object to monitor


|p2= type: [[String]] - event handler name |Parameter2=
|p2= type: [[String]] - event handler name


|p3= expression: [[String]] or [[Code]] - expression to execute |Parameter3=
|p3= expression: [[String]] or [[Code]] - expression to execute


| [[Number]] |RETURNVALUE=
| [[Number]]


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


| [[:Category:Event Handlers|EventHandlers list]], [[removeMPEventHandler]], [[removeAllMPEventHandlers]] |SEEALSO=
| [[:Category:Event Handlers|EventHandlers list]], [[removeMPEventHandler]], [[removeAllMPEventHandlers]]
}}
}}



Revision as of 01:04, 18 January 2021

Hover & click on the images for description

Description

Description:
Adds MP event handler (EH) to the given object and returns EH handle.
MP event handlers are added globally to every client on network in multiplayer and will fire on every client too upon event. 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.

Since Arma 3 v.1.63.137807 the EH handle is also stored in _thisEventHandler variable and is available during EH code execution.

For more information, see Event Handlers/addMPEventHandler.
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
Return Value:
Number

Examples

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

Additional Information

See also:
EventHandlers listremoveMPEventHandlerremoveAllMPEventHandlers

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

Bottom Section


Posted on May 8, 2015 - 12:24 (UTC)
Killzone Kid
MP EHs are added on every PC and execute on every PC, apart from MPRespawn, that only executes at the locality where unit respawns.