You are here: start » scripts » initarsenalhelper

Menu

initArsenalHelper

This function initializes the ACE arsenal according to the player's starting equipment plus any optional equipment provided by the mission maker. It works locally so marksmen only see their marksmen equipment, machinegunners only see their machinegunner equipment, etc..

Make sure ACE3 is installed.


Scripts

fn_initArsenalHelper.sqf
params ["_arsenal",["_optionalItems", []]];
 
// Get player's loadout
_playersLoadout = getUnitLoadout player;
// Get list of items in player's loadout and add optional items
_allPlayableUnitsItems = (flatten _playersLoadout) + _optionalItems;
// Remove duplicates and empty strings
_allPlayableUnitsItems = _allPlayableUnitsItems arrayIntersect _allPlayableUnitsItems select {_x isEqualType "" && {_x != ""}};
 
// Initialize arsenal box
[_arsenal, _allPlayableUnitsItems] call ace_arsenal_fnc_initBox;
 
// Add starting loadout as a default loadout
_loadoutName = roleDescription player;
 
// SP Workaround since roleDescription returns empty string in SP
if (roleDescription player == "") then {
	_loadoutName = "Starting Loadout";
};
[_loadoutName, _playersLoadout] call ace_arsenal_fnc_addDefaultLoadout;
initPlayerLocal.sqf
// arsenal is the name of the object this arsenal will be attached to
[arsenal,["ACE_elasticBandage"]] call SESO_fnc_initArsenalHelper;
// Version without optional equipment
[arsenal] call SESO_fnc_initArsenalHelper;

This can also be called in the arsenal's init field.

// this is the name of the object this arsenal will be attached to
[this,["ACE_elasticBandage"]] call SESO_fnc_initArsenalHelper;
// Version without optional equipment
[this] call SESO_fnc_initArsenalHelper;
Back to top