SabreCodes

Arma 3 Convert Player Squad Units to HC

Mar 23rd, 2026
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 1.87 KB | None | 0 0
  1. /*
  2.     Convert selected units (or all units if none selected) into High Command squads
  3.     and name them Squad-1, Squad-2, Squad-3, etc.
  4.  
  5.     Paste into Debug Console and run on SERVER or via Global Exec.
  6. */
  7.  
  8. private _selected = [];
  9. private _unitsToUse = [];
  10.  
  11. // Try to get currently selected units from curator/editor-style selection context
  12. if (!isNil "get3DENSelected") then {
  13.     _selected = get3DENSelected "object";
  14.     _selected = _selected select { _x isKindOf "CAManBase" };
  15. };
  16.  
  17. // Fallback: if no selected units, use all units
  18. _unitsToUse = if (_selected isNotEqualTo []) then {
  19.     _selected
  20. } else {
  21.     allUnits
  22. };
  23.  
  24. // Keep only alive human/AI soldier units
  25. _unitsToUse = _unitsToUse select {
  26.     alive _x && { _x isKindOf "CAManBase" }
  27. };
  28.  
  29. if (_unitsToUse isEqualTo []) exitWith {
  30.     hint "No valid units found.";
  31. };
  32.  
  33. // Build unique group list from chosen units
  34. private _groups = [];
  35. {
  36.     private _grp = group _x;
  37.     if !(isNull _grp) then {
  38.         if !(_grp in _groups) then {
  39.             _groups pushBack _grp;
  40.         };
  41.     };
  42. } forEach _unitsToUse;
  43.  
  44. if (_groups isEqualTo []) exitWith {
  45.     hint "No valid groups found.";
  46. };
  47.  
  48. // Find a High Command commander
  49. private _hcCommander = player;
  50.  
  51. // If player can't host HC, try to create the module logic linkage won't work by script alone.
  52. // So this assumes the player already has HC access.
  53. if (isNull _hcCommander) exitWith {
  54.     hint "No valid HC commander found.";
  55. };
  56.  
  57. private _index = 1;
  58. private _added = 0;
  59.  
  60. {
  61.     private _grp = _x;
  62.     private _grpName = format ["Squad-%1", _index];
  63.  
  64.     // Set group ID shown in UI/map
  65.     _grp setGroupIdGlobal [_grpName];
  66.  
  67.     // Add group to player's High Command
  68.     _hcCommander hcSetGroup [_grp];
  69.  
  70.     _index = _index + 1;
  71.     _added = _added + 1;
  72. } forEach _groups;
  73.  
  74. hint format ["Added %1 group(s) to High Command.", _added];
Advertisement
Add Comment
Please, Sign In to add comment