addMPEventHandler: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "|= Game name" to "|Game name=")
Line 11: Line 11:
____________________________________________________________________________________________
____________________________________________________________________________________________


| 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 <tt>_this</tt> variable. 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> For more information see: [[Arma_3:_Event_Handlers#addMPEventHandler]] |DESCRIPTION=
| Adds MP event handler (EH) to the given object and returns EH handle.<br>
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 <tt>_this</tt> variable.<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=
____________________________________________________________________________________________
____________________________________________________________________________________________


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


|p1= object: [[Object]] - object to monitor |=  
|p1= object: [[Object]] - object to monitor |Parameter1=
|p2= [type, expression]: [[Array]] |=
 
|p3= type: [[String]] - event handler name |=
|p2= type: [[String]] - event handler name |Parameter2=
|p4= expression: [[String]] or [[Code]] - expression to execute|=
 
|p3= expression: [[String]] or [[Code]] - expression to execute |Parameter3=


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


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


Line 51: Line 57:
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
<dd class="note">
<dd class="note">
MP EHs are added on every PC and execute on every PC, apart from MPRespawn, that only executes at the locality where unit respawns.
MP EHs are added on every PC and execute on every PC, apart from '''MPRespawn''', that only executes at the locality where unit respawns.
</dd>
</dd>
</dl>
</dl>
<!-- DISCONTINUE Notes -->
<!-- DISCONTINUE Notes -->

Revision as of 22:51, 2 September 2019

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:
Uncategorised

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

Notes

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.