{"name":"addMissionEventHandler","operator":null,"title":"addMissionEventHandler","type":"command","url":"https://community.bistudio.com/wiki/addMissionEventHandler","revid":377813,"updated":"2026-01-03T04:12:00Z","groups":["Event Handlers"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"arma3","name":"Arma 3","version":"0.50"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":"local","server_exec":false},"exec":null,"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]","since":null,"effect":null,"exec":null,"params":[{"name":"event","type":"String","optional":false,"default":null,"description":"event name","types":["String"],"since":null,"text":"event: String - event name"},{"name":"expression","type":"Code or String","optional":false,"default":null,"description":"expression that will be executed in missionNamespace when event handler fires.\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","types":["Code","String"],"since":null,"text":"expression: Code or String - expression that will be executed in missionNamespace when event handler fires.\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"},{"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.","types":["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","types":["Number"],"description":"the index of the currently added mission event handler is returned","text":"Number - the index of the currently added mission event handler is returned"},"form":"unary","operator":null,"left":null,"right":{"text":"[event, expression, arguments]","types":["Array"]}}],"examples":[{"text":"```sqf\n_id = addMissionEventHandler [\"PlayerDisconnected\", { systemChat str _this }];\n```","code":["_id = addMissionEventHandler [\"PlayerDisconnected\", { systemChat str _this }];"]},{"text":"```sqf\n_id = addMissionEventHandler [\"EachFrame\", { systemChat str [_thisArgs, time] }, [time]];\n```","code":["_id = addMissionEventHandler [\"EachFrame\", { systemChat str [_thisArgs, time] }, [time]];"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["removeMissionEventHandler","removeAllMissionEventHandlers","getEventHandlerInfo"],"notes":[],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: Event Handlers","Introduced with Arma 3 version 0.50","Scripting Commands","Scripting Commands: Local Effect"]}