{"name":"BIS_fnc_taskHandler","title":"BIS fnc taskHandler","type":"function","url":"https://community.bistudio.com/wiki/BIS_fnc_taskHandler","revid":379574,"updated":"2026-10-31T14:02:31Z","groups":["Tasks"],"status":"ok","games":{"arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"arma2 1.00","arma3_since":"0.50","description":"Task handler: automatically sets a unit's current task. Whenever the unit receives a new task or a task is completed, the uncompleted task with the highest priority (lowest number) becomes current; among tasks of equal priority, the one with the nearest destination is chosen.\nThe function is meant to be called by mission scripts; no Arma 3 script calls it. It must be called where the unit is local:\n\n- the handler (*A3\\functions_f\\misc\\fn_taskHandler.fsm*) is started only if the unit or a member of its group is a player, and only once per group;\n- it ends when the unit dies or when its \"BIS_taskHandler_stop\" variable is set to true, and is restarted for the new unit after respawn;\n- if AI tasks are enabled (*BIS_missionScope* variable \"BIS_useAITasks\" is true or an array containing the unit), *A3\\functions_f\\misc\\fn_AITasks.fsm* is started for the unit as well; on the server it is started for a non-local unit once the unit becomes local (e.g. after its player disconnects).\n\n> [!IMPORTANT]\n> This is legacy Arma 2 code: it only handles tasks created through the Arma 2 Multiplayer Framework (stored in *BIS_missionScope*) and sets the current task through the framework function *RE*, which is not part of Arma 3's Functions Library. For Arma 3 tasks see Arma 3: Task Framework.","syntaxes":[{"syntax":"[unit, taskPriorities] call BIS_fnc_taskHandler","params":[{"name":"unit","type":"Object","description":"unit whose tasks are handled","type_expr":"Object"},{"name":"taskPriorities","type":"Array of Arrays in format [taskLink, priority]:","description":"Array of Arrays in format [taskLink, priority]:\n\n- taskLink: String - link (variable name) of a task created through the Multiplayer Framework\n- priority: Number - task priority; a lower number means a higher priority","type_expr":"Array<Array>","text":"taskPriorities: Array of Arrays in format [taskLink, priority]:\n\n- taskLink: String - link (variable name) of a task created through the Multiplayer Framework\n- priority: Number - task priority; a lower number means a higher priority"}],"returns":{"type":"Nothing","type_expr":"Nothing"}}],"examples":[{"text":"```sqf\n[\n    BIS_cooper,\n    [\n        [\"objShaftoe\", 1],\n        [\"objEscortLagushina\", 1],\n        [\"objRescueCrew\", 2],\n        [\"objGorka\", 3],\n        [\"objFindBase\", 4]\n    ]\n] call BIS_fnc_taskHandler;\n```","code":["[\n\tBIS_cooper,\n\t[\n\t\t[\"objShaftoe\", 1],\n\t\t[\"objEscortLagushina\", 1],\n\t\t[\"objRescueCrew\", 2],\n\t\t[\"objGorka\", 3],\n\t\t[\"objFindBase\", 4]\n\t]\n] call BIS_fnc_taskHandler;"]},{"text":"Stop the handler for a unit:\n\n```sqf\nBIS_cooper setVariable [\"BIS_taskHandler_stop\", true];\n```","code":["BIS_cooper setVariable [\"BIS_taskHandler_stop\", true];"]}],"see_also":["currentTask","setCurrentTask","simpleTasks","Arma 3: Task Framework"]}