Sarge-AI/sarge/UPSMON/Get_pos/UPSMON_pos_fnc_findclosestposition.sqf
Teh Dango 7067ad9b0a 2.2.3
Check the change log for details
2016-08-18 22:58:49 -04:00

19 lines
405 B
Plaintext

// Return the closest position from array to the positionA.
// In: [positionA,[array of positions]]
// Out: positionB
private ["_pA","_ps","_p1","_p2"];
_pA = _this select 0;
_ps = _this select 1;
_p1 = _ps select 0;
if (count _ps > 1) then {
for "_i" from 1 to (count _ps - 1) do {
_p2 = _ps select _i;
if ((_p2 distance _pA) < (_p1 distance _pA)) then {
_p1 = _p2;
};
};
};
_p1