Jump to content
Sign in to follow this  
bangabob

Distance check for array

Recommended Posts

Ideally i want to make this work

Called from init.sqf

null = ["mkr5"] execvm "detect.sqf"; 

_spwnpos = markerPos (_this select 0);

Waituntil {((WEST side player) distance (_spwnpos)<50}; 

But having looks everywhere i am beginning to think that it is not possible.

So heres my second plan

_spwnpos = markerPos (_this select 0);
_BFarray = ["unit1","unit2","unit3","unit4"];

Waituntil {((_BFarray foreach unit) distance (_spwnpos) < 10};

Please help!!!

Edited by BangaBob

Share this post


Link to post
Share on other sites

too many (((((

waitUntil {side player == blufor && {(player distance _spwnpos) < 10}};

Share this post


Link to post
Share on other sites

Will you run this code on clients or on server ?

If on client then:

waitUntil {side player == WEST && (player distance _spwnpos) < 10};

Share this post


Link to post
Share on other sites

Thanks. This will be run server side. Will it still work?

Also how can i get it to detect AI east units

waitUntil {side unit == EAST && (unit distance _spwnpos) < 10};

Share this post


Link to post
Share on other sites

Ah if it will run only on server you need to check for every unit not just player.

Also on dedicated server player is null.

This will detect all units, including AIs:

waitUntil { sleep 1; ( {side _x == WEST && (_x distance _spwnpos) < 10} count allUnits) > 0 };

_units = []; // all WEST units within 10m of _spwnpos
{
 if (side _x == WEST && (_x distance _spwnpos) < 10) then {
   _units set [count _units, _x];
 };
} forEach allUnits;

or

_units = []; // all WEST units within 10m of _spwnpos
while {count _units == 0} do {
 sleep 1;
 {
   if (side _x == WEST && (_x distance _spwnpos) < 10) then {
     _units set [count _units, _x];
   };
 } forEach allUnits;
};

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
Sign in to follow this  

×