Addon: loadout_handler - Nomas-X/AET_AUX GitHub Wiki

Description

This addon handles all players' loadouts on join or respawn. We will go over its functionality, and how it is utilized.

How It Works

When a player joins the server or respawns, this addon automatically adjusts their loadout based on the configuration set in the CBA settings. It ensures that all players are equipped with the necessary basic items (like radios, maps, and compasses) and optional inventory gear depending on role and trait.

The system is designed to respect what the mission maker places in the editor while filling in gaps where needed. It will not override existing items unless certain conditions are met (e.g., incompatible radios). This ensures that pre-configured loadouts remain intact while guaranteeing essential gear is always available.

The loadout application is split into two main systems:

Basic Equipment Handling

Handles standard items such as radios, watches, binoculars, maps, GPS devices, and compasses. Only missing or invalid items are replaced or added, making this system a safeguard rather than a full overwrite.

Inventory Handling

Allows you to configure additional gear that gets placed into the player's uniform, vest, or backpack. If the container lacks sufficient capacity, the addon dynamically increases its storage size so all items fit properly. This size increase is temporary and only affects the current instance of the container—switching to a new uniform/vest/backpack resets it to default.

The addon also supports trait-based loadouts. Specific gear can be assigned to medics, engineers, and explosive specialists, with full control over which container each trait’s items are placed into.

All of these features can be toggled or adjusted through the CBA settings provided by the addon:

Addon Options

In the below picture you can see the list of addon options that this addon provides:

Addon Options 1

Addon Options 2

Addon Options 3

Addon Options 4

  • Enable Loadout Handler: Controls if the loadout handler addon is enabled.
  • Enable On Respawn: Controls if the loadout handler runs on respawn.
  • Basic Equipment
    • TFAR Compatible Radios List: Contains the list of TFAR compatible radios that will not be replaced by the script if found on the player.
    • Radios In Need Of Programmer: Contains the list of radios that need a MicroDAGR Radio Programmer to set frequencies.
    • Radios For Everyone: Controls if all players should have radios.
    • Radio Programmers If Needed: Controls if a MicroDAGR Radio Programmer will be added if the radio needs it.
    • Radio Class Name: The class name of the radio that will be given to the player if they have no valid radio item.
    • Hand Watches For Everyone: Controls if all players should have watches.
    • Hand Watch Class Name: The class name of the watch item that will be given to the player if they have no watch item.
    • Binoculars For Everyone: Controls if all players should have binoculars.
    • Binocular Class Name: The class name of the binoculars item that will be given to the player if they have no binoculars item.
    • Maps For Everyone: Controls if all players should have maps.
    • Map Class Name: The class name of the map item that will be given to the player if they have no map item.
    • GPSs For Everyone: Controls if all players should have GPSs.
    • GPS Class Name: The class name of the GPS item that will be given to the player if they have no GPS item.
    • Compasses For Everyone: Controls if all players should have compasses.
    • Compass Class Name: The class name of the compass item that will be given to the player if they have no compass item.
  • General Inventory Handling
    • Uniform Equipment To Add: The provided array of item class names and numbers is what will be used to add to the player's uniform post initialization. The uniform's space will be increased to accommodate the addition of all new items. This space increase will be special to the worn uniform item only, and will not be applied if a new uniform is used.
    • Vest Equipment To Add: The provided array of item class names and numbers is what will be used to add to the player's vest post initialization. The vest's space will be increased to accommodate the addition of all new items. This space increase will be special to the worn vest item only, and will not be applied if a new vest is used.
    • Backpack Equipment To Add: The provided array of item class names and numbers is what will be used to add to the player's backpack post initialization. The backpack's space will be increased to accommodate the addition of all new items. This space increase will be special to the worn backpack item only, and will not be applied if a new Backpack is used.
  • Other
    • Allow Overfill On Container Switch (ACE Arsenal): If enabled the player's container (uniform, vest, backpack) in the arsenal will have its space increased when switching from a larger container to a smaller container to fit all items currently in the container.
  • Trait Based Inventory Handling
    • Medic Equipment To Add: The provided array of item class names and numbers is what will be used to add to any medic's loadout post initialization. The container's (decided by "Medic Loadout Container" CBA setting) space will be increased to accommodate the addition of all new items. This space increase will be special to the worn container item only, and will not be applied if a new container is used.
    • Engineer Equipment To Add: The provided array of item class names and numbers is what will be used to add to any engineer's loadout post initialization. The container's (decided by "Engineer Loadout Container" CBA setting) space will be increased to accommodate the addition of all new items. This space increase will be special to the worn container item only, and will not be applied if a new container is used.
    • Explosive Specialist Equipment To Add: The provided array of item class names and numbers is what will be used to add to any explosive specialist's loadout post initialization. The container's (decided by "Explosive Specialist Loadout Container" CBA setting) space will be increased to accommodate the addition of all new items. This space increase will be special to the worn container item only, and will not be applied if a new container is used.
    • Medic Loadout Container: The medic's equipment / loadout based on the "Medic Equipment To Add" CBA setting will added to the chosen container.
      • Uniform: The medic's loadout will be placed inside the uniform.
      • Vest: The medic's loadout will be placed inside the vest.
      • Backpack: The medic's loadout will be placed inside the backpack.
    • Engineer Loadout Container: The engineer's equipment / loadout based on the "Engineer Equipment To Add" CBA setting will added to the chosen container.
      • Uniform: The engineer's loadout will be placed inside the uniform.
      • Vest: The engineer's loadout will be placed inside the vest.
      • Backpack: The engineer's loadout will be placed inside the backpack.
    • Explosive Specialist Loadout Container: The explosive specialist's equipment / loadout based on the "Explosive Specialist Equipment To Add" CBA setting will added to the chosen container.
      • Uniform: The explosive specialist's loadout will be placed inside the uniform.
      • Vest: The explosive specialist's loadout will be placed inside the vest.
      • Backpack: The explosive specialist's loadout will be placed inside the backpack.

