Mission Event Handlers – Arma 3
(Wrong type, always boolean.) |
Lou Montana (talk | contribs) (Page lifting) |
||
Line 1: | Line 1: | ||
< | __NOEDITSECTION__ | ||
<div style="float: right; margin-left: 1.5em; max-width: 25%;">__TOC__</div> | |||
== Description == | == Description == | ||
Mission event handlers are specific EHs that are anchored to the running mission and automatically removed when mission is over. For all other available EHs see the [[Arma_3:_Event_Handlers|main page]]. | Mission event handlers are specific EHs that are anchored to the running mission and automatically removed when mission is over. | ||
For all other available EHs see the [[Arma_3:_Event_Handlers|Event Handlers main page]]. | |||
== Related Commands == | == Related Commands == | ||
Line 12: | Line 13: | ||
* [[removeAllMissionEventHandlers]] | * [[removeAllMissionEventHandlers]] | ||
== | == Events == | ||
{{Cfg ref|start}} | |||
{{Cfg ref|abc}} | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.68}}</div> | |||
==== BuildingChanged ==== | |||
</div> | |||
Fired each time a building model changes, for example due to stages of destruction. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["BuildingChanged", { | |||
params ["_previousObject", "_newObject", "_isRuin"]; | |||
}]; | |||
</syntaxhighlight> | |||
* from: [[Object]] - building it changes from | |||
[[ | * to: [[Object]] - building it changes to | ||
* isRuin: [[Boolean]] - [[true]] if changes to ruins | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.57}}</div> | |||
==== CommandModeChanged ==== | |||
</div> | |||
Executes assigned code when user switches to/from HC command mode (<tt>Left Shift + Space</tt>). Stackable version of [[onCommandModeChanged]]. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["CommandModeChanged", { | |||
params ["_isHighCommand", "_isForced"]; | |||
}]; | |||
</syntaxhighlight> | |||
* isHighCommand: [[Boolean]] - same as <tt>_isHighCommand</tt> param | |||
* IsForced: [[Boolean]] - [[true]] if command mode was forced | |||
| | <div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|0.50}}</div> | ||
| < | |||
==== Draw3D ==== | ==== Draw3D ==== | ||
</div> | |||
Runs the EH code each frame in unscheduled environment. Client side EH only (presence of UI). Will stop executing when UI loses focus (if user Alt+Tabs for example). Usually used with [[drawIcon3D]], [[drawLine3D]]. | Runs the EH code each frame in unscheduled environment. Client side EH only (presence of UI). | ||
Will stop executing when UI loses focus (if user Alt+Tabs for example). Usually used with [[drawIcon3D]], [[drawLine3D]]. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["Draw3D", { | |||
// no params | |||
}]; | |||
</syntaxhighlight> | |||
|- | <div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.57}}</div> | ||
| < | ==== EachFrame ==== | ||
</div> | |||
Executes assigned code each frame. Stackable version of [[onEachFrame]]. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["EachFrame", { | |||
// no params | |||
}]; | |||
</syntaxhighlight> | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|0.50}}</div> | |||
==== Ended ==== | ==== Ended ==== | ||
</div> | |||
Triggered when mission ends, either using trigger of type "End", [[endMission]] command, [[BIS_fnc_endMission]] function or ENDMISSION cheat. | Triggered when mission ends, either using trigger of type "End", [[endMission]] command, [[BIS_fnc_endMission]] function or [[ArmA:_Cheats#ENDMISSION|ENDMISSION]] cheat. | ||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["Ended", { | |||
params ["_endType"]; | |||
}]; | |||
</syntaxhighlight> | |||
* endType: [[String]] - mission end type. Used in [[Debriefing]] among other things. | * endType: [[String]] - mission end type. Used in [[Debriefing]] among other things. | ||
|- | |||
| < | <div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.55}}</div> | ||
==== EntityKilled ==== | |||
</div> | |||
Triggered when an entity is killed. Worth noting that ''instigator'' param is [[objNull]] during road kill. To work around this issue try: | |||
<code>[[addMissionEventHandler]] ["EntityKilled", | |||
{ | |||
[[params]] ["_killed", "_killer", "_instigator"]; | |||
[[if]] ([[isNull]] _instigator) [[then]] {_instigator = [[UAVControl]] [[vehicle]] _killer [[select]] 0}; // UAV/UGV player operated road kill | |||
[[if]] ([[isNull]] _instigator) [[then]] {_instigator = _killer}; // player driven vehicle road kill | |||
[[hint]] [[format]] ["Killed By %1", [[name]] _instigator]; | |||
}];</code> | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["EntityKilled", { | |||
params ["_unit", "_killer", "_instigator", "_useEffects"]; | |||
}]; | |||
</syntaxhighlight> | |||
* killed: [[Object]] - entity that was killed | |||
* killer: [[Object]] - the killer (vehicle or person) | |||
* {{GVI|arma3|1.65}} instigator: [[Object]] - person who pulled the trigger | |||
* {{GVI|arma3|1.67}} useEffects: [[Boolean]] - same as ''useEffects'' in [[setDamage]] alt syntax | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.55}}</div> | |||
==== EntityRespawned ==== | |||
</div> | |||
Triggered when an entity is respawned. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["EntityRespawned", { | |||
params ["_entity", "_corpse"]; | |||
}]; | |||
</syntaxhighlight> | |||
* newEntity: [[Object]] - respawned entity | |||
* oldEntity: [[Object]] - corpse/wreck | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.57}}</div> | |||
==== GroupIconClick ==== | |||
</div> | |||
Executes assigned code when user clicks on the HC group icon on the map. If [[groupIconSelectable]] is [[true]], LMB clicking (firing) at the HC group icon on the HUD will also trigger the event. To set group icon selectable use [[setGroupIconsSelectable]]. Stackable version of [[onGroupIconClick]]. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["GroupIconClick", { | |||
params [ | |||
"_is3D", "_group", "_waypointId", | |||
"_mouseButton", "_posX", "_posY", | |||
"_shift", "_control", "_alt" | |||
]; | |||
}]; | |||
</syntaxhighlight> | |||
* is3D: [[Boolean]] - [[true]] if HUD icon, [[false]] if main map icon | |||
* group: [[Group]] - group the icon belonds to | |||
* wpID: [[Number]] - waypoint ID | |||
* mb: [[Number]] - mouse button: 0 - LMB, 1 - RMB (only applicable to IconClick) | |||
* posX: [[Number]] - screen X of the mouse | |||
* posY: [[Number]] - screen Y of the mouse | |||
* shift: [[Boolean]] - [[true]] if <tt>Shift</tt> key was pressed | |||
* ctrl: [[Boolean]] - [[true]] if <tt>Ctrl</tt> key was pressed | |||
* alt: [[Boolean]] - [[true]] if <tt>Alt</tt> key was pressed | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.57}}</div> | |||
==== GroupIconOverEnter ==== | |||
</div> | |||
'''Continuously''' executes assigned code when user hovers with pointer over the HC group icon, either on the HUD or the main map. [[groupIconSelectable]] must be set to [[true]] for this EH to work at all. To set group icon selectable use [[setGroupIconsSelectable]]. When EH fires over the HUD icon, X and Y coordinates will change depending on the position of the pointer in relation to the icon area. When over main map, the X and Y do not change and indicate icon center. Stackable version of [[onGroupIconOverEnter]]. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["GroupIconOverEnter", { | |||
params [ | |||
"_is3D", "_group", "_waypointId", | |||
"_posX", "_posY", | |||
"_shift", "_control", "_alt" | |||
]; | |||
}]; | |||
</syntaxhighlight> | |||
* is3D: [[Boolean]] - [[true]] if HUD icon, [[false]] if main map icon | |||
* group: [[Group]] - group the icon belonds to | |||
* wpID: [[Number]] - waypoint ID | |||
* posX: [[Number]] - screen X of the mouse | |||
* posY: [[Number]] - screen Y of the mouse | |||
* shift: [[Boolean]] - [[true]] if <tt>Shift</tt> key was pressed | |||
* ctrl: [[Boolean]] - [[true]] if <tt>Ctrl</tt> key was pressed | |||
* alt: [[Boolean]] - [[true]] if <tt>Alt</tt> key was pressed | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.57}}</div> | |||
==== GroupIconOverLeave ==== | |||
</div> | |||
Executes assigned code when user moves the pointer away from HC group icon it was over. Fires either for on the HUD icons or the main map HC icons. [[groupIconSelectable]] must be set to [[true]] for this EH to work at all. To set group icon selectable use [[setGroupIconsSelectable]]. Stackable version of [[onGroupIconOverLeave]]. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["GroupIconOverLeave", { | |||
params [ | |||
"_is3D", "_group", "_waypointId", | |||
"_posX", "_posY", | |||
"_shift", "_control", "_alt" | |||
]; | |||
}]; | |||
</syntaxhighlight> | |||
* is3D: [[Boolean]] - [[true]] if HUD icon, [[false]] if main map icon | |||
* group: [[Group]] - group the icon belonds to | |||
* wpID: [[Number]] - waypoint ID | |||
* posX: [[Number]] - screen X of the mouse | |||
* posY: [[Number]] - screen Y of the mouse (Y is always 0 when leaving HUD icon for some reason) | |||
* shift: [[Boolean]] - [[true]] if <tt>Shift</tt> key was pressed | |||
* ctrl: [[Boolean]] - [[true]] if <tt>Ctrl</tt> key was pressed | |||
* alt: [[Boolean]] - [[true]] if <tt>Alt</tt> key was pressed | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.32}}</div> | |||
==== HandleDisconnect ==== | |||
</div> | |||
Triggered when player disconnects from the game. Similar to [[onPlayerDisconnected]] event but can be stacked and contains the unit occupied by player before disconnect. Must be added on the server and triggers only on the server. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["HandleDisconnect", { | |||
params ["_unit", "_id", "_uid", "_name"]; | |||
true; | |||
}]; | |||
</syntaxhighlight> | |||
* unit: [[Object]] - unit formerly occupied by player | |||
* id: [[Number]] - same as _id in [[onPlayerDisconnected]] | |||
* uid: [[String]] - same as _uid in [[onPlayerDisconnected]] | |||
* name: [[String]] - same as _name in [[onPlayerDisconnected]] | |||
'''Override''': If this EH code returns [[true]], the unit, previously occupied by player, gets transferred to the server, becomes AI and continues to live, even with [[description.ext]] param ''disabledAI = 1;'' | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.57}}</div> | |||
==== HCGroupSelectionChanged ==== | |||
</div> | |||
Executes assigned code when user selects available HC group (<tt>F1, F2…</tt>). Stackable version of [[onHCGroupSelectionChanged]]. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["HCGroupSelectionChanged", { | |||
params ["_group", "_isSelected"]; | |||
}]; | |||
</syntaxhighlight> | |||
* group: [[Group]] - group selected (same as <tt>_group</tt> param) | |||
* isSelected: [[Boolean]] - [[true]] if selected (same as <tt>_isSelected</tt> param) | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|0.50}}</div> | |||
==== Loaded ==== | ==== Loaded ==== | ||
</div> | |||
Triggered when mission is loaded from save. <br> | Triggered when mission is loaded from save. <br> | ||
'''NOTE''': "Loaded" event handler should be added <u>BEFORE</u> the mission is loaded from save. Placing it in a [[Functions_Library_(Arma_3)|function]] with preInit = 1; usually does the trick. | '''NOTE''': "Loaded" event handler should be added <u>BEFORE</u> the mission is loaded from save. Placing it in a [[Functions_Library_(Arma_3)|function]] with preInit = 1; usually does the trick. | ||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["Loaded", { | |||
params ["_saveType"]; | |||
}]; | |||
</syntaxhighlight> | |||
* saveType: [[String]] - save type, can be have following values: | * saveType: [[String]] - save type, can be have following values: | ||
** "save" - custom save, achieved by pressing SAVE button in the pause menu | ** "save" - custom save, achieved by pressing SAVE button in the pause menu | ||
** "autosave" - automatic checkpoint, saved using [[saveGame]] command | ** "autosave" - automatic checkpoint, saved using [[saveGame]] command | ||
** "continue" - saved when leaving a mission to the main menu | ** "continue" - saved when leaving a mission to the main menu | ||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.62}}</div> | |||
==== Map ==== | ==== Map ==== | ||
</div> | |||
Triggered when map is opened or closed either by user action or script command [[openMap]]. | Triggered when map is opened or closed either by user action or script command [[openMap]]. | ||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["Map", { | |||
params ["_mapIsOpened", "_mapIsForced"]; | |||
}]; | |||
</syntaxhighlight> | |||
* mapIsOpened: [[Boolean]] - [[true]] if map is opened | * mapIsOpened: [[Boolean]] - [[true]] if map is opened | ||
* mapIsForced: [[Boolean]] - [[true]] if map is forced | * mapIsForced: [[Boolean]] - [[true]] if map is forced | ||
|- | <div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.57}}</div> | ||
| < | ==== MapSingleClick ==== | ||
==== | </div> | ||
Executes assigned code when user clicks anywhere on the main map. Stackable version of [[onMapSingleClick]] with some limitations: | |||
* No arguments can be passed to the assigned code in comparison with the original EH | |||
* Does not have engine default functionality override like the original EH | |||
* | <syntaxhighlight lang="cpp"> | ||
* | addMissionEventHandler ["MapSingleClick", { | ||
| < | params ["_units", "_pos", "_alt", "_shift"]; | ||
{{GVI|arma3|1. | }]; | ||
</syntaxhighlight> | |||
* units: [[Array]] - leader selected units, same as [[groupSelectedUnits]] (same as <tt>_units</tt> param) | |||
* pos: [[Array]] - world [[Position3D]] of the click in format [x,y,0] (same as <tt>_pos</tt> param) | |||
* alt: [[Boolean]] - [[true]] if <tt>Alt</tt> key was pressed (same as <tt>_alt</tt> param) | |||
* shift: [[Boolean]] - [[true]] if <tt>Shift</tt> key was pressed (same as <tt>_shift</tt> param) | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.57}}</div> | |||
==== PlayerConnected ==== | |||
</div> | |||
Executes assigned code when client joins the mission in MP. Stackable version of [[onPlayerConnected]]. | |||
If dedicated server was started without '-autoInit' option and this EH was created on server, on first GUI client this EH also fires against server, but after first client. | |||
In mission's initServer.sqf: | |||
<code>handlercon = [[addMissionEventHandler]] ["PlayerConnected", | |||
{ | |||
[[diag_log]] "Client connected"; | |||
[[diag_log]] [[_this]]; | |||
}];</code> | |||
In RPT: | |||
<code>2016/12/16, 15:39:09 "Client connected" | |||
2016/12/16, 15:39:09 [5.21041e+007,"7xxxxxxxxxxxxxxx1","longbow",false,4] | |||
2016/12/16, 15:39:34 Mission id: 5071d20b183e9580d0ee4f95f413ca18681d6165 | |||
2016/12/16, 15:39:34 "Client connected" | |||
2016/12/16, 15:39:34 [2,"","__SERVER__",false,2]</code> | |||
That happens only for GUI clients, if HC client connects first, EH does not fire for server.<br /> | |||
If dedicated server was started with -autoInit option, this EH does not fire against server, only for future clients, and all further clients appear to be JIPped.<br /> | |||
Interesting moment for headless clients, for headless clients instead of [[getPlayerUID]], handler gets string like "HC12160", where '12160' is headless client process ID (matches HC's PID observed in windows task manager) | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["PlayerConnected", { | |||
params ["_id", "_uid", "_name", "_jip", "_owner"]; | |||
}]; | |||
</syntaxhighlight> | |||
* id: [[Number]] - unique DirectPlay ID (very large number). It is also the same id used for user placed markers (same as <tt>_id</tt> param) | |||
* uid: [[String]] - [[getPlayerUID]] of the joining client. The same as Steam ID (same as <tt>_uid</tt> param) | |||
* name: [[String]] - [[profileName]] of the joining client (same as <tt>_name</tt> param) | |||
* jip: [[Boolean]] - [[didJIP]] of the joining client (same as <tt>_jip</tt> param) | |||
* owner: [[Number]] - [[owner]] id of the joining client (same as <tt>_owner</tt> param) | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.57}}</div> | |||
==== PlayerDisconnected ==== | |||
</div> | |||
Executes assigned code when client leaves the mission in MP. Stackable version of [[onPlayerDisconnected]]. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["PlayerDisconnected", { | |||
params ["_id", "_uid", "_name", "_jip", "_owner"]; | |||
}]; | |||
</syntaxhighlight> | |||
* id: [[Number]] - unique DirectPlay ID (very large number). It is also the same id used for user placed markers (same as <tt>_id</tt> param) | |||
* uid: [[String]] - [[getPlayerUID]] of the leaving client. The same as Steam ID (same as <tt>_uid</tt> param) | |||
* name: [[String]] - [[profileName]] of the leaving client (same as <tt>_name</tt> param) | |||
* jip: [[Boolean]] - [[didJIP]] of the leaving client (same as <tt>_jip</tt> param) | |||
* owner: [[Number]] - [[owner]] id of the leaving client (same as <tt>_owner</tt> param) | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.66}}</div> | |||
==== PlayerViewChanged ==== | |||
</div> | |||
Fired on player view change. Player view changes when player is changing body due to [[teamSwitch]], gets in out of a vehicle or operates UAV for example. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["PlayerViewChanged", { | |||
params [ | |||
"_oldUnit", "_newUnit", "_vehicle", | |||
"_oldCamera", "_newCamera", "_uav" | |||
]; | |||
}]; | |||
</syntaxhighlight> | |||
* oldBody: [[Object]] - player body before EH fired | |||
* newBody: [[Object]] - player body after EH fired | |||
* vehicleIn: [[Object]] - vehicle player is in ([[objNull]] if not in vehicle) | |||
* oldCameraOn: [[Object]] - [[cameraOn]] before EH fired | |||
* newCameraOn: [[Object]] - [[cameraOn]] after EH fired | |||
* UAV: [[Object]] - UAV reference if player is operating one ([[objNull]] if not operating UAV) | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.57}}</div> | |||
==== PreloadStarted ==== | |||
</div> | |||
Executes assigned code before the mission preload screen. Stackable version of [[onPreloadStarted]]. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["PreloadStarted", { | |||
// no params | |||
}]; | |||
</syntaxhighlight> | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.57}}</div> | |||
==== PreloadFinished ==== | |||
</div> | |||
Executes assigned code after the mission preload screen. Stackable version of [[onPreloadFinished]]. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["PreloadFinished", { | |||
// no params | |||
}]; | |||
</syntaxhighlight> | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.57}}</div> | |||
==== TeamSwitch ==== | |||
</div> | |||
Executes assigned code when player teamswitches. Stackable version of [[onTeamSwitch]]. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["TeamSwitch", { | |||
params ["_previousUnit", "_newUnit"]; | |||
}]; | |||
</syntaxhighlight> | |||
* from: [[Object]] - switching from unit (same as <tt>_from</tt> param) | |||
* to: [[Object]] - switching to unit (same as <tt>_to</tt> param) | |||
{{Cfg ref|end}} | |||
[[Category: Event Handlers]] | |||
[[Category: Arma 3: Editing]] | |||
__NOEDITSECTION__ | |||
<div style="float: right; margin-left: 1.5em; max-width: 25%;">__TOC__</div> | |||
== Description == | |||
Mission event handlers are specific EHs that are anchored to the running mission and automatically removed when mission is over. | |||
For all other available EHs see the [[Arma_3:_Event_Handlers|Event Handlers main page]]. | |||
== Related Commands == | |||
* [[addMissionEventHandler]] | |||
* [[removeMissionEventHandler]] | |||
* [[removeAllMissionEventHandlers]] | |||
== Events == | |||
{{Cfg ref|start}} | |||
{{Cfg ref|abc}} | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.68}}</div> | |||
==== BuildingChanged ==== | |||
</div> | |||
Fired each time a building model changes, for example due to stages of destruction. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["BuildingChanged", { | |||
params ["_previousObject", "_newObject", "_isRuin"]; | |||
}]; | |||
</syntaxhighlight> | |||
* from: [[Object]] - building it changes from | |||
* to: [[Object]] - building it changes to | |||
* isRuin: [[Boolean]] - [[true]] if changes to ruins | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.57}}</div> | |||
==== CommandModeChanged ==== | |||
</div> | |||
Executes assigned code when user switches to/from HC command mode (<tt>Left Shift + Space</tt>). Stackable version of [[onCommandModeChanged]]. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["CommandModeChanged", { | |||
params ["_isHighCommand", "_isForced"]; | |||
}]; | |||
</syntaxhighlight> | |||
* isHighCommand: [[Boolean]] - same as <tt>_isHighCommand</tt> param | |||
* IsForced: [[Boolean]] - [[true]] if command mode was forced | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|0.50}}</div> | |||
==== Draw3D ==== | |||
</div> | |||
Runs the EH code each frame in unscheduled environment. Client side EH only (presence of UI). | |||
Will stop executing when UI loses focus (if user Alt+Tabs for example). Usually used with [[drawIcon3D]], [[drawLine3D]]. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["Draw3D", { | |||
// no params | |||
}]; | |||
</syntaxhighlight> | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.57}}</div> | |||
==== EachFrame ==== | |||
</div> | |||
Executes assigned code each frame. Stackable version of [[onEachFrame]]. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["EachFrame", { | |||
// no params | |||
}]; | |||
</syntaxhighlight> | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|0.50}}</div> | |||
==== Ended ==== | |||
</div> | |||
Triggered when mission ends, either using trigger of type "End", [[endMission]] command, [[BIS_fnc_endMission]] function or [[ArmA:_Cheats#ENDMISSION|ENDMISSION]] cheat. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["Ended", { | |||
params ["_endType"]; | |||
}]; | |||
</syntaxhighlight> | |||
* endType: [[String]] - mission end type. Used in [[Debriefing]] among other things. | |||
| | <div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.55}}</div> | ||
| < | |||
==== EntityKilled ==== | ==== EntityKilled ==== | ||
</div> | |||
Triggered when an entity is killed. Worth noting that ''instigator'' param is [[objNull]] during road kill. To work around this issue try: | Triggered when an entity is killed. Worth noting that ''instigator'' param is [[objNull]] during road kill. To work around this issue try: | ||
<code>[[addMissionEventHandler]] ["EntityKilled", | <code>[[addMissionEventHandler]] ["EntityKilled", | ||
{ | { | ||
[[params]] ["_killed", "_killer", "_instigator"]; | [[params]] ["_killed", "_killer", "_instigator"]; | ||
Line 108: | Line 473: | ||
[[if]] ([[isNull]] _instigator) [[then]] {_instigator = _killer}; // player driven vehicle road kill | [[if]] ([[isNull]] _instigator) [[then]] {_instigator = _killer}; // player driven vehicle road kill | ||
[[hint]] [[format]] ["Killed By %1", [[name]] _instigator]; | [[hint]] [[format]] ["Killed By %1", [[name]] _instigator]; | ||
}];</code> | }];</code> | ||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["EntityKilled", { | |||
params ["_unit", "_killer", "_instigator", "_useEffects"]; | |||
}]; | |||
</syntaxhighlight> | |||
* killed: [[Object]] - entity that was killed | * killed: [[Object]] - entity that was killed | ||
* killer: [[Object]] - the killer (vehicle or person) | * killer: [[Object]] - the killer (vehicle or person) | ||
* {{GVI|arma3|1.65}} instigator: [[Object]] - person who pulled the trigger | |||
* {{GVI|arma3|1.67}} useEffects: [[Boolean]] - same as ''useEffects'' in [[setDamage]] alt syntax | |||
==== | <div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.55}}</div> | ||
==== EntityRespawned ==== | |||
</div> | |||
Triggered when an entity is respawned. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["EntityRespawned", { | |||
params ["_entity", "_corpse"]; | |||
}]; | |||
</syntaxhighlight> | |||
* newEntity: [[Object]] - respawned entity | |||
* oldEntity: [[Object]] - corpse/wreck | |||
* | |||
* | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.57}}</div> | |||
==== GroupIconClick ==== | ==== GroupIconClick ==== | ||
</div> | |||
Executes assigned code when user clicks on the HC group icon on the map. If [[groupIconSelectable]] is [[true]], LMB clicking (firing) at the HC group icon on the HUD will also trigger the event. To set group icon selectable use [[setGroupIconsSelectable]]. Stackable version of [[onGroupIconClick]]. | Executes assigned code when user clicks on the HC group icon on the map. If [[groupIconSelectable]] is [[true]], LMB clicking (firing) at the HC group icon on the HUD will also trigger the event. To set group icon selectable use [[setGroupIconsSelectable]]. Stackable version of [[onGroupIconClick]]. | ||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["GroupIconClick", { | |||
params [ | |||
"_is3D", "_group", "_waypointId", | |||
"_mouseButton", "_posX", "_posY", | |||
"_shift", "_control", "_alt" | |||
]; | |||
}]; | |||
</syntaxhighlight> | |||
* is3D: [[Boolean]] - [[true]] if HUD icon, [[false]] if main map icon | * is3D: [[Boolean]] - [[true]] if HUD icon, [[false]] if main map icon | ||
* group: [[Group]] - group the icon belonds to | * group: [[Group]] - group the icon belonds to | ||
Line 182: | Line 523: | ||
* ctrl: [[Boolean]] - [[true]] if <tt>Ctrl</tt> key was pressed | * ctrl: [[Boolean]] - [[true]] if <tt>Ctrl</tt> key was pressed | ||
* alt: [[Boolean]] - [[true]] if <tt>Alt</tt> key was pressed | * alt: [[Boolean]] - [[true]] if <tt>Alt</tt> key was pressed | ||
| | |||
| < | <div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.57}}</div> | ||
==== GroupIconOverEnter ==== | ==== GroupIconOverEnter ==== | ||
</div> | |||
'''Continuously''' executes assigned code when user hovers with pointer over the HC group icon, either on the HUD or the main map. [[groupIconSelectable]] must be set to [[true]] for this EH to work at all. To set group icon selectable use [[setGroupIconsSelectable]]. When EH fires over the HUD icon, X and Y coordinates will change depending on the position of the pointer in relation to the icon area. When over main map, the X and Y do not change and indicate icon center. Stackable version of [[onGroupIconOverEnter]]. | '''Continuously''' executes assigned code when user hovers with pointer over the HC group icon, either on the HUD or the main map. [[groupIconSelectable]] must be set to [[true]] for this EH to work at all. To set group icon selectable use [[setGroupIconsSelectable]]. When EH fires over the HUD icon, X and Y coordinates will change depending on the position of the pointer in relation to the icon area. When over main map, the X and Y do not change and indicate icon center. Stackable version of [[onGroupIconOverEnter]]. | ||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["GroupIconOverEnter", { | |||
params [ | |||
"_is3D", "_group", "_waypointId", | |||
"_posX", "_posY", | |||
"_shift", "_control", "_alt" | |||
]; | |||
}]; | |||
</syntaxhighlight> | |||
* is3D: [[Boolean]] - [[true]] if HUD icon, [[false]] if main map icon | * is3D: [[Boolean]] - [[true]] if HUD icon, [[false]] if main map icon | ||
* group: [[Group]] - group the icon belonds to | * group: [[Group]] - group the icon belonds to | ||
Line 199: | Line 547: | ||
* ctrl: [[Boolean]] - [[true]] if <tt>Ctrl</tt> key was pressed | * ctrl: [[Boolean]] - [[true]] if <tt>Ctrl</tt> key was pressed | ||
* alt: [[Boolean]] - [[true]] if <tt>Alt</tt> key was pressed | * alt: [[Boolean]] - [[true]] if <tt>Alt</tt> key was pressed | ||
| | |||
| < | <div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.57}}</div> | ||
==== GroupIconOverLeave ==== | ==== GroupIconOverLeave ==== | ||
</div> | |||
Executes assigned code when user moves the pointer away from HC group icon it was over. Fires either for on the HUD icons or the main map HC icons. [[groupIconSelectable]] must be set to [[true]] for this EH to work at all. To set group icon selectable use [[setGroupIconsSelectable]]. Stackable version of [[onGroupIconOverLeave]]. | Executes assigned code when user moves the pointer away from HC group icon it was over. Fires either for on the HUD icons or the main map HC icons. [[groupIconSelectable]] must be set to [[true]] for this EH to work at all. To set group icon selectable use [[setGroupIconsSelectable]]. Stackable version of [[onGroupIconOverLeave]]. | ||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["GroupIconOverLeave", { | |||
params [ | |||
"_is3D", "_group", "_waypointId", | |||
"_posX", "_posY", | |||
"_shift", "_control", "_alt" | |||
]; | |||
}]; | |||
</syntaxhighlight> | |||
* is3D: [[Boolean]] - [[true]] if HUD icon, [[false]] if main map icon | * is3D: [[Boolean]] - [[true]] if HUD icon, [[false]] if main map icon | ||
* group: [[Group]] - group the icon belonds to | * group: [[Group]] - group the icon belonds to | ||
Line 216: | Line 571: | ||
* ctrl: [[Boolean]] - [[true]] if <tt>Ctrl</tt> key was pressed | * ctrl: [[Boolean]] - [[true]] if <tt>Ctrl</tt> key was pressed | ||
* alt: [[Boolean]] - [[true]] if <tt>Alt</tt> key was pressed | * alt: [[Boolean]] - [[true]] if <tt>Alt</tt> key was pressed | ||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.32}}</div> | |||
==== HandleDisconnect ==== | |||
</div> | |||
Triggered when player disconnects from the game. Similar to [[onPlayerDisconnected]] event but can be stacked and contains the unit occupied by player before disconnect. Must be added on the server and triggers only on the server. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["HandleDisconnect", { | |||
params ["_unit", "_id", "_uid", "_name"]; | |||
true; | |||
}]; | |||
</syntaxhighlight> | |||
* unit: [[Object]] - unit formerly occupied by player | |||
* id: [[Number]] - same as _id in [[onPlayerDisconnected]] | |||
* uid: [[String]] - same as _uid in [[onPlayerDisconnected]] | |||
* name: [[String]] - same as _name in [[onPlayerDisconnected]] | |||
'''Override''': If this EH code returns [[true]], the unit, previously occupied by player, gets transferred to the server, becomes AI and continues to live, even with [[description.ext]] param ''disabledAI = 1;'' | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.57}}</div> | |||
==== HCGroupSelectionChanged ==== | |||
</div> | |||
Executes assigned code when user selects available HC group (<tt>F1, F2…</tt>). Stackable version of [[onHCGroupSelectionChanged]]. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["HCGroupSelectionChanged", { | |||
params ["_group", "_isSelected"]; | |||
}]; | |||
</syntaxhighlight> | |||
* group: [[Group]] - group selected (same as <tt>_group</tt> param) | |||
* isSelected: [[Boolean]] - [[true]] if selected (same as <tt>_isSelected</tt> param) | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|0.50}}</div> | |||
==== Loaded ==== | |||
</div> | |||
Triggered when mission is loaded from save. <br> | |||
'''NOTE''': "Loaded" event handler should be added <u>BEFORE</u> the mission is loaded from save. Placing it in a [[Functions_Library_(Arma_3)|function]] with preInit = 1; usually does the trick. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["Loaded", { | |||
params ["_saveType"]; | |||
}]; | |||
</syntaxhighlight> | |||
* saveType: [[String]] - save type, can be have following values: | |||
** "save" - custom save, achieved by pressing SAVE button in the pause menu | |||
** "autosave" - automatic checkpoint, saved using [[saveGame]] command | |||
** "continue" - saved when leaving a mission to the main menu | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.62}}</div> | |||
==== Map ==== | |||
</div> | |||
Triggered when map is opened or closed either by user action or script command [[openMap]]. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["Map", { | |||
params ["_mapIsOpened", "_mapIsForced"]; | |||
}]; | |||
</syntaxhighlight> | |||
* mapIsOpened: [[Boolean]] - [[true]] if map is opened | |||
* mapIsForced: [[Boolean]] - [[true]] if map is forced | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.57}}</div> | |||
==== MapSingleClick ==== | |||
</div> | |||
Executes assigned code when user clicks anywhere on the main map. Stackable version of [[onMapSingleClick]] with some limitations: | |||
* No arguments can be passed to the assigned code in comparison with the original EH | |||
* Does not have engine default functionality override like the original EH | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["MapSingleClick", { | |||
params ["_units", "_pos", "_alt", "_shift"]; | |||
}]; | |||
</syntaxhighlight> | |||
* units: [[Array]] - leader selected units, same as [[groupSelectedUnits]] (same as <tt>_units</tt> param) | |||
* pos: [[Array]] - world [[Position3D]] of the click in format [x,y,0] (same as <tt>_pos</tt> param) | |||
* alt: [[Boolean]] - [[true]] if <tt>Alt</tt> key was pressed (same as <tt>_alt</tt> param) | |||
* shift: [[Boolean]] - [[true]] if <tt>Shift</tt> key was pressed (same as <tt>_shift</tt> param) | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.57}}</div> | |||
==== PlayerConnected ==== | ==== PlayerConnected ==== | ||
</div> | |||
Executes assigned code when client joins the mission in MP. Stackable version of [[onPlayerConnected]]. | Executes assigned code when client joins the mission in MP. Stackable version of [[onPlayerConnected]]. | ||
Line 243: | Line 676: | ||
2016/12/16, 15:39:34 [2,"","__SERVER__",false,2] | 2016/12/16, 15:39:34 [2,"","__SERVER__",false,2] | ||
</code> | </code> | ||
That happens only for GUI clients, if HC client connects first, EH does not fire for server. | That happens only for GUI clients, if HC client connects first, EH does not fire for server.<br /> | ||
If dedicated server was started with -autoInit option, this EH does not fire against server, only for future clients, and all further clients appear to be JIPped.<br /> | |||
If dedicated server was started with -autoInit option, this EH does not fire against server, only for future clients, and all further clients appear to be JIPped. | |||
Interesting moment for headless clients, for headless clients instead of [[getPlayerUID]], handler gets string like "HC12160", where '12160' is headless client process ID (matches HC's PID observed in windows task manager) | Interesting moment for headless clients, for headless clients instead of [[getPlayerUID]], handler gets string like "HC12160", where '12160' is headless client process ID (matches HC's PID observed in windows task manager) | ||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["PlayerConnected", { | |||
params ["_id", "_uid", "_name", "_jip", "_owner"]; | |||
}]; | |||
</syntaxhighlight> | |||
* id: [[Number]] - unique DirectPlay ID (very large number). It is also the same id used for user placed markers (same as <tt>_id</tt> param) | * id: [[Number]] - unique DirectPlay ID (very large number). It is also the same id used for user placed markers (same as <tt>_id</tt> param) | ||
* uid: [[String]] - [[getPlayerUID]] of the joining client. The same as Steam ID (same as <tt>_uid</tt> param) | * uid: [[String]] - [[getPlayerUID]] of the joining client. The same as Steam ID (same as <tt>_uid</tt> param) | ||
Line 257: | Line 690: | ||
* jip: [[Boolean]] - [[didJIP]] of the joining client (same as <tt>_jip</tt> param) | * jip: [[Boolean]] - [[didJIP]] of the joining client (same as <tt>_jip</tt> param) | ||
* owner: [[Number]] - [[owner]] id of the joining client (same as <tt>_owner</tt> param) | * owner: [[Number]] - [[owner]] id of the joining client (same as <tt>_owner</tt> param) | ||
| | |||
| < | <div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.57}}</div> | ||
==== PlayerDisconnected ==== | ==== PlayerDisconnected ==== | ||
</div> | |||
Executes assigned code when client leaves the mission in MP. Stackable version of [[onPlayerDisconnected]]. | Executes assigned code when client leaves the mission in MP. Stackable version of [[onPlayerDisconnected]]. | ||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["PlayerDisconnected", { | |||
params ["_id", "_uid", "_name", "_jip", "_owner"]; | |||
}]; | |||
</syntaxhighlight> | |||
* id: [[Number]] - unique DirectPlay ID (very large number). It is also the same id used for user placed markers (same as <tt>_id</tt> param) | * id: [[Number]] - unique DirectPlay ID (very large number). It is also the same id used for user placed markers (same as <tt>_id</tt> param) | ||
* uid: [[String]] - [[getPlayerUID]] of the leaving client. The same as Steam ID (same as <tt>_uid</tt> param) | * uid: [[String]] - [[getPlayerUID]] of the leaving client. The same as Steam ID (same as <tt>_uid</tt> param) | ||
Line 271: | Line 707: | ||
* jip: [[Boolean]] - [[didJIP]] of the leaving client (same as <tt>_jip</tt> param) | * jip: [[Boolean]] - [[didJIP]] of the leaving client (same as <tt>_jip</tt> param) | ||
* owner: [[Number]] - [[owner]] id of the leaving client (same as <tt>_owner</tt> param) | * owner: [[Number]] - [[owner]] id of the leaving client (same as <tt>_owner</tt> param) | ||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.66}}</div> | |||
= | |||
{{GVI|arma3|1. | |||
==== PlayerViewChanged ==== | ==== PlayerViewChanged ==== | ||
</div> | |||
Fired on player view change. Player view changes when player is changing body due to [[teamSwitch]], gets in out of a vehicle or operates UAV for example. | Fired on player view change. Player view changes when player is changing body due to [[teamSwitch]], gets in out of a vehicle or operates UAV for example. | ||
<syntaxhighlight lang="cpp"> | |||
* oldBody: [[Object]] - player body before EH fired | addMissionEventHandler ["PlayerViewChanged", { | ||
params [ | |||
"_oldUnit", "_newUnit", "_vehicle", | |||
"_oldCamera", "_newCamera", "_uav" | |||
]; | |||
}]; | |||
</syntaxhighlight> | |||
* oldBody: [[Object]] - player body before EH fired | |||
* newBody: [[Object]] - player body after EH fired | * newBody: [[Object]] - player body after EH fired | ||
* vehicleIn: [[Object]] - vehicle player is in ([[objNull]] if not in vehicle) | * vehicleIn: [[Object]] - vehicle player is in ([[objNull]] if not in vehicle) | ||
Line 315: | Line 728: | ||
* newCameraOn: [[Object]] - [[cameraOn]] after EH fired | * newCameraOn: [[Object]] - [[cameraOn]] after EH fired | ||
* UAV: [[Object]] - UAV reference if player is operating one ([[objNull]] if not operating UAV) | * UAV: [[Object]] - UAV reference if player is operating one ([[objNull]] if not operating UAV) | ||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.57}}</div> | |||
==== PreloadStarted ==== | |||
</div> | |||
Executes assigned code before the mission preload screen. Stackable version of [[onPreloadStarted]]. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["PreloadStarted", { | |||
// no params | |||
}]; | |||
</syntaxhighlight> | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.57}}</div> | |||
==== PreloadFinished ==== | |||
</div> | |||
Executes assigned code after the mission preload screen. Stackable version of [[onPreloadFinished]]. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["PreloadFinished", { | |||
// no params | |||
}]; | |||
</syntaxhighlight> | |||
<div><div style="float: left; margin-right: 0.5em;">{{GVI|arma3|1.57}}</div> | |||
==== TeamSwitch ==== | |||
</div> | |||
Executes assigned code when player teamswitches. Stackable version of [[onTeamSwitch]]. | |||
<syntaxhighlight lang="cpp"> | |||
addMissionEventHandler ["TeamSwitch", { | |||
params ["_previousUnit", "_newUnit"]; | |||
}]; | |||
</syntaxhighlight> | |||
* from: [[Object]] - switching from unit (same as <tt>_from</tt> param) | |||
* to: [[Object]] - switching to unit (same as <tt>_to</tt> param) | |||
{{Cfg ref|end}} | |||
[[Category: Event Handlers]] | |||
[[Category: Arma 3: Editing]] |
Revision as of 10:47, 19 May 2018
Description
Mission event handlers are specific EHs that are anchored to the running mission and automatically removed when mission is over. For all other available EHs see the Event Handlers main page.
Related Commands
Events
Template:Cfg ref Template:Cfg ref
BuildingChanged
Fired each time a building model changes, for example due to stages of destruction.
addMissionEventHandler ["BuildingChanged", {
params ["_previousObject", "_newObject", "_isRuin"];
}];
- from: Object - building it changes from
- to: Object - building it changes to
- isRuin: Boolean - true if changes to ruins
CommandModeChanged
Executes assigned code when user switches to/from HC command mode (Left Shift + Space). Stackable version of onCommandModeChanged.
addMissionEventHandler ["CommandModeChanged", {
params ["_isHighCommand", "_isForced"];
}];
- isHighCommand: Boolean - same as _isHighCommand param
- IsForced: Boolean - true if command mode was forced
Draw3D
Runs the EH code each frame in unscheduled environment. Client side EH only (presence of UI). Will stop executing when UI loses focus (if user Alt+Tabs for example). Usually used with drawIcon3D, drawLine3D.
addMissionEventHandler ["Draw3D", {
// no params
}];
EachFrame
Executes assigned code each frame. Stackable version of onEachFrame.
addMissionEventHandler ["EachFrame", {
// no params
}];
Ended
Triggered when mission ends, either using trigger of type "End", endMission command, BIS_fnc_endMission function or ENDMISSION cheat.
addMissionEventHandler ["Ended", {
params ["_endType"];
}];
- endType: String - mission end type. Used in Debriefing among other things.
EntityKilled
Triggered when an entity is killed. Worth noting that instigator param is objNull during road kill. To work around this issue try:
addMissionEventHandler ["EntityKilled",
{
params ["_killed", "_killer", "_instigator"];
if (isNull _instigator) then {_instigator = UAVControl vehicle _killer select 0}; // UAV/UGV player operated road kill
if (isNull _instigator) then {_instigator = _killer}; // player driven vehicle road kill
hint format ["Killed By %1", name _instigator];
}];
addMissionEventHandler ["EntityKilled", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
}];
- killed: Object - entity that was killed
- killer: Object - the killer (vehicle or person)
- 1.65 instigator: Object - person who pulled the trigger
- 1.67 useEffects: Boolean - same as useEffects in setDamage alt syntax
EntityRespawned
Triggered when an entity is respawned.
addMissionEventHandler ["EntityRespawned", {
params ["_entity", "_corpse"];
}];
GroupIconClick
Executes assigned code when user clicks on the HC group icon on the map. If groupIconSelectable is true, LMB clicking (firing) at the HC group icon on the HUD will also trigger the event. To set group icon selectable use setGroupIconsSelectable. Stackable version of onGroupIconClick.
addMissionEventHandler ["GroupIconClick", {
params [
"_is3D", "_group", "_waypointId",
"_mouseButton", "_posX", "_posY",
"_shift", "_control", "_alt"
];
}];
- is3D: Boolean - true if HUD icon, false if main map icon
- group: Group - group the icon belonds to
- wpID: Number - waypoint ID
- mb: Number - mouse button: 0 - LMB, 1 - RMB (only applicable to IconClick)
- posX: Number - screen X of the mouse
- posY: Number - screen Y of the mouse
- shift: Boolean - true if Shift key was pressed
- ctrl: Boolean - true if Ctrl key was pressed
- alt: Boolean - true if Alt key was pressed
GroupIconOverEnter
Continuously executes assigned code when user hovers with pointer over the HC group icon, either on the HUD or the main map. groupIconSelectable must be set to true for this EH to work at all. To set group icon selectable use setGroupIconsSelectable. When EH fires over the HUD icon, X and Y coordinates will change depending on the position of the pointer in relation to the icon area. When over main map, the X and Y do not change and indicate icon center. Stackable version of onGroupIconOverEnter.
addMissionEventHandler ["GroupIconOverEnter", {
params [
"_is3D", "_group", "_waypointId",
"_posX", "_posY",
"_shift", "_control", "_alt"
];
}];
- is3D: Boolean - true if HUD icon, false if main map icon
- group: Group - group the icon belonds to
- wpID: Number - waypoint ID
- posX: Number - screen X of the mouse
- posY: Number - screen Y of the mouse
- shift: Boolean - true if Shift key was pressed
- ctrl: Boolean - true if Ctrl key was pressed
- alt: Boolean - true if Alt key was pressed
GroupIconOverLeave
Executes assigned code when user moves the pointer away from HC group icon it was over. Fires either for on the HUD icons or the main map HC icons. groupIconSelectable must be set to true for this EH to work at all. To set group icon selectable use setGroupIconsSelectable. Stackable version of onGroupIconOverLeave.
addMissionEventHandler ["GroupIconOverLeave", {
params [
"_is3D", "_group", "_waypointId",
"_posX", "_posY",
"_shift", "_control", "_alt"
];
}];
- is3D: Boolean - true if HUD icon, false if main map icon
- group: Group - group the icon belonds to
- wpID: Number - waypoint ID
- posX: Number - screen X of the mouse
- posY: Number - screen Y of the mouse (Y is always 0 when leaving HUD icon for some reason)
- shift: Boolean - true if Shift key was pressed
- ctrl: Boolean - true if Ctrl key was pressed
- alt: Boolean - true if Alt key was pressed
HandleDisconnect
Triggered when player disconnects from the game. Similar to onPlayerDisconnected event but can be stacked and contains the unit occupied by player before disconnect. Must be added on the server and triggers only on the server.
addMissionEventHandler ["HandleDisconnect", {
params ["_unit", "_id", "_uid", "_name"];
true;
}];
- unit: Object - unit formerly occupied by player
- id: Number - same as _id in onPlayerDisconnected
- uid: String - same as _uid in onPlayerDisconnected
- name: String - same as _name in onPlayerDisconnected
Override: If this EH code returns true, the unit, previously occupied by player, gets transferred to the server, becomes AI and continues to live, even with description.ext param disabledAI = 1;
HCGroupSelectionChanged
Executes assigned code when user selects available HC group (F1, F2…). Stackable version of onHCGroupSelectionChanged.
addMissionEventHandler ["HCGroupSelectionChanged", {
params ["_group", "_isSelected"];
}];
- group: Group - group selected (same as _group param)
- isSelected: Boolean - true if selected (same as _isSelected param)
Loaded
Triggered when mission is loaded from save.
NOTE: "Loaded" event handler should be added BEFORE the mission is loaded from save. Placing it in a function with preInit = 1; usually does the trick.
addMissionEventHandler ["Loaded", {
params ["_saveType"];
}];
- saveType: String - save type, can be have following values:
- "save" - custom save, achieved by pressing SAVE button in the pause menu
- "autosave" - automatic checkpoint, saved using saveGame command
- "continue" - saved when leaving a mission to the main menu
Map
Triggered when map is opened or closed either by user action or script command openMap.
addMissionEventHandler ["Map", {
params ["_mapIsOpened", "_mapIsForced"];
}];
MapSingleClick
Executes assigned code when user clicks anywhere on the main map. Stackable version of onMapSingleClick with some limitations:
- No arguments can be passed to the assigned code in comparison with the original EH
- Does not have engine default functionality override like the original EH
addMissionEventHandler ["MapSingleClick", {
params ["_units", "_pos", "_alt", "_shift"];
}];
- units: Array - leader selected units, same as groupSelectedUnits (same as _units param)
- pos: Array - world Position3D of the click in format [x,y,0] (same as _pos param)
- alt: Boolean - true if Alt key was pressed (same as _alt param)
- shift: Boolean - true if Shift key was pressed (same as _shift param)
PlayerConnected
Executes assigned code when client joins the mission in MP. Stackable version of onPlayerConnected.
If dedicated server was started without '-autoInit' option and this EH was created on server, on first GUI client this EH also fires against server, but after first client.
In mission's initServer.sqf:
handlercon = addMissionEventHandler ["PlayerConnected",
{
diag_log "Client connected";
diag_log _this;
}];
In RPT:
2016/12/16, 15:39:09 "Client connected"
2016/12/16, 15:39:09 [5.21041e+007,"7xxxxxxxxxxxxxxx1","longbow",false,4]
2016/12/16, 15:39:34 Mission id: 5071d20b183e9580d0ee4f95f413ca18681d6165
2016/12/16, 15:39:34 "Client connected"
2016/12/16, 15:39:34 [2,"","__SERVER__",false,2]
That happens only for GUI clients, if HC client connects first, EH does not fire for server.
If dedicated server was started with -autoInit option, this EH does not fire against server, only for future clients, and all further clients appear to be JIPped.
Interesting moment for headless clients, for headless clients instead of getPlayerUID, handler gets string like "HC12160", where '12160' is headless client process ID (matches HC's PID observed in windows task manager)
addMissionEventHandler ["PlayerConnected", {
params ["_id", "_uid", "_name", "_jip", "_owner"];
}];
- id: Number - unique DirectPlay ID (very large number). It is also the same id used for user placed markers (same as _id param)
- uid: String - getPlayerUID of the joining client. The same as Steam ID (same as _uid param)
- name: String - profileName of the joining client (same as _name param)
- jip: Boolean - didJIP of the joining client (same as _jip param)
- owner: Number - owner id of the joining client (same as _owner param)
PlayerDisconnected
Executes assigned code when client leaves the mission in MP. Stackable version of onPlayerDisconnected.
addMissionEventHandler ["PlayerDisconnected", {
params ["_id", "_uid", "_name", "_jip", "_owner"];
}];
- id: Number - unique DirectPlay ID (very large number). It is also the same id used for user placed markers (same as _id param)
- uid: String - getPlayerUID of the leaving client. The same as Steam ID (same as _uid param)
- name: String - profileName of the leaving client (same as _name param)
- jip: Boolean - didJIP of the leaving client (same as _jip param)
- owner: Number - owner id of the leaving client (same as _owner param)
PlayerViewChanged
Fired on player view change. Player view changes when player is changing body due to teamSwitch, gets in out of a vehicle or operates UAV for example.
addMissionEventHandler ["PlayerViewChanged", {
params [
"_oldUnit", "_newUnit", "_vehicle",
"_oldCamera", "_newCamera", "_uav"
];
}];
- oldBody: Object - player body before EH fired
- newBody: Object - player body after EH fired
- vehicleIn: Object - vehicle player is in (objNull if not in vehicle)
- oldCameraOn: Object - cameraOn before EH fired
- newCameraOn: Object - cameraOn after EH fired
- UAV: Object - UAV reference if player is operating one (objNull if not operating UAV)
PreloadStarted
Executes assigned code before the mission preload screen. Stackable version of onPreloadStarted.
addMissionEventHandler ["PreloadStarted", {
// no params
}];
PreloadFinished
Executes assigned code after the mission preload screen. Stackable version of onPreloadFinished.
addMissionEventHandler ["PreloadFinished", {
// no params
}];
TeamSwitch
Executes assigned code when player teamswitches. Stackable version of onTeamSwitch.
addMissionEventHandler ["TeamSwitch", {
params ["_previousUnit", "_newUnit"];
}];
- from: Object - switching from unit (same as _from param)
- to: Object - switching to unit (same as _to param)
Description
Mission event handlers are specific EHs that are anchored to the running mission and automatically removed when mission is over. For all other available EHs see the Event Handlers main page.
Related Commands
Events
Template:Cfg ref Template:Cfg ref
BuildingChanged
Fired each time a building model changes, for example due to stages of destruction.
addMissionEventHandler ["BuildingChanged", {
params ["_previousObject", "_newObject", "_isRuin"];
}];
- from: Object - building it changes from
- to: Object - building it changes to
- isRuin: Boolean - true if changes to ruins
CommandModeChanged
Executes assigned code when user switches to/from HC command mode (Left Shift + Space). Stackable version of onCommandModeChanged.
addMissionEventHandler ["CommandModeChanged", {
params ["_isHighCommand", "_isForced"];
}];
- isHighCommand: Boolean - same as _isHighCommand param
- IsForced: Boolean - true if command mode was forced
Draw3D
Runs the EH code each frame in unscheduled environment. Client side EH only (presence of UI). Will stop executing when UI loses focus (if user Alt+Tabs for example). Usually used with drawIcon3D, drawLine3D.
addMissionEventHandler ["Draw3D", {
// no params
}];
EachFrame
Executes assigned code each frame. Stackable version of onEachFrame.
addMissionEventHandler ["EachFrame", {
// no params
}];
Ended
Triggered when mission ends, either using trigger of type "End", endMission command, BIS_fnc_endMission function or ENDMISSION cheat.
addMissionEventHandler ["Ended", {
params ["_endType"];
}];
- endType: String - mission end type. Used in Debriefing among other things.
EntityKilled
Triggered when an entity is killed. Worth noting that instigator param is objNull during road kill. To work around this issue try:
addMissionEventHandler ["EntityKilled",
{
params ["_killed", "_killer", "_instigator"];
if (isNull _instigator) then {_instigator = UAVControl vehicle _killer select 0}; // UAV/UGV player operated road kill
if (isNull _instigator) then {_instigator = _killer}; // player driven vehicle road kill
hint format ["Killed By %1", name _instigator];
}];
addMissionEventHandler ["EntityKilled", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
}];
- killed: Object - entity that was killed
- killer: Object - the killer (vehicle or person)
- 1.65 instigator: Object - person who pulled the trigger
- 1.67 useEffects: Boolean - same as useEffects in setDamage alt syntax
EntityRespawned
Triggered when an entity is respawned.
addMissionEventHandler ["EntityRespawned", {
params ["_entity", "_corpse"];
}];
GroupIconClick
Executes assigned code when user clicks on the HC group icon on the map. If groupIconSelectable is true, LMB clicking (firing) at the HC group icon on the HUD will also trigger the event. To set group icon selectable use setGroupIconsSelectable. Stackable version of onGroupIconClick.
addMissionEventHandler ["GroupIconClick", {
params [
"_is3D", "_group", "_waypointId",
"_mouseButton", "_posX", "_posY",
"_shift", "_control", "_alt"
];
}];
- is3D: Boolean - true if HUD icon, false if main map icon
- group: Group - group the icon belonds to
- wpID: Number - waypoint ID
- mb: Number - mouse button: 0 - LMB, 1 - RMB (only applicable to IconClick)
- posX: Number - screen X of the mouse
- posY: Number - screen Y of the mouse
- shift: Boolean - true if Shift key was pressed
- ctrl: Boolean - true if Ctrl key was pressed
- alt: Boolean - true if Alt key was pressed
GroupIconOverEnter
Continuously executes assigned code when user hovers with pointer over the HC group icon, either on the HUD or the main map. groupIconSelectable must be set to true for this EH to work at all. To set group icon selectable use setGroupIconsSelectable. When EH fires over the HUD icon, X and Y coordinates will change depending on the position of the pointer in relation to the icon area. When over main map, the X and Y do not change and indicate icon center. Stackable version of onGroupIconOverEnter.
addMissionEventHandler ["GroupIconOverEnter", {
params [
"_is3D", "_group", "_waypointId",
"_posX", "_posY",
"_shift", "_control", "_alt"
];
}];
- is3D: Boolean - true if HUD icon, false if main map icon
- group: Group - group the icon belonds to
- wpID: Number - waypoint ID
- posX: Number - screen X of the mouse
- posY: Number - screen Y of the mouse
- shift: Boolean - true if Shift key was pressed
- ctrl: Boolean - true if Ctrl key was pressed
- alt: Boolean - true if Alt key was pressed
GroupIconOverLeave
Executes assigned code when user moves the pointer away from HC group icon it was over. Fires either for on the HUD icons or the main map HC icons. groupIconSelectable must be set to true for this EH to work at all. To set group icon selectable use setGroupIconsSelectable. Stackable version of onGroupIconOverLeave.
addMissionEventHandler ["GroupIconOverLeave", {
params [
"_is3D", "_group", "_waypointId",
"_posX", "_posY",
"_shift", "_control", "_alt"
];
}];
- is3D: Boolean - true if HUD icon, false if main map icon
- group: Group - group the icon belonds to
- wpID: Number - waypoint ID
- posX: Number - screen X of the mouse
- posY: Number - screen Y of the mouse (Y is always 0 when leaving HUD icon for some reason)
- shift: Boolean - true if Shift key was pressed
- ctrl: Boolean - true if Ctrl key was pressed
- alt: Boolean - true if Alt key was pressed
HandleDisconnect
Triggered when player disconnects from the game. Similar to onPlayerDisconnected event but can be stacked and contains the unit occupied by player before disconnect. Must be added on the server and triggers only on the server.
addMissionEventHandler ["HandleDisconnect", {
params ["_unit", "_id", "_uid", "_name"];
true;
}];
- unit: Object - unit formerly occupied by player
- id: Number - same as _id in onPlayerDisconnected
- uid: String - same as _uid in onPlayerDisconnected
- name: String - same as _name in onPlayerDisconnected
Override: If this EH code returns true, the unit, previously occupied by player, gets transferred to the server, becomes AI and continues to live, even with description.ext param disabledAI = 1;
HCGroupSelectionChanged
Executes assigned code when user selects available HC group (F1, F2…). Stackable version of onHCGroupSelectionChanged.
addMissionEventHandler ["HCGroupSelectionChanged", {
params ["_group", "_isSelected"];
}];
- group: Group - group selected (same as _group param)
- isSelected: Boolean - true if selected (same as _isSelected param)
Loaded
Triggered when mission is loaded from save.
NOTE: "Loaded" event handler should be added BEFORE the mission is loaded from save. Placing it in a function with preInit = 1; usually does the trick.
addMissionEventHandler ["Loaded", {
params ["_saveType"];
}];
- saveType: String - save type, can be have following values:
- "save" - custom save, achieved by pressing SAVE button in the pause menu
- "autosave" - automatic checkpoint, saved using saveGame command
- "continue" - saved when leaving a mission to the main menu
Map
Triggered when map is opened or closed either by user action or script command openMap.
addMissionEventHandler ["Map", {
params ["_mapIsOpened", "_mapIsForced"];
}];
MapSingleClick
Executes assigned code when user clicks anywhere on the main map. Stackable version of onMapSingleClick with some limitations:
- No arguments can be passed to the assigned code in comparison with the original EH
- Does not have engine default functionality override like the original EH
addMissionEventHandler ["MapSingleClick", {
params ["_units", "_pos", "_alt", "_shift"];
}];
- units: Array - leader selected units, same as groupSelectedUnits (same as _units param)
- pos: Array - world Position3D of the click in format [x,y,0] (same as _pos param)
- alt: Boolean - true if Alt key was pressed (same as _alt param)
- shift: Boolean - true if Shift key was pressed (same as _shift param)
PlayerConnected
Executes assigned code when client joins the mission in MP. Stackable version of onPlayerConnected.
If dedicated server was started without '-autoInit' option and this EH was created on server, on first GUI client this EH also fires against server, but after first client.
In mission's initServer.sqf:
handlercon = addMissionEventHandler ["PlayerConnected",
{
diag_log "Client connected";
diag_log _this;
}];
In RPT:
2016/12/16, 15:39:09 "Client connected"
2016/12/16, 15:39:09 [5.21041e+007,"7xxxxxxxxxxxxxxx1","longbow",false,4]
2016/12/16, 15:39:34 Mission id: 5071d20b183e9580d0ee4f95f413ca18681d6165
2016/12/16, 15:39:34 "Client connected"
2016/12/16, 15:39:34 [2,"","__SERVER__",false,2]
That happens only for GUI clients, if HC client connects first, EH does not fire for server.
If dedicated server was started with -autoInit option, this EH does not fire against server, only for future clients, and all further clients appear to be JIPped.
Interesting moment for headless clients, for headless clients instead of getPlayerUID, handler gets string like "HC12160", where '12160' is headless client process ID (matches HC's PID observed in windows task manager)
addMissionEventHandler ["PlayerConnected", {
params ["_id", "_uid", "_name", "_jip", "_owner"];
}];
- id: Number - unique DirectPlay ID (very large number). It is also the same id used for user placed markers (same as _id param)
- uid: String - getPlayerUID of the joining client. The same as Steam ID (same as _uid param)
- name: String - profileName of the joining client (same as _name param)
- jip: Boolean - didJIP of the joining client (same as _jip param)
- owner: Number - owner id of the joining client (same as _owner param)
PlayerDisconnected
Executes assigned code when client leaves the mission in MP. Stackable version of onPlayerDisconnected.
addMissionEventHandler ["PlayerDisconnected", {
params ["_id", "_uid", "_name", "_jip", "_owner"];
}];
- id: Number - unique DirectPlay ID (very large number). It is also the same id used for user placed markers (same as _id param)
- uid: String - getPlayerUID of the leaving client. The same as Steam ID (same as _uid param)
- name: String - profileName of the leaving client (same as _name param)
- jip: Boolean - didJIP of the leaving client (same as _jip param)
- owner: Number - owner id of the leaving client (same as _owner param)
PlayerViewChanged
Fired on player view change. Player view changes when player is changing body due to teamSwitch, gets in out of a vehicle or operates UAV for example.
addMissionEventHandler ["PlayerViewChanged", {
params [
"_oldUnit", "_newUnit", "_vehicle",
"_oldCamera", "_newCamera", "_uav"
];
}];
- oldBody: Object - player body before EH fired
- newBody: Object - player body after EH fired
- vehicleIn: Object - vehicle player is in (objNull if not in vehicle)
- oldCameraOn: Object - cameraOn before EH fired
- newCameraOn: Object - cameraOn after EH fired
- UAV: Object - UAV reference if player is operating one (objNull if not operating UAV)
PreloadStarted
Executes assigned code before the mission preload screen. Stackable version of onPreloadStarted.
addMissionEventHandler ["PreloadStarted", {
// no params
}];
PreloadFinished
Executes assigned code after the mission preload screen. Stackable version of onPreloadFinished.
addMissionEventHandler ["PreloadFinished", {
// no params
}];
TeamSwitch
Executes assigned code when player teamswitches. Stackable version of onTeamSwitch.
addMissionEventHandler ["TeamSwitch", {
params ["_previousUnit", "_newUnit"];
}];