OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: SaOk on 02 Mar 2011, 13:26:02
-
How can I get this kind of code to work with multiple ForEach-commands? The problem is 2 _x´s in (_x distance _x)
{if (({_x distance _x > 300;} count (units group player)) > 0) then {deletevehicle _x;_tableAnimal = _tableAnimal - [_x]; _countAnimal = _countAnimal - 1;};} foreach _tableAnimal;
It says something about _forEachIndex in here, but I dont understand it yet: http://community.bistudio.com/wiki/forEach
I would need a single line to check distances between objects in two dynamic size arrays.
Edit: I scripted it in another way, but if foreach inside foreach is possible, let me know:
_closestU = (units group player) select 0;
_disU = _closestU distance _center;
{if(_x distance _center < _disU) then {_disU = _closestU distance _center; _closestU= _x;};} foreach (units group player);
{if (_closestU distance _x > 300) then {deletevehicle _x;_tableAnimal = _tableAnimal - [_x]; _countAnimal = _countAnimal - 1;};} foreach _tableAnimal;
-
{ _y = _x; if (({_y distance _x > 300;} count (units group player)) > 0) then {deletevehicle _x;_tableAnimal = _tableAnimal - [_x]; _countAnimal = _countAnimal - 1;};} foreach _tableAnimal;
-
Thanks, I will try that next time. :)