I'm kinda running against a wall with this problem. What I need to (focus on need to, I can't really do it any other way) do is execute a couple of functions from an external sqf file.
To help illustrate, this is what I'm doing right now:
init.sqf:
Code: Select all
[] call compile preprocessFileLineNumbers "functions.sqf";
Code: Select all
trt_fnc_cleanup = {
private ["_group1","_group2"];
_group1 = _this select 0;
_group2 = _this select 1;
sleep 0.5;
{deletevehicle _x} foreach units _group1 + units _group2;
};
trt_fnc_cleanup_1 = {
private ["_group1","_script","_obj1"];
_script = _this select 0;
_group1 = _this select 1;
_obj1 = _this select 2;
sleep 5;
terminate _script;
sleep 0.5;
{deletevehicle _x} foreach units _group1;
sleep 0.5;
nul = [_obj1] execVM "tasks\dynamictasks.sqf";
};
trt_fnc_cleanup_2 = {
private ["_group1","_script","_obj1","_group2"];
_script = _this select 0;
_group1 = _this select 1;
_group2 = _this select 2;
_obj1 = _this select 3;
sleep 1;
terminate _script;
sleep 0.5;
{deletevehicle _x} foreach units _group1 + units _group2;
sleep 0.5;
hint format ["Obj: %1",taskstate _obj1];
nul = [_obj1] execVM "tasks\dynamictasks.sqf";
};
trt_fnc_cleanup_3 = {
private ["_group1","_script","_obj1","_obj2"];
_script = _this select 0;
_group1 = _this select 1;
_obj1 = _this select 2;
_obj2 = _this select 3;
sleep 5;
terminate _script;
sleep 0.5;
{deletevehicle _x} foreach units _group1;
sleep 0.5;
nul = [_obj1,_obj2] execVM "tasks\dynamictasks.sqf";
};
trt_fnc_cleanup_4 = {
private ["_group1","_group2","_script","_obj1","_obj2"];
_script = _this select 0;
_group1 = _this select 1;
_group2 = _this select 2;
_obj1 = _this select 3;
_obj2 = _this select 4;
sleep 5;
terminate _script;
sleep 0.5;
{deletevehicle _x} foreach units _group1 + units _group2;
sleep 0.5;
nul = [_obj1,_obj2] execVM "tasks\dynamictasks.sqf";
};
trt_fnc_cleanup_5 = {
private ["_group1","_group2","_script","_obj1","_obj2","_obj3"];
_script = _this select 0;
_group1 = _this select 1;
_group2 = _this select 2;
_obj1 = _this select 3;
_obj2 = _this select 4;
_obj3 = _this select 5;
sleep 5;
terminate _script;
sleep 0.5;
{deletevehicle _x} foreach units _group1 + units _group2;
sleep 0.5;
nul = [_obj1,_obj2,_obj3] execVM "tasks\dynamictasks.sqf";
};
Code: Select all
while {flying} do {
if (vehicle player != uh1h) exitWith {
_pktsk2 setTaskState "failed";
[trtask3,opforgroup,_bluforsquad,_pktsk2] call trt_fnc_cleanup_2;
};
The thing is, the function doesn't get executed. I've tested using Radio Bravo for debug and the function works, but I'm not sure what to do against it. Will preprocessing in every script work? This seems unlikely as I already did that in the init.sqf though. Dynamictasks.sqf is just a script which selects a random mission and deletes all previous objectives assigned. Ideas?
//Ninja-edit
Preprocessing in the respective sqf file didn't work either.
//Edit2
Using spawn might help. Should've remembered the basic rule:
spawn = function / code with sleep
call = function / code without sleep.
Fixed the issue.