Jump to content
Sign in to follow this  
ryansoper

Loop won't resume? WaitUntil

Recommended Posts

I have three files:

init.sqf

waitUntil {time > 5};
jobactive = false;
publicVariable "jobactive";

while {true} do 
{
hint "This Far";
jobSelect = floor(random 2);
publicVariable "jobSelect";

jobactive = true;
publicVariable "jobactive";

switch (jobSelect) do
{
	case 0: {execVM "jobs\susactivity.sqf";}; 
	case 1: {execVM "jobs\drugsden.sqf";};
};
hint format ["%1", jobactive];
waitUntil (!jobactive);
hint format ["After: %1", jobactive];
sleep 20;
};

susActivity.sqf

jobactive = true;
publicVariable "jobactive";
thisjob = true;
publicVariable "thisjob";
sleep 3;

_SMhint = "<t align='center'><t size='2.2'>CALL INCOMING...</t><br/><t size='1.5' color='#00B2EE'>Abandoned Vehicle</t><br/>____________________<br/>Caller has reported an abandoned vehicle. Please head to the area to investigate.</t>";
hint parsetext _SMhint;

_CompleteHint = "<t align='center'><t size='2.2'>JOB COMPLETED</t>>";

_polStationPos = getMarkerPos "polstationmarker";
_position = [_polstationpos, 150, 200, 3, 0, 20, 0] call BIS_fnc_findSafePos;

//hint format ["Position: %1",_position];

sideObj = "C_Van_01_box_F" createVehicle _position;
sideobj lock true;
sideObj setDir random 360;
sideObj addAction ["Recover Vehicle", {hint "Recovering vehicle"; sleep 3; deleteVehicle (_this select 0); thisjob = false; publicVariable "thisjob";}];

jobMarker = createMarker ["jobMarker", position player];
"jobMarker" setmarkerpos (position sideobj);
"jobMarker" setmarkertext "Abandoned Vehicle";
"jobMarker" setmarkercolor "ColorRed";
"jobMarker" setMarkerAlpha 1;
"jobMarker" setmarkerType "hd_dot";

_job = player createSimpleTask ["Suspicious Activity"];

_job setSimpleTaskDescription ["Respond to area an investigate for suspcious activity.","Active Job",""];
_job setTaskState "Assigned";

player setCurrentTask _job;

waitUntil {!thisjob};
deleteMarker jobmarker;
_job setTaskState "Succeeded";
hint parsetext _completehint;
jobactive = false;
publicVariable "jobactive";

and drugsden.sqf

jobactive = true;
publicVariable "jobactive";
_CSites =["CSite1", "CSite2", "CSite3", "CSite4", "CSite5", "CSite6", "CSite7", "CSite8", "CSite9", "CSite10"];
sleep 3;


_CompleteHint = "<t align='center'><t size='2.2'>DRUGS DEN CLEARED</t>>";

_SMhint = "<t align='center'><t size='2.2'>CALL INCOMING...</t><br/><t size='1.5' color='#00B2EE'>Possible Drugs Den</t><br/>____________________<br/>Intel suggests the presence of a Drugs den in this area. Please respond to the area and investigate. HIGH CHANCE OF ARMED SUPSECTS. Lethal force is sanctioned.</t>";
hint parsetext _SMhint;

_Pos = _CSites select random 10;
DenPos = [getMarkerPos _pos, 1, 25, 3, 0, 20, 0] call BIS_fnc_findSafePos;

criminalCar = "max_robbers_suv" createVehicle denPos;
criminalCar lock true;
criminalGroup = [DenPos, EAST, ["max_robber_light", "max_robber_light", "max_robber_light", "Max_robber"], [],[],[],[],[],180] call BIS_fnc_spawnGroup;
criminalBoss = "Max_robber_boss" createUnit [ DenPos, criminalGroup, "crimboss = this"];

jobMarker = createMarker ["jobMarker", position player];
"jobMarker" setmarkerpos (position CriminalCar);
"jobMarker" setmarkertext "Drugs Den";
"jobMarker" setmarkercolor "ColorRed";
"jobMarker" setMarkerAlpha 1;
"jobMarker" setmarkerType "hd_dot";

waitUntil {!alive crimBoss};
criminalCar addAction ["Recover Vehicle", {hint "Recovering vehicle"; sleep 3; deleteVehicle (_this select 0); jobactive = false; publicVariable "jobactive";}];
hint "Boss Dead, Recover the car";
waitUntil {!jobactive};
deleteMarker jobmarker;
_job setTaskState "Succeeded";
hint parsetext _completehint;
publicVariable "jobactive";

My intention is that the game launches, and it generates one of the jobs. When you clear it. It will then continue the loop and generate another random job. This did work briefly, however for some reason now, I cannot get the loop to resume after the first iteration. I'm not sure if I've just totally messed something up, but I'd appreciate it if someone would take a look.

Thanks,

Ryan

Share this post


Link to post
Share on other sites

init.sqf

waitUntil {time > 5};
jobactive = false;
publicVariable "jobactive";

