Jump to content

Recommended Posts

So my script (which is ancient and dont remember what half the variables are) which is part of larger mod - used to work flawlessly interms of detecting when a battle has started and when it has ended within a trigger radius. I now get the error that the waituntil's are returning nil when they need to be a bool. I have 3 waitUntils which are used to certain units in the area and if so advance the script to the end (end of battle thereby firing marker.sqf) but it no longer works and i guess i dont undertand the syntax.

 

The Blocked out waituntils are the previous working syntax and the the waituntil right underneath my failed attempt to rectify it

 

Sample.sqf

hint "sample working!";
sleep 3;
Frog_Panic = True;
Frog_rank = [];
_rank = rank player;
_myGroup = group player;
nearfort = 0;
frog_zero =[];  

_myNearestEnemy = (units _myGroup select 0) findNearestEnemy player;
if (_rank == "Private") then {
/*playSound "HP_Private";*/ Frog_rank = "HP_Private"
};

if (_rank == "Corporal")  then {
/* playSound "HP_Corporal"; */ Frog_rank = "HP_Corporal"
};

if (_rank == "Sergeant") then  {
/* playSound "HP_Sargent"; */ Frog_rank = "HP_Sargent"
};

if (_rank == "Lieutenant")  then {
/* playSound "HP_Lieutenent"; */ Frog_rank = "HP_Lieutenent"
};

if (_rank == "Captain")   then {
/* playSound "HP_Captain"; */ Frog_rank = "HP_Captain"
};

if (_rank == "Major")  then {
/* playSound "HP_Major";  */Frog_rank = "HP_Major"
};

 
/* private _lcs = [];
{    private _lct = _forEachIndex;
    {    _lcs pushBack [text _x, _lct, locationPosition _x, direction _x, size _x, rectangular _x];
    } forEach nearestLocations [getArray (configFile >> "CfgWorlds" >> worldName >> "centerPosition"), [_x], worldSize];    
} forEach ["NameLocal","NameVillage", "NameCity", "NameCityCapital"];  */

_loc = text ((nearestlocations [position player, ["NameCityCapital", "NameVillage","NameLocal", "Namecity"],500])select 0);
 
if (_loc == "agia Marina") then {frog_loc = "agiaMarina"};
if (_loc == "Girna") then {frog_loc = "Girna"};
 
switch (_loc) do {
    case "Agia Marina": { hint "Marina"; Frog_loc = "agiaMarina" };      
    case "Stratis Air Base": { hint "Stratis Air Base"; Frog_loc ="stratisAirbase" };   
    case "Girna": { hint "Girna"; Frog_loc ="Girna" };
                 };

sleep 1;

hint format ["The Battle of %1 has begun", _loc];
battleStarted = true;
missionNamespace setVariable ["cBattle",_loc];
sleep 3;
_searchRadius = 300;
_playerPos = getPos player;
_nearE = player findNearestEnemy player;
_nearTargets = _playerPos nearEntities [["CAManBase", "Car", "Tank"], _searchRadius];
_sideEnemy = side _nearE;
_sideP = side player;

_bz = createTrigger ["EmptyDetector", getPos player];
_bz setTriggerArea [300, 300, 0, false];
_bz setTriggerTimeout [5, 10, 7, false];

if (_sideEnemy == East) then {
_bz setTriggerActivation ["East", "PRESENT", false];
} else {};

if (_sideEnemy == Resistance) then {
_bz setTriggerActivation ["Guer", "PRESENT", false];
} else {};

if (_sideEnemy == West) then {
_bz setTriggerActivation ["West", "PRESENT", false];
} else {};

_bz setTriggerStatements ["this", "",""];
systemchat format ["Side = %1", _sideEnemy];
/* waituntil {count list _bz > 0};  */

waituntil { if (count list _bz > 0) then {true}};
_counte = count list _bz;
 
hint str format ["%1 %2 Units", _counte, _sideEnemy];

sleep 1;
missionNameSpace setvariable ["aliveE",_countE];

_bzw = createTrigger ["EmptyDetector", getPos player];

_bzw setTriggerArea [300, 300, 0, false];

