{"name":"activateAddons","operator":null,"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","replaced_by":[],"games":[{"game":"ofpe","name":"Operation Flashpoint: Elite","version":"1.00"},{"game":"arma1","name":"Armed Assault","version":"1.00"},{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"ofpe","name":"Operation Flashpoint: Elite","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Activates the listed addons.","syntaxes":[{"syntax":"activateAddons addonsList","since":null,"effect":null,"exec":null,"params":[{"name":"addonsList","type":"Array of Strings","optional":false,"default":null,"description":null,"types":["Array","String"],"since":null,"text":"addonsList: Array of Strings"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"unary","operator":null,"left":null,"right":{"text":"addonsList","types":["Array","String"]}}],"examples":[{"text":"```sqf\nactivateAddons [\"BISOFP\"];\n```","code":["activateAddons [\"BISOFP\"];"]}],"multiplayer":null,"problems":null,"aliases":[],"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`."}],"categories":[]}