Jump to content
scottb613

Array of player AI units selected via Function Keys?

Recommended Posts

Hi Folks,

 

Another basic question - I've tried Chat GPT and numerous searches. 

 

How do I capture an array of selected units - that have been selected via Function Keys and are highlighted in the user interface?

 

Thanks.

 

Regards,
Scott

Share this post


Link to post
Share on other sites

Hi Folks,

 

I think I have it.

 

groupSelectedUnits

 

Regards,
Scott

Share this post


Link to post
Share on other sites

Hi Folks,

 

One follow up - I'm using an "addAction" on an ammo box to call a rearm script - which shows up fine - however - when I select any unit using a Function Key (the subject of my rearm script - groupSelectedUnits) - my addAction is no longer available in the scrolling menu.  Catch 22?

 

Is there a way around this?

 

_ammoBox addAction ["<t color='#FFB43F'>-Ammo Rearm</t>","Scripts\SCOammo.sqf",_ammoBox,1.8,true,true,"","true",5];

 

Thanks.

 

Regards,
Scott

Share this post


Link to post
Share on other sites

Not really, imho.

What I did: a tempo like this:

_ammobox addAction [
  "<t color='#FFB43F'>-Ammo Rearm</t>",
  {
    params ["_ammobox,"_plyr"];
    waitUntil {groupSelectedUnits _plyr isNotEqualTo []};
    sleep 3;
    [groupSelectedUnits _plyr,_ammobox] spawn {your code for these guys & ammobox (eventually)} ;
  },nil,0,FALSE,TRUE,"",""
];

After calling the action, then starting selection, you have 3 seconds to select all units you need before the code applies on them.


Another example for dismissing units, even out of sight:
 

Spoiler

 


MGI_dismissUnits = [
  "dismiss selected units (within 3s.)",
  {
    params ["_plyr"];
    waitUntil {groupSelectedUnits _plyr isNotEqualTo []};
    sleep 3;
    groupSelectedUnits _plyr joinSilent grpNull;
  },nil,0,FALSE,TRUE,"",""
];
player addAction MGI_dismissUnits;

player addEventHandler ["Respawn",{
  params ["_unit","_corpse"];
  _unit addAction MGI_dismissUnits;
  removeAllActions _corpse;
}];

 

 

 

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Hi Pierre,

 

Thanks so much for the ideas and examples. Yep - seems like the best way to go…

 

I’ll give this a shot.

 

Regards,

Scott

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×