Forum Jump :

Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 60
In-game name: Kobayashi Maru

 
#186530 Posted at 2016-02-15 16:09        
     
No, you can't use the same "_x scope" for two arrays at the same time (units my_group and building positions).
Try:
{_rooms = [nearestBuilding _x] call BIS_fnc_buildingPositions;
if (count _rooms >0) then {
_x setPos (_rooms select floor random (count _rooms))} else {
_x setpos (nearestBuilding _x)}
} foreach units _mygroup;

This works but 2 remarks:
- Don't let your units in a group. They always return in formation, even if "none" choosen instead of "in formation". I think it's a bug from Arma. Prefer an array of units (not grouped). Units can decide to leave their position, according to their behavior facing a threat (civilians are often fleeing).

- nearest building can be different for these units. So you can populate several buildings with the same script, depending on where nearest building is. That's the reason why I added a "else" for building without room, like some walls in some maps.

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS





Tags: At, Fill, Help, How, Need, Some, To