{"name":"activateAddons","title":"activateAddons","type":"command","url":"https://community.bistudio.com/wiki/activateAddons","revid":370473,"updated":"2024-12-16T18:10:00Z","groups":["Mods and Addons"],"status":"ok","games":{"ofpe":"1.00","arma1":"1.00","arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"ofpe 1.00","arma3_since":"0.50","description":"Activates the listed addons.","syntaxes":[{"syntax":"activateAddons addonsList","params":[{"name":"addonsList","type":"Array of Strings","type_expr":"Array<String>"}],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"unary","right":{"text":"addonsList"}}],"examples":[{"code":["activateAddons [\"BISOFP\"];"]}],"see_also":["unitAddons","activatedAddons"],"notes":[{"user":"WGL.Q","date":"2009-01-21T12:37:00Z","text":"Be aware that addon's string is the `CfgPatches` class of the desired addon to preload."},{"user":"UNN","date":"2009-05-10T11:17:00Z","text":"This command will activate addons that are referenced via scripts but not included in a missions required addons section. If executed from a configs init event with the call command, it will effectively override a missions required addons, preventing them from being activated (Appears to only happen in multi player).\nTo activate the passed addons along with those defined in the mission.sqm, execute the command from a configs init event using spawn or execVM."},{"user":"Sa-Matra","date":"2022-07-03T08:43:05Z","text":"Here is a handy function to call before you do createVehicle or other create* command during missing init scripts, which should activate missing addons without having to worry about re-adding previously added addons.\n\n```sqf\nfnc_prepareClassAddons = {\n    private _class = toLower _this;\n\n    // To avoid double checks\n    if(isNil\"var_addonCheckedClasses\") then {var_addonCheckedClasses = createHashMap;};\n    if(_class in var_addonCheckedClasses) exitWith {};\n\n    // Finding missing addons\n    private _needed = unitAddons _class apply {toLower _x};\n    private _active = activatedAddons;\n    private _missing = _needed - (_needed arrayIntersect _active);\n    if(count _missing > 0) then {\n        // Adding everything again, engine will figure it out itself\n        _active append _missing;\n        activateAddons _active;\n    };\n\n    var_addonCheckedClasses set [_class, _needed];\n};\n```\n\nUsage would be `\"Land_BurntGarbage_01_F\" call fnc_prepareClassAddons`."}]}