Excluding Units

If you would like to exclude certain units from the loadout handler or a part of it then simply run the code below locally on the unit's side:

Basic Equipment Exclusion

player setVariable ["AET_loadout_handler_excludeBasicEquipment", true, true];

General Inventory Handling Exclusion

// Exclude Uniform Loadout
player setVariable ["AET_loadout_handler_excludeUniformEquipment", true, true];
// Exclude Vest Loadout
player setVariable ["AET_loadout_handler_excludeVestEquipment", true, true];
// Exclude Backpack Loadout
player setVariable ["AET_loadout_handler_excludeBackpackEquipment", true, true];

Trait Based Inventory Handling Exclusion

// Exclude Medic Loadout
player setVariable ["AET_loadout_handler_excludeMedicEquipment", true, true];
// Exclude Engineer Loadout
player setVariable ["AET_loadout_handler_excludeEngineerEquipment", true, true];
// Exclude Explosive Specialist Loadout
player setVariable ["AET_loadout_handler_excludeExplosiveSpecialistEquipment", true, true];

Loadout Handling (Script)

Run the following function locally to add items to a unit's container while ensuring there is enough space by increasing max load of the container if the initial space is not enough.

/*
Authors:
	Redwan S. / Nomas

Description:
    This function is used to handle adding the items to a container and ensuring that there is enough space by increasing max load of the container if the initial space is not enough.

Arguments:
	0. <Object> The unit that items will be added to its container.

	1. <Object> The container that items will be added to and max load of will be increase.

	2. <String> The container that the item will be added to, can be "Uniform", "Vest", or "Backpack".

	3. <Array> Contains arrays of the items to be added and the amount of each item.

		3.0. <Array>
		
			3.0.0. <String> Class name of the item to be added.

			3.0.1. <Number> Amount of the item to be added.
Return Value:
	<Nil>
*/
[
	player,
	uniformContainer player,
	"Uniform",
	[["ACE_EarPlugs", 1], ["ACE_elasticBandage", 10], ["HandGrenade", 3]]
] call AET_loadout_handler_addItems;
⚠️ **GitHub.com Fallback** ⚠️