Warning: include(/var/www/html/forum/Sources/../../../includes/depot_files/OFPEC_get_header_image.inc.php): failed to open stream: No such file or directory in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 146

Warning: include(): Failed opening '/var/www/html/forum/Sources/../../../includes/depot_files/OFPEC_get_header_image.inc.php' for inclusion (include_path='.:/usr/local/lib/php') in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 146

Notice: Undefined index: OFPEC in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 152

Notice: Trying to access array offset on value of type null in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 152

Notice: Trying to access array offset on value of type null in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 152
    Home   Help Login Register  

Author Topic: ForEach inside ForEach  (Read 3343 times)

0 Members and 1 Guest are viewing this topic.

Offline SaOk

  • Missions Depot Staff
  • *****
    • My youtube profile
ForEach inside ForEach
« 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)

Code: [Select]
{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:

Code: [Select]
_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;
« Last Edit: 02 Mar 2011, 15:08:37 by SaOk »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: ForEach inside ForEach
« Reply #1 on: 02 Mar 2011, 16:50:14 »
Code: [Select]
{ _y = _x; if (({_y distance _x > 300;} count (units group player)) > 0) then {deletevehicle _x;_tableAnimal = _tableAnimal - [_x]; _countAnimal = _countAnimal - 1;};} foreach _tableAnimal;
urp!

Offline SaOk

  • Missions Depot Staff
  • *****
    • My youtube profile
Re: ForEach inside ForEach
« Reply #2 on: 02 Mar 2011, 16:58:07 »
Thanks, I will try that next time. :)