Home   Help Search Login Register  

Author Topic: Selected Units to Array  (Read 1458 times)

0 Members and 1 Guest are viewing this topic.

Offline SaOk

  • Missions Depot Staff
  • *****
    • My youtube profile
Selected Units to Array
« 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
« Last Edit: 03 Jun 2010, 23:13:03 by SaOk »

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Selected Units to Array
« Reply #1 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:
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline SaOk

  • Missions Depot Staff
  • *****
    • My youtube profile
Re: Selected Units to Array
« Reply #2 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 {};