{"name":"BIS_fnc_taskCreate","operator":null,"title":"BIS fnc taskCreate","type":"function","url":"https://community.bistudio.com/wiki/BIS_fnc_taskCreate","revid":369829,"updated":"2024-10-15T15:21:45Z","groups":["Tasks"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"1.00"}],"since":{"game":"arma3","name":"Arma 3","version":"1.00"},"arma3_since":"1.00","branch":null,"locality":{"argument":"global","effect":"global","server_exec":false},"exec":null,"description":"Create a task.","syntaxes":[{"syntax":"[owner, taskID, description, destination, state, priority, showNotification, type, visibleIn3D] call BIS_fnc_taskCreate","since":null,"effect":null,"exec":null,"params":[{"name":"owner","type":null,"optional":false,"default":null,"description":"Task owner(s)\n- Boolean - true to set task of all playable units\n- Object - set task of a specific object\n- Group - set tasks of all objects in the group\n- Side - set tasks of all objects of the given side\n- Array - collection of above types","types":[],"since":null,"text":"**owner**: Task owner(s)\n- Boolean - true to set task of all playable units\n- Object - set task of a specific object\n- Group - set tasks of all objects in the group\n- Side - set tasks of all objects of the given side\n- Array - collection of above types"},{"name":"taskID","type":null,"optional":false,"default":null,"description":"- String - Task ID\n- Array - In the format of [task ID, parent task ID]","types":[],"since":null,"text":"**taskID**:\n- String - Task ID\n- Array - In the format of [task ID, parent task ID]"},{"name":"description","type":null,"optional":false,"default":null,"description":"- Array - Task description in the format [\"description\", \"title\", \"marker\"] - \"marker\" is depreciated, functionally does nothing\n  - Description and Title can also be a format array [ \"Text\", var1, var2, ... ] where Text will be localized and then formatted per client, see #Example 4\n- String - CfgTaskDescriptions class name, if empty string is used then CfgTaskDescriptions is searched for a class matching the tasks TaskID","types":[],"since":null,"text":"**description**:\n- Array - Task description in the format [\"description\", \"title\", \"marker\"] - \"marker\" is depreciated, functionally does nothing\n  - Description and Title can also be a format array [ \"Text\", var1, var2, ... ] where Text will be localized and then formatted per client, see #Example 4\n- String - CfgTaskDescriptions class name, if empty string is used then CfgTaskDescriptions is searched for a class matching the tasks TaskID"},{"name":"destination (Optional)","type":"Task destination","optional":false,"default":null,"description":"(Optional): Task destination\n- Object - Use objNull to set no position\n- Array - can be one of:\n  - format Position\n  - [target, precision] (as used by setSimpleTaskTarget)\n    - target: Object\n    - precision: Boolean - false to use *owner*'s knowledge of *target*, true to force display even if *target* is unknown to *owner*","types":[],"since":null,"text":"**destination** (Optional): Task destination\n- Object - Use objNull to set no position\n- Array - can be one of:\n  - format Position\n  - [target, precision] (as used by setSimpleTaskTarget)\n    - target: Object\n    - precision: Boolean - false to use *owner*'s knowledge of *target*, true to force display even if *target* is unknown to *owner*"},{"name":"state","type":null,"optional":true,"default":"\"CREATED\"","description":"task state. Can be:\n- String - can be one of following:\n  - \"CREATED\"\n  - \"ASSIGNED\"\n  - \"AUTOASSIGNED\" (\"ASSIGNED\" when no task is assigned yet, otherwise \"CREATED\")\n  - \"SUCCEEDED\"\n  - \"FAILED\"\n  - \"CANCELED\"\n- Boolean - true to set the task as current\n- Number\n  - 0 or less for false\n  - > 0 as true","types":[],"since":null,"text":"**state**: (Optional, default \"CREATED\") task state. Can be:\n- String - can be one of following:\n  - \"CREATED\"\n  - \"ASSIGNED\"\n  - \"AUTOASSIGNED\" (\"ASSIGNED\" when no task is assigned yet, otherwise \"CREATED\")\n  - \"SUCCEEDED\"\n  - \"FAILED\"\n  - \"CANCELED\"\n- Boolean - true to set the task as current\n- Number\n  - 0 or less for false\n  - > 0 as true"},{"name":"priority","type":"Number","optional":true,"default":null,"description":"priority. When the current task is completed, the system selects the one with the largest priority >= 0. To avoid auto assignment of that task, give it a priority of -1.","types":["Number"],"since":null,"text":"**priority**: Number - (Optional) priority. When the current task is completed, the system selects the one with the largest priority >= 0. To avoid auto assignment of that task, give it a priority of -1."},{"name":"showNotification","type":"Boolean","optional":true,"default":"true","description":"true to show notification, false to disable it","types":["Boolean"],"since":null,"text":"**showNotification**: Boolean - (Optional, default true) true to show notification, false to disable it"},{"name":"type","type":"String","optional":true,"default":"\"\"","description":"vanilla or custom task type; if not defined, empty (no) type is used","types":["String"],"since":null,"text":"**type**: String - (Optional, default \"\") vanilla or custom task type; if not defined, empty (no) type is used"},{"name":"visibleIn3D","type":"Boolean","optional":true,"default":"false","description":"true to make task always visible in 3D","types":["Boolean"],"since":null,"text":"**visibleIn3D**: Boolean - (Optional, default false) true to make task always visible in 3D"}],"returns":{"type":"Boolean","types":["Boolean"],"description":null,"text":"Boolean"}}],"examples":[{"text":"```sqf\n[civilian, \"task1\", [\"Do this and you get a cookie\", \"Earn Cookie\", \"cookiemarker\"], [0,0,0], \"ASSIGNED\", 2, true] call BIS_fnc_taskCreate;\n```","code":["[civilian, \"task1\", [\"Do this and you get a cookie\", \"Earn Cookie\", \"cookiemarker\"], [0,0,0], \"ASSIGNED\", 2, true] call BIS_fnc_taskCreate;"]},{"text":"```sqf\n[west, \"parentTask\", [\"This is the parent task.\", \"Parent task\", \"cookiemarker2\"], objNull, 1, 3, true] call BIS_fnc_taskCreate;\n[west, [\"subTask\", \"parentTask\"], [\"This is the subTask.\", \"subTask\", \"cookiemarker2\"], objNull, 1, 3, true] call BIS_fnc_taskCreate;\n```","code":["[west, \"parentTask\", [\"This is the parent task.\", \"Parent task\", \"cookiemarker2\"], objNull, 1, 3, true] call BIS_fnc_taskCreate;\n[west, [\"subTask\", \"parentTask\"], [\"This is the subTask.\", \"subTask\", \"cookiemarker2\"], objNull, 1, 3, true] call BIS_fnc_taskCreate;"]},{"text":"in Description.ext\n\n```cpp\nclass CfgTaskTypes\n{\n    class my_CfgTaskType\n    {\n        displayname = \"Tank\";\n        icon = \"Tank_MCO.paa\";\n        icon3D = \"Tank_MCO.paa\";\n    };\n};\n```\n\nSQF:\n\n```sqf\n[east, [\"taskType_\"], [\"Setting taskType\", \"The simple way\", \"marker2\"], objNull, 1, 3, true, \"my_CfgTaskType\"] call BIS_fnc_taskCreate; // task with a custom icon\n```","code":["[east, [\"taskType_\"], [\"Setting taskType\", \"The simple way\", \"marker2\"], objNull, 1, 3, true, \"my_CfgTaskType\"] call BIS_fnc_taskCreate; // task with a custom icon"]},{"text":"in Stringtable.xml\n\n```xml\n<Key ID=\"STR_CITY_TASK\">\n    <English>Clear %1 of enemies</English>\n    <!-- more languages -->\n</Key>\n```\n\nSQF:\n\n```sqf\n[\n    _side,\n    _taskID,\n    [\n        // format array, string to be localised, parameters for format %1, %2 ...\n        [ \"STR_CITY_TASK\", _cityName ],\n        [ \"STR_CITY_TASK\", _cityName ],\n        \"\"\n    ]\n] call BIS_fnc_taskCreate;\n```","code":["[\n\t_side,\n\t_taskID,\n\t[\n\t\t// format array, string to be localised, parameters for format %1, %2 ...\n\t\t[ \"STR_CITY_TASK\", _cityName ],\n\t\t[ \"STR_CITY_TASK\", _cityName ],\n\t\t\"\"\n\t]\n] call BIS_fnc_taskCreate;"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["Arma 3: Task Framework"],"notes":[{"user":"Lou Montana","date":"2018-02-02T13:15:00Z","text":"You can define a CfgTaskDescriptions part in description.ext, such as:\n\n```cpp\nclass CfgTaskDescriptions\n{\n    class myTask\n    {\n        title = \"$STR_MyTaskTitle\";\n        description = \"$STR_MyTaskDescription\";\n    };\n};\n```\n\nThis should allow tasks to be localised for every player in MP **if created locally**.\nYou can use \"myTask\" as *description* (3rd) parameter.\n\n> [!IMPORTANT]\n> For a proper localisation everywhere, see Hypoxic125's note below."},{"user":"Hypoxic125","date":"2022-11-13T04:13:19Z","text":"Example of Correct Localization Setup Using CfgTaskDescriptions\n\n```cpp\nclass CfgTaskDescriptions\n{\n    class hyp_infiltrate\n    {\n        title = \"STR_HYP_TASKS_INFILTRATE_TITLE\";\n        description = \"STR_HYP_TASKS_INFILTRATE_DESCRIPTION\";\n        // requires stringtable key - NOT localized string\n        // note the lack of \"$\" before the stringtable key - if \"$\" is included, languages will be incorrect\n    };\n};\n```\n\n```sqf\n// Server Execution\n[east, \"infiltrate\", \"hyp_infiltrate\", objNull, \"ASSIGNED\", -1, true, \"MOVE\", false] call BIS_fnc_taskCreate;\n```"}],"categories":["Arma 3: Functions","Arma 3: New Functions","Function Group: Tasks","Functions","Functions: Global Effect","Introduced with Arma 3 version 1.00"],"docblock":null,"filled_from_docblock":[]}