while {true} do 
{
hint "This Far";
jobSelect = floor(random 2);
publicVariable "jobSelect";

jobactive = true;
publicVariable "jobactive";

switch (jobSelect) do
{
	case 0: {execVM "jobs\susactivity.sqf";}; 
	case 1: {execVM "jobs\drugsden.sqf";};
};
hint format ["%1", jobactive];
waitUntil {!jobactive}; [color="#FF0000"]// <-- waitUntil requires {}, not ()[/color]
hint format ["After: %1", jobactive];
sleep 20;
};

susActivity.sqf

jobactive = true;
publicVariable "jobactive";
thisjob = true;
publicVariable "thisjob";
sleep 3;

_SMhint = "<t align='center'><t size='2.2'>CALL INCOMING...</t><br/><t size='1.5' color='#00B2EE'>Abandoned Vehicle</t><br/>____________________<br/>Caller has reported an abandoned vehicle. Please head to the area to investigate.</t>";
hint parsetext _SMhint;

_CompleteHint = "<t align='center' size='2.2'>JOB COMPLETED</t>"; [color="#FF0000"]// <-- ![/color]

_polStationPos = getMarkerPos "polstationmarker";
_position = [_polstationpos, 150, 200, 3, 0, 20, 0] call BIS_fnc_findSafePos;

//hint format ["Position: %1",_position];

sideObj = "C_Van_01_box_F" createVehicle _position;
sideobj lock true;
sideObj setDir random 360;
sideObj addAction ["Recover Vehicle", {hint "Recovering vehicle"; sleep 3; deleteVehicle (_this select 0); thisjob = false; publicVariable "thisjob";}];

jobMarker = createMarker ["jobMarker", position player];
"jobMarker" setmarkerpos (position sideobj);
"jobMarker" setmarkertext "Abandoned Vehicle";
"jobMarker" setmarkercolor "ColorRed";
"jobMarker" setMarkerAlpha 1;
"jobMarker" setmarkerType "hd_dot";

_job = player createSimpleTask ["Suspicious Activity"];

_job setSimpleTaskDescription ["Respond to area an investigate for suspcious activity.","Active Job",""];
_job setTaskState "Assigned";

player setCurrentTask _job;

waitUntil {!thisjob};
deleteMarker jobmarker;
_job setTaskState "Succeeded";
hint parsetext _completehint;
jobactive = false;
publicVariable "jobactive";

Edited by Schatten

Share this post


Link to post
Share on other sites
init.sqf

waitUntil {time > 5};
jobactive = false;
publicVariable "jobactive";

while {true} do 
{
hint "This Far";
jobSelect = floor(random 2);
publicVariable "jobSelect";

jobactive = true;
publicVariable "jobactive";

switch (jobSelect) do
{
	case 0: {execVM "jobs\susactivity.sqf";}; 
	case 1: {execVM "jobs\drugsden.sqf";};
};
hint format ["%1", jobactive];
waitUntil {!jobactive}; [color="#FF0000"]// <-- waitUntil requires {}, not ()[/color]
hint format ["After: %1", jobactive];
sleep 20;
};

susActivity.sqf

jobactive = true;
publicVariable "jobactive";
thisjob = true;
publicVariable "thisjob";
sleep 3;

_SMhint = "<t align='center'><t size='2.2'>CALL INCOMING...</t><br/><t size='1.5' color='#00B2EE'>Abandoned Vehicle</t><br/>____________________<br/>Caller has reported an abandoned vehicle. Please head to the area to investigate.</t>";
hint parsetext _SMhint;

_CompleteHint = "<t align='center' size='2.2'>JOB COMPLETED</t>"; [color="#FF0000"]// <-- ![/color]

_polStationPos = getMarkerPos "polstationmarker";
_position = [_polstationpos, 150, 200, 3, 0, 20, 0] call BIS_fnc_findSafePos;

//hint format ["Position: %1",_position];

sideObj = "C_Van_01_box_F" createVehicle _position;
sideobj lock true;
sideObj setDir random 360;
sideObj addAction ["Recover Vehicle", {hint "Recovering vehicle"; sleep 3; deleteVehicle (_this select 0); thisjob = false; publicVariable "thisjob";}];

jobMarker = createMarker ["jobMarker", position player];
"jobMarker" setmarkerpos (position sideobj);
"jobMarker" setmarkertext "Abandoned Vehicle";
"jobMarker" setmarkercolor "ColorRed";
"jobMarker" setMarkerAlpha 1;
"jobMarker" setmarkerType "hd_dot";

_job = player createSimpleTask ["Suspicious Activity"];

_job setSimpleTaskDescription ["Respond to area an investigate for suspcious activity.","Active Job",""];
_job setTaskState "Assigned";

player setCurrentTask _job;

waitUntil {!thisjob};
deleteMarker jobmarker;
_job setTaskState "Succeeded";
hint parsetext _completehint;
jobactive = false;
publicVariable "jobactive";

Top bloke! I knew it'd be something simple, but I couldn't for the life of me work it out!

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  

×