if (_sideP == East) then {
_bzw setTriggerActivation ["East", "PRESENT", false];
} else {};

if (_sideP == independent) then {
_bzw setTriggerActivation ["Guer", "PRESENT", false];
} else {};

if (_sideP == west) then {
_bzw setTriggerActivation ["West", "PRESENT", false];
} else {};

//_bzw setTriggerActivation ["west", " PRESENT", true];

_bzw setTriggerStatements ["this", "",""];

/* waituntil {count list _bzw > 0}; */
waituntil { if (count list _bzw > 0) then {true}};

_countW = count list _bzw;
 
//systemchat ["%1 %2 Units", _countW, _sideP];

_ratio = _counte/_countW;

_fight1 = ["Tough","Challenging","Brutal","Uphill","Difficult","Exhausting","Demanding","Complex"] call bis_fnc_selectRandom;
_fight2 = ["Fair","Even","Easy","Basic","Simple","Straightforward","Light"] call bis_fnc_selectRandom;
_fighttype = ["battle","engagement","fight","contact","assault","encounter","skirmish"] call bis_fnc_selectRandom;
 if (_ratio >= 1.5) then {
 player sidechat format ["%2 %3 at a ratio of %1 to 1", _ratio, _fight1, _fighttype];
 } else {
 player sidechat format ["%2 %3 at a ratio of %1 to 1", _ratio, _fight2, _fighttype];
 };

missionNameSpace setVariable ["CombatBonus", _ratio];
sleep .5;
_list = player nearEntities ["Man", 500];

_enemySides = [side player] call BIS_fnc_enemySides;
_radius = 1000;
_nearEnemies = allUnits select {_x distance player < _radius AND side _x in _enemySides}; { if ((_x in Frog_Count_Fortified) && !(_x in frog_zero))  then {
frog_zero pushback _x; nearFort = nearfort + 1}} foreach _nearenemies;
/* hintc str nearfort; */
if (nearFort > 2) then { playsound Frog_rank; sleep .6; playsound "fortify_01"; sleep 4; playsound Frog_loc;sleep 3.5; playsound "fortify_02"};


 _myNearestEnemy = player findNearestEnemy player;
 if ((typeOf _nearE  in Frog_ReconEast) && (_counte >=1))  then { playsound Frog_rank; sleep 1; playSound "HP_SpecOps";_pos = getPos _nearE; _markertxt = format ["Spec Ops?" ];
_markerstr = createMarker ["PLP ASSET Special Forces",_pos];
_markerstr setMarkerShape "ICON";
_markerstr setMarkerType "plp_mark_as_specialforces";
_markerstr setMarkerSize [0.9,0.9];
_markerstr setMarkerColor "ColorRed";
_markerstr setMarkerText _markertxt};

if ((typeOf _nearE  in Frog_SniperEast) && (_counte >=1)) then { playSound Frog_rank; sleep 1; playSound "PossSniper";_pos = getPos _nearE;  _markertxt = format ["Sniper?"];
_markerstr = createMarker ["plp_mark_as_sniperrifle",_pos];
_markerstr setMarkerShape "ICON";
_markerstr setMarkerType "plp_mark_as_sniperrifle";
_markerstr setMarkerSize [0.9,0.9];

_markerstr setMarkerColor "ColorRed";
_markerstr setMarkerText _markertxt};

if ((typeOf _nearE  in Frog_Agent) && (_counte >=1)) then {playSound Frog_rank; sleep 1; playSound "PossSniper";_pos = getPos _nearE;  _markertxt = format ["Agent"];
_markerstr = createMarker ["plp_mark_as_voltage",_pos];
_markerstr setMarkerShape "ICON";
_markerstr setMarkerType "plp_mark_as_voltage";
_markerstr setMarkerSize [0.9,0.9];

_markerstr setMarkerColor "ColorRed";
_markerstr setMarkerText _markertxt};


_bzC = createTrigger ["EmptyDetector", getPos player];
_bzC setTriggerArea [300, 300, 0, false];
_bzC setTriggerTimeout [5, 10, 7, false];  
if (_sideEnemy == East) then {
_bzC setTriggerActivation ["East", "not PRESENT", false];
} else {};

