ThomasRW 1 Posted September 14, 2022 Hey, I have one little problem with the function "BIS_fnc_taskState". My plan is, to do something, when the task a assigned. (for example activating a trigger) To do this, I created a task in 3D-Editor (state: created). According to the return value of the function above, the task is on state "CREATED" at mission start. The problem is now, when I assign the task via the tasks menue while beeing on the map, the state does not change to "ASSIGNED". Shouldn't it change to that state? When the task is completed successful, the state changes to "SUCCEEDED". Is there anything I've overlooked? thanks in advance Thomas Share this post Link to post Share on other sites
pierremgi 4736 Posted September 18, 2022 Let's see your code. Share this post Link to post Share on other sites
ThomasRW 1 Posted September 18, 2022 7 hours ago, pierremgi said: Let's see your code. I've tried it via the 3d editor. Here is what I did: Placed a "Create Task" module and changed the following attributes Variable Name: sometask01 (never used) Owner: All playable units Task ID: 0001 State: Created Placed a "Set Task State" module State: succeeded Placed a trigger Type: None Activation: Any Player Activation Type: Present Linked "Set Task State" module to the trigger Placed new trigger (to monitor task state "created") Type: None Activation: None Condition: "0001" call BIS_fnc_taskState == "CREATED" On Activation: hint format["Task is been %1", "0001" call BIS_fnc_taskState]; On Deactivation: hint "Task is no longer CRTEATED"; Place third trigger (to monitor task state "assigned") all same but condition changed to: "0001" call BIS_fnc_taskState == "ASSIGNED" Placed the fourth trigger (to monitor task state "succeeded") again everything is the same but condition changed to: "0001" call BIS_fnc_taskState == "SUCCEEDED" The Result: Task Created: Hint with "Task is been CREATED" Task Assigned: Hint with "Task is been CREATED" (So it does not change) Task Succeeded: Hint with "Task is been SUCCEEDED" I hope, that is everaything, you need. Share this post Link to post Share on other sites
johnnyboy 3739 Posted September 18, 2022 For assigning, try using BIS_fnc_taskSetCurrent instead. See the Task Framework page for a list of all the task related functions. 1 Share this post Link to post Share on other sites
pierremgi 4736 Posted September 18, 2022 TaskState doesn't work (BI function or command) when you change the state of the task on map, from created to assigned. Very old known issue. Cherry on the cake, you must pay attention for: task,... taskId,... module name. - A task is not a string, not a variable, but a task; (a type apart. Use taskNull for non-existing task) - taskId is a string, at least in BI functions, without quote in module ... (or a number? like in currentTask player returning something like: Task blabla (id 0). here id 0 is for the first parent task I guess ); - module name is a variable. In your case, the condition you can check is: player call BIS_fnc_taskCurrent isEqualTo "0001" for Assigned task (so, as current one) TaskName can help also: taskName currentTask player // will return "0001" instead of: Task 0001 (id 0) So you can use that also in the event handler (in initPlayerLocal.sqf), instead of a trigger: player addEventHandler ["TaskSetAsCurrent", { params ["_unit", "_task"]; if (taskName _task isEqualTo "0001") then {hint "Task 0001 is been ASSIGNED"} }]; 2 Share this post Link to post Share on other sites
Larrow 2779 Posted September 18, 2022 28 minutes ago, pierremgi said: A task is not a string, not a variable, but a task Only if you are using actual tasks. Task Modules and the related BI task functions of the task framework are all based on a STRING (taskID). The framework pretty much hides TASKs away from the end user and replaces them with the use of taskIDs STRING. To turn a framework taskID STRING into its actual TASK use BIS_fnc_taskReal on the ID. player addEventHandler ["TaskSetAsCurrent", { params[ "_unit", "_task" ]; //_task is of type TASK //"0001" ( taskID ) call BIS_fnc_taskReal ( turn taskID STRING(task framework) into its actual related TASK ) if ( _task isEqualTo ( "0001" call BIS_fnc_taskReal ) ) then { hint "Task 0001 is been ASSIGNED"; }; }]; 1 Share this post Link to post Share on other sites
ThomasRW 1 Posted September 19, 2022 Thanks to all of you for the help. I guess, what I tried is working know. It doesn't have full functionallity yet but should be pretty easy to expand. If you find something, I should do different, feel free to comment. (And no.. This script does not make any sense for now. It was testing only) //initPlayerLocal.sqf params ["_player", "_didJIP"]; _player addEventHandler ["TaskSetAsCurrent", { params ["_unit", "_task"]; private _taskName = taskName _task; private _taskState = taskState _task; //Set Task State global, so every Client has the same Task assigned //task 1000 is a dummy task, because I couldn't assign the TaskNull and the EventHandler did'nt triggered everytinme the task was assigned/unassigned if (_taskName != "1000" && _taskName != "DummyTask") then{ switch (_taskState) do{ case "Created": {[_taskName, "CREATED", true] call BIS_fnc_taskSetState;}; case "Assigned": {[_taskName, "CREATED", true] call BIS_fnc_taskSetState; hint format ["Task %1 is %2", _taskName, _taskName call BIS_fnc_taskState]; "1000" call BIS_fnc_taskSetCurrent;}; }; }; }]; Share this post Link to post Share on other sites