{"name":"addMissionEventHandler","title":"addMissionEventHandler","type":"command","url":"https://community.bistudio.com/wiki/addMissionEventHandler","revid":377813,"updated":"2026-01-03T04:12:00Z","groups":["Event Handlers"],"status":"ok","games":{"arma3":"0.50"},"since":"arma3 0.50","arma3_since":"0.50","locality":{"effect":"local"},"description":"Adds event handler attached to the current mission and returns event handler handle. For the list of available mission event handlers see: Arma 3: Mission Event Handlers","syntaxes":[{"syntax":"addMissionEventHandler [event, expression, arguments]","params":[{"name":"event","type":"String","description":"event name","type_expr":"String"},{"name":"expression","type":"Code or String","description":"expression that will be executed in missionNamespace when event handler fires.\n\n- If the event handler has some data to return upon activation they are stored in the `_this` variable\n- Arma 3 v1.64 the event handler's handle is stored in `_thisEventHandler` variable and is available during event handler code execution\n- Arma 3 v2.04 it is possible to pass additional arguments to the EH code via optional param. The *args* are stored in `_thisArgs` variable\n\n> [!IMPORTANT]\n> Only arguments of simple types get proper serialization. Objects, Groups etc will not serialize and appear as NULLs on game load.\n\n- Arma 3 v2.06 the event's name is available from `_thisEvent` variable","type_expr":"Code | String"},{"name":"arguments","type":"Array of Anything","optional":true,"default":"`[]`","description":"additional arguments to be passed to the EH code. Available during code execution via `_thisArgs` variable.","type_expr":"Array<Anything>","since":"arma3 2.04","text":"arguments: Array of Anything - (Optional, default `[]`) additional arguments to be passed to the EH code. Available during code execution via `_thisArgs` variable."}],"returns":{"type":"Number","type_expr":"Number","description":"the index of the currently added mission event handler is returned"},"form":"unary","right":{"text":"[event, expression, arguments]"}}],"examples":[{"code":["_id = addMissionEventHandler [\"PlayerDisconnected\", { systemChat str _this }];"]},{"code":["_id = addMissionEventHandler [\"EachFrame\", { systemChat str [_thisArgs, time] }, [time]];"]}],"see_also":["removeMissionEventHandler","removeAllMissionEventHandlers","getEventHandlerInfo"]}