From 86dd2b74046f0f5c5390f6b5267f28f598bea4e4 Mon Sep 17 00:00:00 2001 From: IT07 Date: Thu, 23 Jun 2016 22:46:33 +0200 Subject: [PATCH] Rewritten, tweaked and fixed --- exile_vemf_reloaded/sqf/REMOTEguard.sqf | 31 ++++++++++++++----------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/exile_vemf_reloaded/sqf/REMOTEguard.sqf b/exile_vemf_reloaded/sqf/REMOTEguard.sqf index c3c4fe1..91f12d1 100644 --- a/exile_vemf_reloaded/sqf/REMOTEguard.sqf +++ b/exile_vemf_reloaded/sqf/REMOTEguard.sqf @@ -13,23 +13,26 @@ */ uiNamespace setVariable ["VEMFrHcLoad", []]; -uiNamespace setVariable ["VEMFrAIgroups", []]; while {true} do { - _groups = uiNamespace getVariable "VEMFrAIgroups"; - waitUntil {if (count _groups > 0) then {true} else {uiSleep 1; false} }; - { - if (local _x) then + if ((count playableUnits) > 0) then + { + waitUntil {if ((count allGroups) > 0) then {uiSleep 0.25; true} else {uiSleep 0.5; false} }; { - if ((count units _x) < 1) then + if ((local _x) AND (_x getVariable ["isVEMFrGroup",false])) then { - deleteGroup _x; + if ((count (units _x)) > 0) then + { + ["REMOTEguard",1,format["Attempting to transfer group: %1", _x]] ExecVM "exile_vemf_reloaded\sqf\log.sqf"; + // Group still has units, check if there is anyone that can be the owner + _handle = [_x] ExecVM "exile_vemf_reloaded\sqf\setGroupOwner.sqf"; + waitUntil { if (scriptDone _handle) then {true} else {uiSleep 0.1; false} }; + ["REMOTEguard",1,format["Transfer attempted. Group (%1) is %2", _x, if (local _x) then {"still local!"} else {"now REMOTE"}]] ExecVM "exile_vemf_reloaded\sqf\log.sqf"; + } else + { + deleteGroup _x; + }; }; - if (count (units _x) > 0) then - { - // Group still has units, check if there is anyone that can be the owner - [_x] ExecVM "exile_vemf_reloaded\sqf\transferOwner.sqf"; - }; - }; - } forEach _groups; + } forEach allGroups; + } else { uiSleep 5 }; };