OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: SaOk on 03 Jun 2010, 22:08:29

Title: Selected Units to Array
Post by: SaOk on 03 Jun 2010, 22:08:29
Is there a way to detect what units player (as a group leader) have selected (activated) in his group. I like to create an action which player could use to separate wanted units to own high command group. And also an action which would return units from selected high command group back to player's group.

Edit: Selected "High Command"-group join with this script (activated with radio):
Code: [Select]
_array = hcSelected player;
_count = count _array - 1;
while {_count > -1} do {
{[_x] JoinSilent player;} foreach (units (_array select _count));
_count = _count - 1;
};
if (true) exitWith {};

But I cant find a way to detect selected units in player's group. I tried to use "groupSelectedUnits"-command, but it dosent seem to work or I havent understood how it works. Empty array is returned all the time.

http://community.bistudio.com/wiki/groupSelectedUnits
Title: Re: Selected Units to Array
Post by: h- on 04 Jun 2010, 11:42:27
groupSelectedUnits works just fine here.

Tested with myself being a squad leader, this in a radio trigger:
Code: [Select]
hint format ["%1",groupSelectedUnits player]And selected units were "hinted"..

:dunno:
Title: Re: Selected Units to Array
Post by: SaOk on 04 Jun 2010, 13:55:10
Now I found the problem. You are right - that "groupSelectedUnits"-command really works, but in normal view units are automatically unselected too early when the command is used via radio. In command-view (numpad del) all works great.

Code: [Select]
_array = groupSelectedUnits player;
if (count _array > 0) then {
_group = creategroup west;
{[_x] join _group;} foreach _array;
player hcsetgroup [_group,""];
};
if (true) exitWith {};