Jump to content
ThomasRW

[SOLVED] Wrong return value for task state

Recommended Posts

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
7 hours ago, pierremgi said:

Let's see your code.

I've tried it via the 3d editor. Here is what I did:

 

  1. Placed a "Create Task" module and changed the following attributes
    1. Variable Name: sometask01 (never used)
    2. Owner: All playable units
    3. Task ID: 0001
    4. State: Created
  2. Placed a "Set Task State" module
    1. State: succeeded
  3. Placed a trigger
    1. Type: None
    2. Activation: Any Player
    3. Activation Type: Present
  4. Linked "Set Task State" module to the trigger
  5. Placed new trigger (to monitor task state "created")
    1. Type: None
    2. Activation: None
    3. Condition: "0001" call BIS_fnc_taskState == "CREATED"
    4. On Activation: hint format["Task is been %1", "0001" call BIS_fnc_taskState];
    5. On Deactivation: hint "Task is no longer CRTEATED";
  6. Place third trigger (to monitor task state "assigned")
    1. all same but condition changed to: "0001" call BIS_fnc_taskState == "ASSIGNED"
  7. Placed the fourth trigger (to monitor task state "succeeded")
    1. again everything is the same but condition changed to: "0001" call BIS_fnc_taskState == "SUCCEEDED"

 

The Result:

  1. Task Created: Hint with "Task is been CREATED"
  2. Task Assigned: Hint with "Task is been CREATED" (So it does not change)
  3. 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

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"}
}];

 

 

 

 

  • Like 2

Share this post


Link to post
Share on other sites
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"; };
}];

 

  • Like 1

Share this post


Link to post
Share on other sites

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×