#include "..\script_component.hpp"

// subroutine to gather nearest 50 units every 5 seconds and store in GVAR(nearMen)
// cleanup
if (!isNil QGVAR(getNearMenPFH)) then {
	[GVAR(getNearMenPFH)] call CBA_fnc_removePerFrameHandler;
};
// add pfh
GVAR(getNearMenPFH) = [{
	localNamespace setVariable [
		QGVAR(nearMen), 
		(nearestObjects [player,["Man"],50,false]) select {
			!isNull _x &&
			player isNotEqualTo _x
		}
	];
}, 1] call CBA_fnc_addPerFrameHandler;
