addMPEventHandler: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "\| *((\[\[.*\]\],? ?)+) * \}\}" to "|seealso= $1 }}") |
Lou Montana (talk | contribs) m (Text replacement - "(\|[pr][0-9]+ *= *[^-]+) *- *E([a-z])" to "$1 - e$2") |
||
(15 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{RV|type=command | {{RV|type=command | ||
| arma2oa | |game1= arma2oa | ||
|version1= 1.55 | |||
|1. | |game2= tkoh | ||
|version2= 1.00 | |||
| | |game3= arma3 | ||
|version3= 0.50 | |||
|gr2 = Event Handlers | |gr1= Multiplayer | ||
|gr2= Event Handlers | |||
|arg= global | |arg= global | ||
Line 13: | Line 18: | ||
|eff= global | |eff= global | ||
| Adds | |descr= Adds a multiplayer event handler (EH) to the given object and returns EH handle. See {{Link|:Category:Event Handlers|Event Handlers}}. | ||
{{Feature|important|A Multiplayer Event Handler is '''not''' saved in a save file and therefore will not be restored on load - use it accordingly.}} | |||
{{Feature | | |||
| object [[addMPEventHandler]] [type, expression] | |mp= 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 {{Link|:Category:Event Handlers|Event Handlers}} pages. | |||
|s1= object [[addMPEventHandler]] [type, expression] | |||
|p1= object: [[Object]] - object to monitor | |p1= object: [[Object]] - object to monitor | ||
Line 26: | Line 30: | ||
|p2= type: [[String]] - event handler name | |p2= type: [[String]] - event handler name | ||
|p3= expression: [[String]] or [[Code]] - expression to execute | |p3= expression: [[String]] or [[Code]] - expression to execute.<br> | ||
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 {{hl|_this}} variable. | |||
{{Feature|arma3|Since Arma 3 v.1.64 the EH handle is also stored in {{hl|_thisEventHandler}} variable and is available during EH code execution.}} | |||
* Event Handler parameters are accessible via <sqf inline>_this</sqf> | |||
* The Event Handler type is available as <sqf inline>_thisEvent</sqf> | |||
* The Event Handler index is available as <sqf inline>_thisEventHandler</sqf> | |||
| [[Number]] | |r1= [[Number]] - event handler index | ||
|x1= < | |x1= <sqf>_index = player addMPEventHandler ["MPKilled", { _this execVM "playerKilled.sqf"; }];</sqf> | ||
|seealso= [[:Category:Event Handlers|EventHandlers | |seealso= [[:Category:Event Handlers|EventHandlers List]] [[removeMPEventHandler]] [[removeAllMPEventHandlers]] [[getEventHandlerInfo]] | ||
}} | }} | ||
Revision as of 14:06, 8 November 2023
Description
- Description:
- Adds a multiplayer event handler (EH) to the given object and returns EH handle. See Event Handlers.
- 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.- Event Handler parameters are accessible via _this
- The Event Handler type is available as _thisEvent
- The Event Handler index is available as _thisEventHandler
- Return Value:
- Number - event handler index
Examples
- Example 1:
Additional Information
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
Categories:
- Scripting Commands
- Introduced with Arma 2: Operation Arrowhead version 1.55
- Arma 2: Operation Arrowhead: New Scripting Commands
- Arma 2: Operation Arrowhead: Scripting Commands
- Take On Helicopters: Scripting Commands
- Arma 3: Scripting Commands
- Command Group: Multiplayer
- Command Group: Event Handlers
- Scripting Commands: Global Effect