/* mrcash_spotters.sqf
Parameters:
Array of spotters
Array of groups to spot
name of global var to set to true if there is a positive detection as string (between "").
Execute it from init.sqf
*/
private ["_detected", "_i", "_j", "_groups", "_spotters", "_varname", "_alldead"];
_groups = _this select 0;
_spotters = _this select 1;
_varname = _this select 2;
if (!isServer) exitWith {};
Sleep 10;
_detected = false;
_alldead = false;
call compile format["%1=false;", _varname];
while {!_detected && !_alldead} do
{
{
for [{_i=0},{(_i < count _groups) && !_detected},{_i=_i+1}] do
{
for [{_j=0},{(_j < count units (_groups select _i)) && !_detected},{_j=_j+1}] do
{
if (_x knowsAbout vehicle (units (_groups select _i) select _j) > 0) then
{
if (alive (vehicle (units (_groups select _i) select _j)) then
{
_detected = true;
};
};
Sleep 0.25;
};
};
} forEach _spotters;
if (({alive _x} count _spotters) == 0) then
{
_alldead = true;
};
Sleep 3;
};
if (!_alldead) then
{
call compile format["%1=true;", _varname];
};
// init.sqf
// Two arrays of spotters (a single spotter per array)
[[spotter1], [alpha,bravo,charlie], "spotter1_saw_something"]execVM"mrcash_spotters.sqf";
[[spotter2], [alpha,bravo,charlie], "spotter2_saw_something"]execVM"mrcash_spotters.sqf";
Then you may check spotter1_saw_something and spotter2_saw_something global vars in a trigger to see if spotter1 OR spotter2 have detected someone in the indicated enemy groups.