if (_sideEnemy == Independent) then {
_bzC setTriggerActivation ["Guer", "not PRESENT", false];
} else {};

if (_sideEnemy == West) then {
_bzC setTriggerActivation ["West", "not PRESENT", false];
} else {};

//_bzC setTriggerActivation ["east", "not PRESENT", false];

/* if (Frog_TPanic > 25) then {hintc "Town is in a total panic!"} ; */
 /* waituntil { count list _bzC < 1}; */
 waituntil { if (count list _bzc > 1) then {true}};
 
/* {if (side _x == civilian) then {sleep random 180;_x call Frog_Civ_After_Battle}} foreach count _bzC; */
 hintc "Waituntil sample count bzC worked!";
/* _counte = count list _bz; */
0 = execvm "ego\EGO\scripts\marker.sqf";
_bzC setTriggerStatements ["this", "[thistrigger] execvm 'ego\EGO\scripts\marker.sqf'",""];

 

Edited by froggyluv
Shamed by shunners

Share this post


Link to post
Share on other sites

Waituntil requires a boolean at the end.

Your example is weird, since you only return a boolean to the waitUntils scope if it's true:

waituntil { if (count list _bzc > 1) then {true}};

when you could simply use:

waituntil {count list _bzc > 1};

instead.

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

What BIKI says:

Since Arma 3 v1.93.145618 returning anything other than true or false from condition will result in appropriate type error.

And the best example is:

// bad waitUntil { bank getVariable "money" > 0 };

// good waitUntil { bank getVariable ["money", 0] > 0 };

 

But further:

For some unknown reason if you have waitUntil loop active and game is saved/loaded, some variables in the expression may appear undefined for a short time. As a workaround, assign expression to a variable and make sure it is defined before waitUntil checks it:

waitUntil { private _expression = var1 && (var2 > 10); !isNil "_expression" && { _expression } };

 

That's a real problem. IMHO, no matter, the way you:

waituntil {count list _bzc > 1}; (or waituntil { if (count list _bzc > 1) then {true} else {false} };)

_bzc must be defined or secured:

If you have any doubt, or error message:

waitUntil { private _expression = (count list _bzc > 1); !isNil "_expression" && { _expression } };

 

Note 1: if defined (in the true private scope) just above, probably a simple sleep could suffice:

private _bzC = createTrigger ["EmptyDetector", getPos player];

...

waitUntil { sleep 1; count list _bzc > 1};

 

Note 2: for trigger(s), I'd rather use setTriggerActivation just for the area check and setTriggerStatements with count, instead of trigger pre-condition + list.  In other words, waitUntil usage is weird in a trigger.

 

 

 

 

  • Like 2
  • Thanks 2

Share this post


Link to post
Share on other sites

@froggyluv whoa, use the <> code button there buddy, wrap that nice and tight. You've been around long enough.

  • Like 3

Share this post


Link to post
Share on other sites
11 hours ago, froggyluv said:

but it no longer works

This has nothing to do with waitUntil changes, all you get is the error message, no changes in functionality. Has been like this since 1.94 hotfix

  • Like 1

Share this post


Link to post
Share on other sites

@GOM: That was what I have in there as the initial code /* waituntil { count list _bzC < 1}; */  -1 line above the "trial code"  -that code had been workin until a certain update where it started spamming errors. The 2nd was just my misguided attempt to rectify the sitcheeation..

 

@Pierre: Thanks man - the Private and Sleep did the trick- works swimmingly again

 

@Janez:  And Youve been here long enough im way to old and cantankerous to learn new things or change my ways!!

Ha, didnt think it was long enough to warrant spoiler tags and not sure what the code tag does but if it makes you feel better....

 

@KK: Ok semantical wizard -spamming error messages sucks A so i consider it not functioning in a proper, ladylike manner

  • Like 2
  • Haha 2

Share this post


Link to post
Share on other sites

@froggyluv well, then I will have you know, dear Sir, that I have to compensate somehow and am also far too petty to just let go of transgressions such as that wall of text.

 

