Jump to content
Sign in to follow this  
jakkob4682

question about selecting group members then using addAction to make them leave group

Recommended Posts

Basically what the title say.  What I want is to be able to select units from from the group(F keys) then use an addAction command to make them leave the group(aka join grpNull) create their own group, and perform a defined task(i.e. taskPatrol,defend,attack etc).  Pretty sure I can figure the addAction script out on my own but how do I pass the units selected to the script?  This is not a Multiplayer task if that helps.

Share this post


Link to post
Share on other sites
player addAction ["Say hello", "script.sqf", ["Hello World"]];

If you include that third parameter (["Hello World"] in this example) to addAction, an array, you can pass those values to the the script as _this select 3.

 

Inside script.sqf for this example:

params ["_object", "_caller", "_actionID", "_args"];

// Player single player could you get away with just this. Player says "Hello World" on sidechat
//_caller sideChat (_args select 0);

// For MP it would be:
[_caller, (_args select 0)] remoteExec ["sidechat"];

Share this post


Link to post
Share on other sites

so lets say i select the last two units in a 3 man group using F2 and F3 then i can pass them to the addaction? What I'm trying to do is make it so the units dont have to be named in the editor, I can just press the F key and pass the unit or units to a script to manipulate them.

Share this post


Link to post
Share on other sites

so I guess the real question is how do I pass group members selected the F keys to an array?

Share this post


Link to post
Share on other sites

so I guess the real question is how do I pass group members selected the F keys to an array?

 Darn good question and I can't seem to figure that one out.  You could use this to point at a soldier in your group and get him to go patrol on his own.

//player addAction ["Patrol", {null = [player, cursorTarget] execVM "patrolscript.sqf"}];

params ["_caller", "_unit"];

if !(group _unit == group player) exitwith {};

_caller groupchat "Where should the unit patrol?";
openMap true;
mapclick = false;
onMapSingleClick "clickpos = _pos; mapclick = true; onMapSingleClick """";true;";

waituntil {mapclick or !(visiblemap)};
	
if !(visibleMap) exitwith {
	_unit groupchat "Sticking with you boss!";
};

_pos = clickpos;
openMap false;

[_unit] join grpNull;
[group _unit, _pos, 100] call BIS_fnc_TaskPatrol;
[_unit, "Heading out!"] remoteExec ["sidechat"];

Share this post


Link to post
Share on other sites

yeah guess that will have to work.  trying to create an evac mission then once the evac is complete and we're out the heli remove the units from group and have them patrol around the drop off site.  Was trying to make it as user friendly as possible so anyone using the script didn't have to edit the script but you're example will do the same thing :) Anyhow thanks for the snippet.

Share this post


Link to post
Share on other sites

Just have something like that happen automatically.  Run a script from the helo transport unload waypoint activation maybe.

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  

×