BIS fnc taskCreate: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (see also)
m (Fix)
 
(61 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{RV|type=function


{{Function|= Comments
|game1= arma3
____________________________________________________________________________________________
|version1= 1.00


| arma3 |= Game name
|gr1= Tasks


|1.00|= Game version
|arg= global
____________________________________________________________________________________________
|eff= global


| <pre>/*
|descr= Create a task.


Description:
|s1= [owner, taskID, description, destination, state, priority, showNotification, type, visibleIn3D] call [[BIS_fnc_taskCreate]]
Create a task.


Parameters:
|p1= '''owner''': Task owner(s)
0: BOOL or OBJECT or GROUP or SIDE or ARRAY - Task owner(s)
* [[Boolean]] - true to set task of all playable units
1: STRING or ARRAY - Task name or array in the format [task name, parent task name]
* [[Object]] - set task of a specific object
2: ARRAY or STRING - Task description in the format ["description", "title", "marker"] or CfgTaskDescriptions class
* [[Group]] - set tasks of all objects in the group
3: OBJECT or ARRAY or STRING - Task destination
* [[Side]] - set tasks of all objects of the given side
4: BOOL or NUMBER or STRING - Task state (or true to set as current)
* [[Array]] - collection of above types
5: NUMBER - Task priority (when automatically selecting a new current task, higher priority is selected first)
6: BOOL - Show notification (default: true)
7: STRING - Task type as defined in the CfgTaskTypes
8: BOOL - Should the task being shared (default: false), if set to true, the assigned players are being counted


Returns:
|p2= '''taskID''':
BOOL
* [[String]] - Task ID
*/
* [[Array]] - In the format of [task ID, parent task ID]


</pre><small>''(Placeholder description extracted from the function header by [[BIS_fnc_exportFunctionsToWiki]])''</small> |= Description
|p3= '''description''':
____________________________________________________________________________________________
* [[Array]] - Task description in the format ["description", "title", "marker"] - "marker" is depreciated, functionally does nothing
** Description and Title can also be a [[format]] array [ "Text", var1, var2, ... ] where Text will be localized and then formatted per client, see {{Link|#Example 4}}
* [[String]] - [[Description.ext#CfgTaskDescriptions|CfgTaskDescriptions]] class name, if empty string is used then [[Description.ext#CfgTaskDescriptions|CfgTaskDescriptions]] is searched for a class matching the tasks TaskID


| <!-- [] call [[BIS_fnc_taskCreate]]; --> |= Syntax
|p4= '''destination''' (Optional): Task destination
* [[Object]] - Use [[objNull]] to set no position
* [[Array]] - can be one of:
** format [[Position]]
** [target, precision] (as used by [[setSimpleTaskTarget]])
*** target: [[Object]]
*** precision: [[Boolean]] - [[false]] to use ''owner''<nowiki/>'s knowledge of ''target'', [[true]] to force display even if ''target'' is unknown to ''owner''


|p1= |= Parameter 1
|p5= '''state''': (Optional, default "CREATED") task state. Can be:
* [[String]] - can be one of following:
** "CREATED"
** "ASSIGNED"
** "AUTOASSIGNED" ("ASSIGNED" when no task is assigned yet, otherwise "CREATED")
** "SUCCEEDED"
** "FAILED"
** "CANCELED"
* [[Boolean]] - [[true]] to set the task as current
* [[Number]]
** 0 or less for [[false]]
** > 0 as [[true]]


| |= Return value
|p6= '''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.
____________________________________________________________________________________________


|x1= <code><nowiki>[</nowiki>[[civilian]],["task1"],["Do this and you get a cookie","Earn Cookie","cookiemarker"],[0,0,0],1,2,[[true]]] [[call]] [[BIS_fnc_taskCreate]]</code> |=
|p7= '''showNotification''': [[Boolean]] - (Optional, default [[true]]) true to show notification, false to disable it


|x2= <code><nowiki>[</nowiki>[[west]],["task2"],["Good luck finding this cookie","Find Cookie","cookiemarker2"],[[objNull]],1,3,true] call [[BIS_fnc_taskCreate]] //Task without a map location</code> |=
|p8= '''type''': [[String]] - (Optional, default "") {{Link|Arma 3: Task Framework#Task Icons|vanilla}} or {{Link|Description.ext#CfgTaskTypes|custom}} task type; if not defined, empty (no) type is used
____________________________________________________________________________________________


| [[BIS_fnc_setTask]], [[Arma_3_Task_Framework|Task Framework]] [[Arma_3_Task_Enhancements|Task Enhancements]] |= See also
|p9= '''visibleIn3D''': [[Boolean]] - (Optional, default [[false]]) true to make task always visible in 3D
 
|r1= [[Boolean]]
 
|x1= <sqf>[civilian, "task1", ["Do this and you get a cookie", "Earn Cookie", "cookiemarker"], [0,0,0], "ASSIGNED", 2, true] call BIS_fnc_taskCreate;</sqf>
 
|x2= <sqf>
[west, "parentTask", ["This is the parent task.", "Parent task", "cookiemarker2"], objNull, 1, 3, true] call BIS_fnc_taskCreate;
[west, ["subTask", "parentTask"], ["This is the subTask.", "subTask", "cookiemarker2"], objNull, 1, 3, true] call BIS_fnc_taskCreate;
</sqf>
 
|x3= in [[Description.ext]]
<syntaxhighlight lang="cpp">
class CfgTaskTypes
{
class my_CfgTaskType
{
displayname = "Tank";
icon = "Tank_MCO.paa";
icon3D = "Tank_MCO.paa";
};
};
</syntaxhighlight>
SQF:
<sqf>[east, ["taskType_"], ["Setting taskType", "The simple way", "marker2"], objNull, 1, 3, true, "my_CfgTaskType"] call BIS_fnc_taskCreate; // task with a custom icon</sqf>
 
|x4= in [[Stringtable.xml]]
<syntaxhighlight lang="xml">
<Key ID="STR_CITY_TASK">
<English>Clear %1 of enemies</English>
<!-- more languages -->
</Key>
</syntaxhighlight>
 
SQF:
<sqf>
[
_side,
_taskID,
[
// format array, string to be localised, parameters for format %1, %2 ...
[ "STR_CITY_TASK", _cityName ],
[ "STR_CITY_TASK", _cityName ],
""
]
] call BIS_fnc_taskCreate;</sqf>
 
|seealso= [[Arma 3: Task Framework]]
}}
}}


<h3 style="display:none">Notes</h3>
{{Note
<dl class="command_description">
|user= Lou Montana
<!-- Note Section BEGIN -->
|timestamp= 20180202131500
|text= You can define a [[Description.ext#CfgTaskDescriptions|CfgTaskDescriptions]] part in [[Description.ext|description.ext]], such as:
<syntaxhighlight lang="cpp">
class CfgTaskDescriptions
{
class myTask
{
title = "$STR_MyTaskTitle";
description = "$STR_MyTaskDescription";
};
};
</syntaxhighlight>
This should allow tasks to be localised for every player in MP '''if created locally'''.
You can use "myTask" as ''description'' (3<sup>rd</sup>) parameter.
{{Feature|important|For a proper localisation everywhere, see [[User:Hypoxic125|Hypoxic125]]'s note below.}}
}}


<!-- Note Section END -->
{{Note
</dl>
|user= Hypoxic125
 
|timestamp= 20221113041319
<h3 style="display:none">Bottom Section</h3>
|text= Example of Correct Localization Setup Using CfgTaskDescriptions
[[Category:Function Group: Tasks|{{uc:taskCreate}}]]
<syntaxhighlight lang="cpp">
[[Category:Functions|{{uc:taskCreate}}]]
class CfgTaskDescriptions
[[Category:{{Name|arma3}}: Functions|{{uc:taskCreate}}]]
{
class hyp_infiltrate
{
title = "STR_HYP_TASKS_INFILTRATE_TITLE";
description = "STR_HYP_TASKS_INFILTRATE_DESCRIPTION";
// requires stringtable key - NOT localized string
// note the lack of "$" before the stringtable key - if "$" is included, languages will be incorrect
};
};
</syntaxhighlight>
<sqf>
// Server Execution
[east, "infiltrate", "hyp_infiltrate", objNull, "ASSIGNED", -1, true, "MOVE", false] call BIS_fnc_taskCreate;
</sqf>
}}

Latest revision as of 16:21, 15 October 2024

Hover & click on the images for description

Description

Description:
Create a task.
Execution:
call
Groups:
Tasks

Syntax

Syntax:
[owner, taskID, description, destination, state, priority, showNotification, type, visibleIn3D] call BIS_fnc_taskCreate
Parameters:
owner: Task owner(s)
  • Boolean - true to set task of all playable units
  • Object - set task of a specific object
  • Group - set tasks of all objects in the group
  • Side - set tasks of all objects of the given side
  • Array - collection of above types
taskID:
  • String - Task ID
  • Array - In the format of [task ID, parent task ID]
description:
  • Array - Task description in the format ["description", "title", "marker"] - "marker" is depreciated, functionally does nothing
    • 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
  • String - CfgTaskDescriptions class name, if empty string is used then CfgTaskDescriptions is searched for a class matching the tasks TaskID
destination (Optional): Task destination
state: (Optional, default "CREATED") task state. Can be:
  • String - can be one of following:
    • "CREATED"
    • "ASSIGNED"
    • "AUTOASSIGNED" ("ASSIGNED" when no task is assigned yet, otherwise "CREATED")
    • "SUCCEEDED"
    • "FAILED"
    • "CANCELED"
  • Boolean - true to set the task as current
  • Number
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.
showNotification: Boolean - (Optional, default true) true to show notification, false to disable it
type: String - (Optional, default "") vanilla or custom task type; if not defined, empty (no) type is used
visibleIn3D: Boolean - (Optional, default false) true to make task always visible in 3D
Return Value:
Boolean

Examples

Example 1:
[civilian, "task1", ["Do this and you get a cookie", "Earn Cookie", "cookiemarker"], [0,0,0], "ASSIGNED", 2, true] call BIS_fnc_taskCreate;
Example 2:
[west, "parentTask", ["This is the parent task.", "Parent task", "cookiemarker2"], objNull, 1, 3, true] call BIS_fnc_taskCreate; [west, ["subTask", "parentTask"], ["This is the subTask.", "subTask", "cookiemarker2"], objNull, 1, 3, true] call BIS_fnc_taskCreate;
Example 3:
in Description.ext
class CfgTaskTypes
{
	class my_CfgTaskType
	{
		displayname = "Tank";
		icon = "Tank_MCO.paa";
		icon3D = "Tank_MCO.paa";
	};
};

SQF:

[east, ["taskType_"], ["Setting taskType", "The simple way", "marker2"], objNull, 1, 3, true, "my_CfgTaskType"] call BIS_fnc_taskCreate; // task with a custom icon
Example 4:
in Stringtable.xml
<Key ID="STR_CITY_TASK">
	<English>Clear %1 of enemies</English>
	<!-- more languages -->
</Key>

SQF:

[ _side, _taskID, [ // format array, string to be localised, parameters for format %1, %2 ... [ "STR_CITY_TASK", _cityName ], [ "STR_CITY_TASK", _cityName ], "" ] ] call BIS_fnc_taskCreate;

Additional Information

See also:
Arma 3: Task Framework

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
Lou Montana - c
Posted on Feb 02, 2018 - 13:15 (UTC)
You can define a CfgTaskDescriptions part in description.ext, such as:
class CfgTaskDescriptions
{
	class myTask
	{
		title = "$STR_MyTaskTitle";
		description = "$STR_MyTaskDescription";
	};
};

This should allow tasks to be localised for every player in MP if created locally. You can use "myTask" as description (3rd) parameter.

For a proper localisation everywhere, see Hypoxic125's note below.
Hypoxic125 - c
Posted on Nov 13, 2022 - 04:13 (UTC)
Example of Correct Localization Setup Using CfgTaskDescriptions
class CfgTaskDescriptions
{
	class hyp_infiltrate
	{
		title = "STR_HYP_TASKS_INFILTRATE_TITLE";
		description = "STR_HYP_TASKS_INFILTRATE_DESCRIPTION";
		// requires stringtable key - NOT localized string
		// note the lack of "$" before the stringtable key - if "$" is included, languages will be incorrect
	};
};

// Server Execution [east, "infiltrate", "hyp_infiltrate", objNull, "ASSIGNED", -1, true, "MOVE", false] call BIS_fnc_taskCreate;