Jump to content
Sign in to follow this  
1para{god-father}

How to use Task with a trigger

Recommended Posts

I have 5 Tasks that I am using but I want to trigger something if it is set to say task 3 how can i use this in the condition of a trigger ?

using tskobj_1,tskobj_2,tskobj_3 etc..

Thanks

Share this post


Link to post
Share on other sites

Tasks Demo

You'd use taskState to check the current state of a task.

Condition:

taskState tskSomeTask == "Succeeded"

OnAct:

hint "Some task is finished!";

Though really, you manually complete a task, so you could just do whatever your trigger is waiting for at the same time. No need for the trigger, just make it part of the completing task thing.

Edited by kylania

Share this post


Link to post
Share on other sites
I have 5 Tasks that I am using but I want to trigger something if it is set to say task 3 how can i use this in the condition of a trigger ?

using tskobj_1,tskobj_2,tskobj_3 etc..

Thanks

In your init.sqf file make:

myNameTask1 = false;
myNameTask2 = false;
myNameTask3 = false;
myNameTask4 = false;
myNameTask5 = false;

Then whenever you activate any of your tasks, example task 3: make sure

myNameTask3 = true;

is set somewhere in either trigger or script that creates task 3.

Then create a trigger checking for if myNameTask3 is true.

Trigger setup:

Condition: myNameTask3

On activation field alternative 1:

scud setpos getpos anyObjectname;

alternative 2:

_null = [] execVM "anyScript.sqf";

Not sure if i totally understand what you are asking, if this was not it, please specify your question.

---------- Post added at 07:00 PM ---------- Previous post was at 06:56 PM ----------

Tasks Demo

You'd use taskState to check the current state of a task.

Condition:

taskState tskSomeTask == "Succeeded"

OnAct:

hint "Some task is finished!";

Though really, you manually complete a task, so you could just do whatever your trigger is waiting for at the same time. No need for the trigger, just make it part of the completing task thing.

This link from kylania is actually where i first sucessfully created and understood tasks :)

Share this post


Link to post
Share on other sites

Thanks guys,

The problem is I am using Random Tasks I have tried the following but myNameTask1 allways stays False. it never turns true ?

Is there a way that I can check to see what the currents task ?

--------------------------------

myNameTask1 = false;

publicvariable "myNameTask1";

///////////////RANDOM TASKS////////////////////

taskCount = paramsarray select 5;

fncAddTask = {

switch _this do {

case 0: {

tskobj_1 = player createSimpleTask["Clear camera"];

tskobj_1 setSimpleTaskDescription ["1", "1", "1"];

tskobj_1 setSimpleTaskDestination (getMarkerPos "camara");

player setcurrenttask tskobj_1;

myNameTask1 = true;

};

case 1: {

tskobj_2 = player createSimpleTask["Pinley and clear the Town"];

tskobj_2 setSimpleTaskDescription ["2", "2", "2"];

tskobj_2 setSimpleTaskDestination (getMarkerPos "pinley");

player setcurrenttask tskobj_2;

tskobj_1 = true;

myNameTask1 = true;

};

case 2: {

tskobj_3 = player createSimpleTask["Clear Barracks"];

tskobj_3 setSimpleTaskDescription ["3", "3", "3"];

tskobj_3 setSimpleTaskDestination (getMarkerPos "barracks");

player setcurrenttask tskobj_3;

myNameTask1 = true;

};

case 3: {

tskobj_4 = player createSimpleTask["Rescue Reporter"];

tskobj_4 setSimpleTaskDescription ["4 ", "4", "4"];

tskobj_4 setSimpleTaskDestination (getMarkerPos "airport");

player setcurrenttask tskobj_4;

myNameTask1 = true;

};

case 4: {

tskobj_5 = player createSimpleTask["mainropad"];

tskobj_5 setSimpleTaskDescription ["5", "5", "5"];

tskobj_5 setSimpleTaskDestination (getMarkerPos "mainraod");

player setcurrenttask tskobj_5;

myNameTask1 = true;

};

};

};

fncPickTask = {

if isserver then {

if (count tasks == 0) then {

theEnd = true;

publicvariable "theEnd";

} else {

addTask = tasks select (floor random count tasks);

tasks = tasks - [addTask];

publicvariable "addTask";

if !isdedicated then { addTask call fncAddTask };

};

};

};

theEnd = false;

if isserver then {

tasks = [];

for "_i" from 0 to (taskCount - 1) do {

tasks set [_i,_i];

};

} else {

[] spawn {

waituntil {!isnil "addTask"};

addTask call fncAddTask;

"addTask" addpublicvariableeventhandler {(_this select 1) call fncAddTask};

};

};

call fncPickTask; // add first task for briefing

Share this post


Link to post
Share on other sites
Thanks guys,

The problem is I am using Random Tasks I have tried the following but myNameTask1 allways stays False. it never turns true ?

Is there a way that I can check to see what the currents task ?

--------------------------------

myNameTask1 = false;

publicvariable "myNameTask1";

///////////////RANDOM TASKS////////////////////

taskCount = paramsarray select 5;

fncAddTask = {

switch _this do {

case 0: {

tskobj_1 = player createSimpleTask["Clear camera"];

tskobj_1 setSimpleTaskDescription ["1", "1", "1"];

tskobj_1 setSimpleTaskDestination (getMarkerPos "camara");

player setcurrenttask tskobj_1;

myNameTask1 = true;

};

case 1: {

tskobj_2 = player createSimpleTask["Pinley and clear the Town"];

tskobj_2 setSimpleTaskDescription ["2", "2", "2"];

tskobj_2 setSimpleTaskDestination (getMarkerPos "pinley");

player setcurrenttask tskobj_2;

tskobj_1 = true;

myNameTask1 = true;

};

case 2: {

tskobj_3 = player createSimpleTask["Clear Barracks"];

tskobj_3 setSimpleTaskDescription ["3", "3", "3"];

tskobj_3 setSimpleTaskDestination (getMarkerPos "barracks");

player setcurrenttask tskobj_3;

myNameTask1 = true;

};

case 3: {

tskobj_4 = player createSimpleTask["Rescue Reporter"];

tskobj_4 setSimpleTaskDescription ["4 ", "4", "4"];

tskobj_4 setSimpleTaskDestination (getMarkerPos "airport");

player setcurrenttask tskobj_4;

myNameTask1 = true;

};

case 4: {

tskobj_5 = player createSimpleTask["mainropad"];

tskobj_5 setSimpleTaskDescription ["5", "5", "5"];

tskobj_5 setSimpleTaskDestination (getMarkerPos "mainraod");

player setcurrenttask tskobj_5;

myNameTask1 = true;

};

};

};

fncPickTask = {

if isserver then {

if (count tasks == 0) then {

theEnd = true;

publicvariable "theEnd";

} else {

addTask = tasks select (floor random count tasks);

tasks = tasks - [addTask];

publicvariable "addTask";

if !isdedicated then { addTask call fncAddTask };

};

};

};

theEnd = false;

if isserver then {

tasks = [];

for "_i" from 0 to (taskCount - 1) do {

tasks set [_i,_i];

};

} else {

[] spawn {

waituntil {!isnil "addTask"};

addTask call fncAddTask;

"addTask" addpublicvariableeventhandler {(_this select 1) call fncAddTask};

};

};

call fncPickTask; // add first task for briefing

Have you added the myNameTask1,2,3,4,5 = false to your initfile, or in a trigger prior to any task script being run?

Why do you have myNameTask1 = true in all your tasks?

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
Sign in to follow this  

×