createSimpleTask: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (template:command argument fix)
m (Some wiki formatting)
 
(84 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma2 |= Game name
|game1= arma2
|version1= 1.00


|1.00|= Game version
|game2= arma2oa
|version2= 1.50


|arg= global |= Arguments in MP
|game3= tkoh
|version3= 1.00


|eff= local |= Effects in MP
|game4= arma3
____________________________________________________________________________________________
|version4= 0.50


| Creates a new [[Task]]. The task effect is [[local]], it will only exist on the client it was added.
|gr1= Briefing
<br>
{{Important|Using the '''[[Arma 3 Task Framework]]''' instead is recommended}}|= Description
____________________________________________________________________________________________


| person '''createSimpleTask''' [name, ''parentTask'']|= Syntax
|arg= global


|p1= person: [[Object]] -  Unit to add this new task |PARAMETER1=
|eff= local
|p2= [name, parentTask]: [[Array]] |=
|p3= name: [[String]] |PARAMETER2=
|p4= ''parentTask'' (Optional): [[Task]] |PARAMETER3=  


| [[Task]] - the new task |RETURNVALUE=
|descr= Creates a new [[Task]] and adds it to the Diary.
{{Feature|Arma3|Using the '''[[Arma 3: Task Framework]]''' instead is recommended}}
{{Feature|informative|When task is added as a child, it appears as subcategory to the parent task in the Tasks menu and can be parent to another child task. However this is cosmetic appearance as each task has own id and can be referenced directly via diary link.}}


|mp= The task effect is [[Multiplayer Scripting#Locality|local]], it will only exist on the client it was added.


|x1= <code>_currentTask = [[player]] [[createSimpleTask]] ["NewTask"];</code>|EXAMPLE1=
|s1= unit [[createSimpleTask]] [name, parentTask]
|x2= <code>_childTask = [[player]] [[createSimpleTask]] ["ChildTask", _currentTask];</code>|EXAMPLE2=


____________________________________________________________________________________________
|p1= unit: [[Object]] - unit to add this new task


| [[Tasks]], [[simpleTasks]], [[briefing]], [[removeSimpleTask]], [[setSimpleTaskDescription]], [[setSimpleTaskDestination]], [[setTaskState]], [[setTaskResult]], [[taskState]] |SEEALSO=
|p2= name: [[String]]


| |MPBEHAVIOUR=  
|p3= parentTask: [[Task]] - (Optional, [[taskNull]]) - The new task will be a sub task of the parent task
____________________________________________________________________________________________
 
|r1= [[Task]] - the new task
 
|x1= <sqf>_currentTask = player createSimpleTask ["NewTask"];</sqf>
 
|x2= <sqf>_childTask = player createSimpleTask ["ChildTask", _currentTask];</sqf>
 
|seealso= [[simpleTasks]] [[removeSimpleTask]] [[setSimpleTaskDescription]] [[setSimpleTaskDestination]] [[setTaskState]] [[setTaskResult]] [[taskState]] [[Tasks]] [[Briefing]]
}}
}}


