addUserActionEventHandler

From Bohemia Interactive Community
Revision as of 17:25, 6 May 2025 by Lou Montana (talk | contribs) (Add _thisEvent's "prone to change" note)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Hover & click on the images for description

Description

Description:
Adds a user action event handler to the current mission and returns its event handler index.
Groups:
Event Handlers

Syntax

Syntax:
addUserActionEventHandler [keyName, event, expression]
Parameters:
keyName: String - action key name - see inputAction/actions
event: String - event name - see UserAction Event Handlers. Can be one of:
  • "Activate"
  • "Deactivate"
  • "Analog"
expression: Code - expression that will be executed in missionNamespace when event handler fires.
The Event Handler index is available as _thisEventHandler during Event Handler code execution.
The magic variable _thisEvent is available in these event handlers but can only return one of these three values:
  • "KeyActivateEH"
  • "KeyDeactivateEH"
  • "KeyAnalogEH"
This is prone to change in Arma 3 v2.20!
Return Value:
Number - the index of the currently added UserAction event handler is returned

Examples

Example 1:
private _ehId = addUserActionEventHandler ["ReloadMagazine", "Activate", { systemChat "reloading!"; }];

Additional Information

See also:
removeUserActionEventHandler removeAllUserActionEventHandlers UserAction Event Handlers

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