Jump to content
Sign in to follow this  
siggy

Return array of selected units from F1-F12 keys?

Recommended Posts

Just a quickie... I've trawled comref and suspect that this can't be done - perhaps somebody can say definitively!

I'd like to return an array of the units that I have selected along the bottom of my screen (i.e. the group members I've selected using F1 to F12). The idea is to then pass this array into a script.

Can't find anything though :(

Share this post


Link to post
Share on other sites

This it is, but you need to be in command view (del-button in numpad) if using it trought radio. Else the selected units are automaticly unactivated, before the script happens:

_array = groupSelectedUnits player;

Share this post


Link to post
Share on other sites

Nice one!

I'm testing in v1.56 and do not need to switch to command view. It doesn't de-select the units until after I've done the 0-0-x, in 1st Person - works a treat :)

Scenario is a 4 man PMC team with a Land Rover. An ammo crate with some fancy weapons is attached to the vehicle using attachTo.

Radio Juliet: nul = (groupSelectedUnits player) execVM "Rearm.sqf";

//Rearm.sqf
//---------
//Check only one unit's selected
if (count _this == 1) 
then
{
//If they're in a vehicle, check it's not moving, before jumping out
_pmc = _this select 0;
if ((!(vehicle _pmc == _pmc)) and (speed (vehicle _pmc) > 0.5))
then
{
	hintSilent "Unit is moving too fast!"
}
else
{
	//If in a stationary vehicle, get out and move to the ammo crate
	if (!(vehicle _pmc == _pmc))
	then
	{
		_pmc action ["GetOut",vehicle _pmc]; _pmc commandMove (position pmc_ammo)
	}
	//Otherwise, just move to the crate
	else
	{
		//If close enough, open the gear menu between the unit and the crate
		if (_pmc distance pmc_ammo > 4.5)
		then
		{
			_pmc commandMove (position pmc_ammo)
		}
		else
		{
			_pmc action ["GEAR",pmc_ammo]
		};
	};
};
}
else
{
hint "Select a single unit!"
};

I appreciate the help!

Share this post


Link to post
Share on other sites

Nice, that (groupSelectedUnits player) execVM "Scriptname.sqf"; really works. I had that "groupSelectedUnits" in the script which was too late to detect the units that player chose. That makes things now much easier, thanks. :)

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
Sign in to follow this  

×