Theo Thalwitzer 4 Posted September 23, 2020 This is just a little script-set I made to recruit and dismiss units at will. So far it works fine in SP (Surprisingly well, actually) but I want to make this MP compatible. The set consists of 4 small script files: 1. File: "recruiting.sqf" // Code below: /* Usage: put this in INIT of unit to be recruited; nul=[this] execVM "TRecruit\Recruiting.sqf"; // 'this' or unitname */ _guyNotRecruited = true; _fng = _this select 0; _fng setcaptive true; //use different state or condition perhaps?? _recruitGuy = _fng addAction ["Recruit","TRecruit\newguyinit.sqf"]; while {_guyNotRecruited} do { if (not(captive _fng)) then {_guyNotRecruited = false}; if (not alive _fng) exitwith {_fng removeAction _recruitGuy}; sleep 1; }; _fng removeAction _recruitGuy; [_fng] join (group player); _fng enableAI "MOVE"; sleep 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; sleep 5; nul=[_fng] execVM "TRecruit\dismissing.sqf"; 2. File: "dismissing.sqf" //Code below: _guyRecruited = true; _fng = _this select 0; _dropGuy = _fng addAction ["Dismiss","TRecruit\dropguyinit.sqf"]; while {_guyRecruited} do { if (captive _fng) then {_guyRecruited = false}; if (not alive _fng) exitwith {_fng removeAction _dropGuy}; sleep 1; }; _fng removeAction _dropGuy; [_fng] join grpNull; _fng setCaptive true; sleep 1; if (not alive _fng) then { hint "Team member deceased"; } else { 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=[_fng] execVM "TRecruit\recruiting.sqf"; }; sleep 5; 3. File: "newGuyInit.sqf" //Code below: // set unit not captive _unit=_this select 0; _unit setcaptive false; 4. File: "dropGuyInit.sqf" //Code below: // set unit not captive _unit=_this select 0; _unit setcaptive true; //// I hope someone will find this useful, but as I said it will have issues in MP. Works great in SP though. 2 Share this post Link to post Share on other sites
Gunter Severloh 4052 Posted September 23, 2020 Nice work! a good script to look at for example that does close to the same thing but alot of other functions is Bon's recruitment redux script https://www.armaholic.com/page.php?id=26312 his script works in Mp, maybe you can look at his code to see how he did it. With his script you can recruit using addaction and when you enter it a GUI comes up with a list of AI types to choose from based on the faction/side your on, if you want to remove an AI from your group, then you can dismiss them via the menu also i will add your thread here to my AI compilation list script section when i update next. Cheers! 1 Share this post Link to post Share on other sites
Theo Thalwitzer 4 Posted September 23, 2020 (edited) 10 hours ago, Gunter Severloh said: Nice work! a good script to look at for example that does close to the same thing but alot of other functions is Bon's recruitment redux script https://www.armaholic.com/page.php?id=26312 his script works in Mp, maybe you can look at his code to see how he did it. With his script you can recruit using addaction and when you enter it a GUI comes up with a list of AI types to choose from based on the faction/side your on, if you want to remove an AI from your group, then you can dismiss them via the menu also i will add your thread here to my AI compilation list script section when i update next. Cheers! Awesome thanks! I have Bon's so I'll go through it. My only problem is that I have no programming background, so I have to learn this on the fly. Bon's scripts is a little advanced for my current understanding but I'm getting there... Currently I regularly use a mod called Spyder Addons for recruitment and vehicle spawning but it doesn't allow me to dismiss team members, which is why I came up with this. Edited September 23, 2020 by Theo Thalwitzer Extra info Share this post Link to post Share on other sites
wogz187 1086 Posted September 23, 2020 @Theo Thalwitzer Here's a repeatable recruitment script which allows dismissal, Spoiler // call this on the group {_x setVariable ["MMF_isRecruit", 0]} forEach units _grp; // or just put this in the unit's init field, this setVariable ["MMF_isRecruit", 0] //AND the player must call the function once to load the AddAction, [player] call MMF_fnc_recruit; This function will handle the rest, MMF_fnc_recruit= { params ["_caller"]; if (_caller== player) then { MMF_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", "player distance cursorTarget<5 && (cursorTarget getvariable ""MMF_isRecruit"") <1", "playerSide isEqualTo side cursorTarget", {}, {}, { [cursorTarget] call MMF_fnc_recruit; }, {}, [], 2, 0, false, true] call BIS_fnc_holdActionAdd; } else { [_caller] join (group player); systemChat "Recruit hired"; _caller setVariable ["MMF_isRecruit", 1]; dismissAction=_caller addAction ["Dismiss", "[_this select 0] join grpNull; (_this select 0) setVariable [""MMF_isRecruit"", 0]; (_this select 0) removeAction dismissAction;"]; _caller addEventHandler ["Killed", { (_this select 0) removeAction dismissAction; }]; }; }; Paste the function into init.sqf or the Attributes Init Dialog. Have fun! Share this post Link to post Share on other sites
Theo Thalwitzer 4 Posted September 23, 2020 9 hours ago, wogz187 said: @Theo Thalwitzer Here's a repeatable recruitment script which allows dismissal, Hide contents // call this on the group {_x setVariable ["MMF_isRecruit", 0]} forEach units _grp; // or just put this in the unit's init field, this setVariable ["MMF_isRecruit", 0] //AND the player must call the function once to load the AddAction, [player] call MMF_fnc_recruit; This function will handle the rest, MMF_fnc_recruit= { params ["_caller"]; if (_caller== player) then { MMF_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", "player distance cursorTarget<5 && (cursorTarget getvariable ""MMF_isRecruit"") <1", "playerSide isEqualTo side cursorTarget", {}, {}, { [cursorTarget] call MMF_fnc_recruit; }, {}, [], 2, 0, false, true] call BIS_fnc_holdActionAdd; } else { [_caller] join (group player); systemChat "Recruit hired"; _caller setVariable ["MMF_isRecruit", 1]; dismissAction=_caller addAction ["Dismiss", "[_this select 0] join grpNull; (_this select 0) setVariable [""MMF_isRecruit"", 0]; (_this select 0) removeAction dismissAction;"]; _caller addEventHandler ["Killed", { (_this select 0) removeAction dismissAction; }]; }; }; Paste the function into init.sqf or the Attributes Init Dialog. Have fun! Super! I'll give it a go! Share this post Link to post Share on other sites