<h3 style='display:none'>Notes</h3>
{{Note
<dl class='command_description'>
|user= Lou Montana
<!-- Note Section BEGIN -->
|timestamp= 20110702114500
<dd class="notedate">Posted on July 02, 2011 - 11:45 (GMT+1)
|text=
<dt class="note">[[User:Lou Montana|Lou Montana]]<dd class="note">
* Creating child will position the new task just under the parent task.
*Creating child will position the new task just under the parent task.
* Creating another "normal" (parent) task will create a new line '''above''' the others. Think of it if you want ordered objectives.
*Creating another "normal" (parent) task will create a new line '''above''' the others. Think of it if you want ordered objectives.
* Succeeding parent task will automatically succeed childs, whatever their [[taskState]] was set to. (I.E. If a task is set as a child to another, it will be completed when its parent is complete.. no matter if the child task really was or not).
*Succeeding parent task will automatically succeed childs, whatever their [[taskState]] was set to. (I.E. If a task is set as a child to another, it will be completed when its parent is complete.. no matter if the child task really was or not).
* This command has to be executed again for it to be applied for JIP players - no server sync<br><br>
*This command has to be executed again for it to be applied for JIP players - no server sync<br><br>
Full step by step code from beginning to end:<br>
Full step by step code from beginning to end:<br>
'''Step 1: create a new simpleTask'''
'''Step 1: create a new simpleTask'''
<code>
<sqf>MySimpleTask = player createSimpleTask [(localize "STR_aSimpleTask")];</sqf>
A_SIMPLE_TASK = [[player]] [[createSimpleTask]] [([[localize]] "STR_aSimpleTask")];
</code>
You may create a task at any given point in time. You just need to be aware of the fact, that you've created the task for a single unit (the player). So if you make use of teamSwitch, respawn or similiar, you need to think about how to manage this, so all of these units will have up to date tasks assigned to them.
You may create a task at any given point in time. You just need to be aware of the fact, that you've created the task for a single unit (the player). So if you make use of teamSwitch, respawn or similiar, you need to think about how to manage this, so all of these units will have up to date tasks assigned to them.
Second, it's a good practice to use a stringtable, even if you do not plan (yet) to offer translations.<br>
Second, it is a good practice to use a stringtable, even if you do not plan (yet) to offer translations.<br>
'''Step 2: task destination'''<br>
'''Step 2: task destination'''<br>
<code>
<sqf>MySimpleTask setSimpleTaskDestination _destination;</sqf>
A_SIMPLE_TASK [[setSimpleTaskDestination]] _destination;
</code>
variable/pointer-to-your-task setSimpleTaskDestination some-position. That's it.<br>
variable/pointer-to-your-task setSimpleTaskDestination some-position. That's it.<br>
'''Step 3: task description'''
'''Step 3: task description'''
<code>
<sqf>
A_SIMPLE_TASK [[setSimpleTaskDescription]] [
MySimpleTask setSimpleTaskDescription [
  ([[localize]] "STR_aSimpleTaskLongText"),
localize "STR_aSimpleTaskLongText",
  ([[localize]] "STR_aSimpleTask"),
localize "STR_aSimpleTask",
  ([[localize]] "STR_aSimpleTaskWaypointLabel")
localize "STR_aSimpleTaskWaypointLabel"
];
];
</code>
</sqf>
Again, no magic involved here. You take your task, the command setSimpleTaskDescription an pass an array with three strings in it. The first string is the long description text, the second is the name/title of the task and the last one will show up on-screen on the waypoint in cadet mode.<br>
 
Again, no magic involved here. You take your task, the command setSimpleTaskDescription an pass an array with three strings in it.
The first string is the long description text, the second is the name/title of the task and the last one will show up on-screen on the waypoint in cadet mode.<br>
'''Step 4: set and update task states'''
'''Step 4: set and update task states'''
<code>
<sqf>MySimpleTask setTaskState "CREATED";</sqf>
A_SIMPLE_TASK [[setTaskState]] "CREATED";
</code>
And that's it. Here a minimal working example:
And that's it. Here a minimal working example:
<code>
<sqf>
A_SIMPLE_TASK = [[player]] [[createSimpleTask]] ["simple task title"];
MySimpleTask = player createSimpleTask ["simple task title"];
A_SIMPLE_TASK [[setSimpleTaskDestination]] ([[position]] [[player]]);
MySimpleTask setSimpleTaskDestination (position player);
A_SIMPLE_TASK [[setSimpleTaskDescription]] [
MySimpleTask setSimpleTaskDescription [
  "simple task long description",
"simple task long description",
  "simple task title",
"simple task title",
  "simple task waypoint label"
"simple task waypoint label"
];
];
A_SIMPLE_TASK [[setTaskState]] "CREATED";
MySimpleTask setTaskState "CREATED";
</code>
</sqf>
 
And then later in the mission:
And then later in the mission:
<code>
<sqf>MySimpleTask setTaskState "SUCCEEDED";</sqf>
A_SIMPLE_TASK [[setTaskState]] "SUCCEEDED";
 
</code>
If you want to keep the player in the loop about the status of tasks, you may always do this:
If you want to keep the player in the loop about the status of tasks, you may always do this:
<code>
<sqf>[objNull, objNull, MySimpleTask, "SUCCEEDED"] execVM "CA\Modules\MP\data\scriptCommands\taskHint.sqf";</sqf>
[ [[objNull]], [[objNull]], A_SIMPLE_TASK, "SUCCEEDED"] [[execVM]] "CA\Modules\MP\data\scriptCommands\taskHint.sqf";
}}
</code>
<!-- Note Section END -->
</dl>
 
 
 