Spoiler

You see how much nicer it looks now with code wrap 🙂. I was actually going to suggest a spoiler tag as well but apparently forgot.

Btw, when you enter @ and start typing users name, a drop down list appears and if you click on desired user, you can tag them. It's slower and it doesn't really matter, but if you do it will notify tagged user so they can respond or view latest development.

Take care!

  • Like 3

Share this post


Link to post
Share on other sites

Note:

This kind of "waitUntil" error happens also with BI scripts. I recently got this error when running a virtual CAS module (Vanilla).

The error comes from the requester.fsm (script id 57)

script:
 

Spoiler

 

_provider setVariable ["BIS_SUPP_requester", player, TRUE];
_provider setVariable ["BIS_SUPP_supportRunCoords", _supportCoords, TRUE];
_provider setVariable ["BIS_SUPP_ammoType", player getVariable "BIS_SUPP_ammoType", TRUE];
_provider setVariable ["BIS_SUPP_supportType", "CAS_Bombing", TRUE];
_provider setVariable ["BIS_SUPP_supporting", TRUE, TRUE];

player kbTell [_provider, "BIS_SUPP_protocol", _supportType + "_Request", BIS_SUPP_channels select ([WEST, EAST, RESISTANCE] find side group player)];

_i = 1;
while {markerPos format ["BIS_SUPP_mrkr_%1", _i] distance [0,0,0] > 0} do {_i = _i + 1};
_mrkrName = format ["BIS_SUPP_mrkr_%1", _i];

_mrkr = createMarker [_mrkrName, _supportCoords];
_mrkrName setMarkerTextLocal localize "STR_A3_mdl_supp_disp_cas_bombing";
_mrkrName setMarkerTypeLocal "selector_selectedMission";
_mrkrName setMarkerColorLocal "ColorBlack";
_mrkrName setMarkerSizeLocal [0.75, 0.75];

[_provider, _mrkrName] spawn {
    _provider = _this select 0;
    _mrkrName = _this select 1;
    waitUntil {!(_provider getVariable "BIS_SUPP_supporting") || !alive _provider};
    deleteMarker _mrkrName;
};

if (_virtual) then {
    _module setVariable ["BIS_SUPP_lastCall", time, TRUE];
};

_deleteVirtual = FALSE;

 

 

error:

Spoiler

19:27:11 Error in expression <ider getVariable "BIS_SUPP_supporting") || !alive _provider};
deleteMarker _mrkr>
   Error position: <|| !alive _provider};
deleteMarker _mrkr>
   Error Undefined behavior: waitUntil returned nil. True or false expected.
19:27:21 Error in expression <ider getVariable "BIS_SUPP_supporting") || !alive _provider};
deleteMarker _mrkr>
   Error position: <|| !alive _provider};
deleteMarker _mrkr>
   Error Undefined behavior: waitUntil returned nil. True or false expected.
19:27:21 In last 10000 miliseconds was lost another 658 these messages.
19:27:31 Error in expression <ider getVariable "BIS_SUPP_supporting") || !alive _provider};
deleteMarker _mrkr>
   Error position: <|| !alive _provider};
deleteMarker _mrkr>
   Error Undefined behavior: waitUntil returned nil. True or false expected.
19:27:31 In last 10000 miliseconds was lost another 696 these messages.
19:27:41 Error in expression <ider getVariable "BIS_SUPP_supporting") || !alive _provider};
deleteMarker _mrkr>
   Error position: <|| !alive _provider};
deleteMarker _mrkr>
   Error Undefined behavior: waitUntil returned nil. True or false expected.
19:27:41 In last 10000 miliseconds was lost another 710 these messages.
19:27:51 Error in expression <ider getVariable "BIS_SUPP_supporting") || !alive _provider};
deleteMarker _mrkr>
   Error position: <|| !alive _provider};
deleteMarker _mrkr>
   Error Undefined behavior: waitUntil returned nil. True or false expected.
19:27:51 In last 10000 miliseconds was lost another 646 these messages.

 

Difficult to reproduce. Use the virtual CAS intensively.

  • Like 2
  • Thanks 1

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

×