Home   Help Search Login Register  

Author Topic: Script for Random Task not working with F2  (Read 1619 times)

0 Members and 1 Guest are viewing this topic.

Offline psvialli

  • Members
  • *
Script for Random Task not working with F2
« on: 17 Nov 2010, 09:09:25 »
Hi guys,

I am trying to implement a random tasks into F2 I have placed the code in the init but I get nothing no tasks appear, it works if I create a new mission without F2 and pop it into the init any idea why it would not work when i put it in the init when using F2 ?

Code

//taskCount = paramsarray select 0;
taskCount = 6;

fncAddTask = {
switch _this do {
case 0: {
tskobj_1 = player createsimpletask ["task1"];
tskobj_1 setsimpletaskdescription ["1","1","1"];
player setcurrenttask tskobj_1;
};
case 1: {
tskobj_2 = player createsimpletask ["task2"];
tskobj_2 setsimpletaskdescription ["2","2","2"];
player setcurrenttask tskobj_2;
};
case 2: {
tskobj_3 = player createsimpletask ["task3"];
tskobj_3 setsimpletaskdescription ["3","3","3"];
player setcurrenttask tskobj_3;
};
case 3: {
tskobj_4 = player createsimpletask ["task4"];
tskobj_4 setsimpletaskdescription ["4","4","4"];
player setcurrenttask tskobj_4;
};
case 4: {
tskobj_5 = player createsimpletask ["task5"];
tskobj_5 setsimpletaskdescription ["5","5","5"];
player setcurrenttask tskobj_5;
};
case 5: {
tskobj_6 = player createsimpletask ["task6"];
tskobj_6 setsimpletaskdescription ["6","6","6"];
player setcurrenttask tskobj_6;
};
};
};
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


Many thanks