addMissionEventHandler: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "_{10,} " 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


| arma3 |Game name=
| arma3


|0.50|Game version=
|0.50


|eff= local |MP Effects=
|eff= local |MP Effects=


|gr1= Event Handlers |GROUP1=
|gr1= Event Handlers


| Adds event handler (EH) attached to the current mission and returns EH handle. If EH has some data to return upon event, 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 the list of available mission event handlers see: [[Arma_3:_Event_Handlers/addMissionEventHandler]]|DESCRIPTION=
| Adds event handler (EH) attached to the current mission and returns EH handle. If EH has some data to return upon event, 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 the list of available mission event handlers see: [[Arma_3:_Event_Handlers/addMissionEventHandler]]


| '''addMissionEventHandler''' [type, command] |SYNTAX=
| '''addMissionEventHandler''' [type, command]


|p1= [type, command]: [[Array]] |PARAMETER1=
|p1= [type, command]: [[Array]]


|p2= type: [[String]] |PARAMETER2=
|p2= type: [[String]]


|p3= command: [[Code]] or [[String]] - By default executed in [[missionNamespace]] |PARAMETER3=
|p3= command: [[Code]] or [[String]] - By default executed in [[missionNamespace]]


| [[Number]] - The index of the currently added mission event handler is returned. |RETURNVALUE=
| [[Number]] - The index of the currently added mission event handler is returned.




|x1= <code>// A script could be executed to stop custom scripts graciously, or save progress & stats, for example:
|x1= <code>// A script could be executed to stop custom scripts graciously, or save progress & stats, for example:


_id = [[addMissionEventHandler]] ["Ended",{ _this [[execVM]] "missionEnded.sqf" }];</code>|EXAMPLE1=
_id = [[addMissionEventHandler]] ["Ended",{ _this [[execVM]] "missionEnded.sqf" }];</code>




| [[removeMissionEventHandler]], [[removeAllMissionEventHandlers]] |SEEALSO=
| [[removeMissionEventHandler]], [[removeAllMissionEventHandlers]]


|  |MPBEHAVIOUR=  
|  |MPBEHAVIOUR=  

Revision as of 01:04, 18 January 2021

Hover & click on the images for description

Description

Description:
Adds event handler (EH) attached to the current mission and returns EH handle. If EH has some data to return upon event, 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 the list of available mission event handlers see: Arma_3:_Event_Handlers/addMissionEventHandler
Groups:
Event Handlers

Syntax

Syntax:
addMissionEventHandler [type, command]
Parameters:
[type, command]: Array
type: String
command: Code or String - By default executed in missionNamespace
Return Value:
Number - The index of the currently added mission event handler is returned.

Examples

Example 1:
// A script could be executed to stop custom scripts graciously, or save progress & stats, for example: _id = addMissionEventHandler ["Ended",{ _this execVM "missionEnded.sqf" }];

Additional Information

See also:
removeMissionEventHandlerremoveAllMissionEventHandlers

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