<h3 style='display:none'>Bottom Section</h3>
[[Category:ArmA 2: New Scripting Commands List|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
[[Category:Command_Group:_Briefing|{{uc:{{PAGENAME}}}}]]

Latest revision as of 13:09, 12 March 2024

Hover & click on the images for description

Description

Description:
Creates a new Task and adds it to the Diary.
Arma 3
Using the Arma 3: Task Framework instead is recommended
When task is added as a child, it appears as subcategory to the parent task in the Tasks menu and can be parent to another child task. However this is cosmetic appearance as each task has own id and can be referenced directly via diary link.
Multiplayer:
The task effect is local, it will only exist on the client it was added.
Groups:
Briefing

Syntax

Syntax:
unit createSimpleTask [name, parentTask]
Parameters:
unit: Object - unit to add this new task
name: String
parentTask: Task - (Optional, taskNull) - The new task will be a sub task of the parent task
Return Value:
Task - the new task

Examples

Example 1:
_currentTask = player createSimpleTask ["NewTask"];
Example 2:
_childTask = player createSimpleTask ["ChildTask", _currentTask];

Additional Information

See also:
simpleTasks removeSimpleTask setSimpleTaskDescription setSimpleTaskDestination setTaskState setTaskResult taskState Tasks Briefing

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 Jul 02, 2011 - 11:45 (UTC)
  • Creating child will position the new task just under the parent task.
  • Creating another "normal" (parent) task will create a new line above the others. Think of it if you want ordered objectives.
  • Succeeding parent task will automatically succeed childs, whatever their taskState was set to. (I.E. If a task is set as a child to another, it will be completed when its parent is complete.. no matter if the child task really was or not).
  • This command has to be executed again for it to be applied for JIP players - no server sync

Full step by step code from beginning to end:
Step 1: create a new simpleTask
MySimpleTask = player createSimpleTask [(localize "STR_aSimpleTask")];
You may create a task at any given point in time. You just need to be aware of the fact, that you've created the task for a single unit (the player). So if you make use of teamSwitch, respawn or similiar, you need to think about how to manage this, so all of these units will have up to date tasks assigned to them. Second, it is a good practice to use a stringtable, even if you do not plan (yet) to offer translations.
Step 2: task destination
MySimpleTask setSimpleTaskDestination _destination;
variable/pointer-to-your-task setSimpleTaskDestination some-position. That's it.
Step 3: task description
MySimpleTask setSimpleTaskDescription [ localize "STR_aSimpleTaskLongText", localize "STR_aSimpleTask", localize "STR_aSimpleTaskWaypointLabel" ];
Again, no magic involved here. You take your task, the command setSimpleTaskDescription an pass an array with three strings in it. The first string is the long description text, the second is the name/title of the task and the last one will show up on-screen on the waypoint in cadet mode.
Step 4: set and update task states
MySimpleTask setTaskState "CREATED";
And that's it. Here a minimal working example:
MySimpleTask = player createSimpleTask ["simple task title"]; MySimpleTask setSimpleTaskDestination (position player); MySimpleTask setSimpleTaskDescription [ "simple task long description", "simple task title", "simple task waypoint label" ]; MySimpleTask setTaskState "CREATED";
And then later in the mission:
MySimpleTask setTaskState "SUCCEEDED";
If you want to keep the player in the loop about the status of tasks, you may always do this:
[objNull, objNull, MySimpleTask, "SUCCEEDED"] execVM "CA\Modules\MP\data\scriptCommands\taskHint.sqf";