punderland 0 Posted December 13, 2017 Is there a way to loop through all groups on the field to select them all? I am trying to combine spawn ai with high command so that I can select groups spawned and add them to high command in a sector control game to allow more strategy elements. Also, is it possible to make that certain units death can shut down high command function of one side? Share this post Link to post Share on other sites
commanderx 17 Posted December 13, 2017 forEach is your friend here. Try something like { ...code } forEach allUnits side EAST; I am not 100% sure if this works. If not you use this. { if ((side _x) == West) then { code }; } forEach allUnits; 1 Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted December 13, 2017 To select groups of a specific side: _selection = allGroups select {side _x isEqualTo east};//returns all east groups 1 hour ago, punderland said: Also, is it possible to make that certain units death can shut down high command function of one side? Depends on how you want to do it, killed eventhandler on a certain unit would work most reliable, together with hcRemoveAllGroups on the high commander. Cheers 2 Share this post Link to post Share on other sites
commanderx 17 Posted December 13, 2017 I am sry... of course you want to loop all Groups. This can be done like in the examples before but with allGroups instead of allUnits. https://community.bistudio.com/wiki/allGroups Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted December 13, 2017 3 minutes ago, commanderx said: I am sry... of course you want to loop all Groups. This can be done like in the examples before but with allGroups instead of allUnits. https://community.bistudio.com/wiki/allGroups No need to loop, when the select command can do the same. Cheers 1 1 Share this post Link to post Share on other sites
punderland 0 Posted December 13, 2017 14 minutes ago, Grumpy Old Man said: No need to loop, when the select command can do the same. Cheers On a side note, if there is anyway for spawn ai to spawn cup/rhs units and for them to get sector tactics module way point also? And many thanks for the help, really appreciate! Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted December 13, 2017 1 hour ago, punderland said: On a side note, if there is anyway for spawn ai to spawn cup/rhs units and for them to get sector tactics module way point also? And many thanks for the help, really appreciate! You'd probably need to spawn another module or sync the spawned groups to the existing module somehow. No idea if the module will handle them correctly when syncing a new group during mission runtime. I'm not even sure if synchronizeObjectsAdd is the correct command for this. Cheers Share this post Link to post Share on other sites
punderland 0 Posted December 13, 2017 Now that I try to script it, I put Quote _selection=[]; _selection=allGroups select {side _x isEqualTo west}; kommand_west hcSetGroup [_selection]; where kommand_west is the unit for high command and _selection is to try to select all groups. It cites error of local variable n global scope. Why??? :(( Share this post Link to post Share on other sites
pierremgi 4862 Posted December 13, 2017 0 = [] spawn { while {true} do { { _grp = _x; _grp setVariable ["marked",true]; < any code with _grp here: _grp addWaypoint [getpos myModule,0]; // and setwaypoint... family: fast , combat mode.... komman_west hcSetGroup [_grp]; other lines > } foreach (allGroups select { side _x == West && !(_x getVariable ["marked",false]) ) sleep 3; } }; 1 Share this post Link to post Share on other sites
punderland 0 Posted December 14, 2017 10 hours ago, pierremgi said: _grp setVariable ["marked",true]; What is this for??? 10 hours ago, pierremgi said: 0 = [] spawn { while {true} do { And why I need this?? I didnt learn scripting in ARMA much....only little scripting knowledge of this language....pls help :) Share this post Link to post Share on other sites
pierremgi 4862 Posted December 14, 2017 It's useful if you spawn units (new groups via scripts/triggers...) The loop ( while true do +sleep) checks for new group(s) (every 3 seconds here). As a new group hasn't a variable "marked" (or what you want) yet, the selection works (variable is false per default here), and you can script for this group(s) . The old ones have their variables set to true and are skipped for this selection. See more at setVariable. It's very useful to determine units or groups already treated by a code. 1 Share this post Link to post Share on other sites