Theo Thalwitzer 4 Posted October 16, 2019 (edited) Hi all! I have a simple problem. That's to say, for someone not as nOObish as me in scripting... In my mission (APEX), I need all units of a specific faction (all PMC units from the PG Services mod), to be automatically recruit-able via a little script I slapped together. At the moment I call the script via the unit's INIT field: e.g.; " nul=[] execVM "recruiting.sqf"; ". This, however, does not allow for AI-spawned units to be recruit-able. My goal: Run a script to check and find any AI-spawned units of the specified faction (PG_Services) within a certain radius, or ideally, the entire map, and run my recruitment script on each. The method I use for recruiting is pretty basic but seems to work exactly as I want it to, so I'd prefer not to change that. My only problem is how to identify and run the script on all faction-spawned units on the map. My method for recruiting & dismissing - After !MANY! experiments, I decided on a system of 4 tiny scripts. So far I cannot seem to find much problems with it. There may be some in MP... 1. recruiting.sqf - is run 1st - currently in unit's INIT but could be trigger / script based _guyNotRecruited = true; _man = _this select 0; _man setCaptive true; // OPTIONAL _recruitGuy = _man addAction ["Recruit","TRecruit\newguyinit.sqf"]; while {_guyNotRecruited} do { if (not(captive _man)) then {_guyNotRecruited = false}; if (not alive _man) exitWith {_man removeAction _recruitGuy}; sleep 1; }; _man removeAction _recruitGuy; [_man] join (group player); _man enableAI "MOVE"; // OPTIONALsleep 1; nul = [[["New Team Member recruited.","<t align='center' shadow='2' size='0.7'>%1</t><br/>"],["","<t align='center' shadow='2' size='0.7'>%1</t><br/>"],["","<t align='center' shadow='2' size='0.7'>%1</t>"]]] spawn BIS_fnc_typeText; nul=[_man] execVM "TRecruit\dismissing.sqf"; Obviously the script still needs polishing... setCaptive & enableAI "MOVE"; only used for testing & debug 2. newguyinit.sqf - called by recruiting.sqf - line 4 _unit=_this select 0; _unit setCaptive false; The script 'dismissing.sqf' is now running on the unit 3. dismissing.sqf - also called by recruitment.sqf - line 17 _guyRecruited = true; _man = _this select 0; _dropGuy = _man addAction ["Dismiss","TRecruit\dropguyinit.sqf"]; while {_guyRecruited} do { if (captive _man) then {_guyRecruited = false}; if (not alive _man) exitWith {_man removeAction _dropGuy}; sleep 1; }; _man removeAction _dropGuy; _man disableAI "MOVE"; //Optional but nice for leaving someone as guard on a specific spot [_man] join grpNull; sleep 1; nul = [[["Team Member dismissed.","<t align='center' shadow='2' size='0.7'>%1</t><br/>"],["","<t align='center' shadow='2' size='0.7'>%1</t><br/>"],["","<t align='center' shadow='2' size='0.7'>%1</t>"]]] spawn BIS_fnc_typeText; nul=[_man] execVM "TRecruit\recruiting.sqf"; Last but not least 4. dropguyinit.sqf - called by dismissing.sqf _unit=_this select 0; _unit setCaptive true; The original recruitment.sqf is called back onto the unit when dismissed. So I have a nice method of recruiting, dismissing and re-recruiting units without hassle. I'd prefer to hang on to that. I foresee one problem with the dismissing.sqf script - any other player will be able to run the "Dismiss" action on the unit. Working on that... But HOW do I get to run this script automatically on all PMC units spawned on the map?? Any tip would be welcome Edited October 16, 2019 by Theo Thalwitzer Share this post Link to post Share on other sites
avibird 1 154 Posted October 16, 2019 Hello @Theo Thalwitzer Welcome to the forum a simple Google search will give you a half a dozen scripts that allow you to recruit units. Also this forum armaholic and stream workshop you will find all you need. This is one I use a lot for recruiting units during a mission. http://www.armaholic.com/page.php?id=26312 Just beware sometimes you will get conflicts using different scripts and mods together as well as scripts and mods may stop working after game updates it's one of the downfalls of using scripts and mods and Arma. Share this post Link to post Share on other sites
wogz187 1086 Posted October 16, 2019 @Theo Thalwitzer, Try this, Spoiler you_fnc_recruit= { params ["_caller"]; [_caller] join (group player); systemChat "Recruit hired"; _caller setVariable ["isRecruit", 1]; dismissAction=_caller addAction ["Dismiss", "[_this select 0] join grpNull; (_this select 0) setVariable [""isRecruit"", 0]; (_this select 0) removeAction dismissAction;"]; }; recruitAction=[ player, "Recruit Unit", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "alive cursorTarget && (cursorTarget getvariable ""isRecruit"") <1", "playerSide isEqualTo side cursorTarget", {}, {}, { [cursorTarget] call you_fnc_recruit; }, {}, [], 2, 0, false, true] call BIS_fnc_holdActionAdd; It changes your question to: "how do I set the variable "isRecruit" for all units in a faction?", and that can be done a number of ways. Like in the unit's init properties or the group spawn script like, {_x setVariable ["isRecruit", 0];} forEach units _grp Have fun! 1 Share this post Link to post Share on other sites