activateAddons: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (added cmd group: Mods and Addons)
No edit summary
 
(37 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command
____________________________________________________________________________________________


| arma |Game name=
|game1= ofpe
|version1= 1.00


|1.00|Game version=
|game2= arma1
____________________________________________________________________________________________
|version2= 1.00


| Activates the listed addons. The list of active addons is initialized during this function. |DESCRIPTION=
|game3= arma2
____________________________________________________________________________________________
|version3= 1.00


| '''activateAddons''' [addon1, ...] |SYNTAX=
|game4= arma2oa
|version4= 1.50


|p1= [addon1, ...]: [[Array]] |PARAMETER1=
|game5= tkoh
|version5= 1.00


| [[Nothing]] |RETURNVALUE=
|game6= arma3
____________________________________________________________________________________________
|version6= 0.50
 
|x1= <code>[[activateAddons]] ["BISOFP"];</code> |EXAMPLE1=
____________________________________________________________________________________________


| [[unitAddons]], [[activatedAddons]] |SEEALSO=
|gr1= Mods and Addons


|descr= Activates the listed addons.
|s1= [[activateAddons]] addonsList
|p1= addonsList: [[Array]] of [[String]]s
|r1= [[Nothing]]
|x1= <sqf>activateAddons ["BISOFP"];</sqf>
|seealso= [[unitAddons]] [[activatedAddons]]
}}
}}


<h3 style="display:none">Notes</h3>
{{Note
<dl class="command_description">
|user= WGL.Q
<!-- Note Section BEGIN -->
|timestamp= 20090121123700
<dd class="notedate">Posted on Jan 21, 2009 - 12:37
|text= Be aware that addon's string is the {{hl|CfgPatches}} class of the desired addon to preload.
<dt class="note">[[User:WGL.Q|WGL.Q]]<dd class="note">
}}
Be aware that "Addon1" is the cfgPatches class of the desired addon to preload.
<dd class="notedate">Posted on May 10, 2009 - 11:17
<dt class="note">[[User:UNN|UNN]]<dd class="note">
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).
To 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:UNN|UNN]]
<!-- Note Section END -->
</dl>


<h3 style="display:none">Bottom Section</h3>
{{Note
|user= UNN
|timestamp= 20090510111700
|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).
To activate the passed addons along with those defined in the mission.sqm, execute the command from a configs init event using [[spawn]] or [[execVM]].
}}


[[Category:Scripting Commands|ACTIVATEADDONS]]
{{Note
[[Category:Scripting Commands OFP Elite |ACTIVATEADDONS]]
|user= samatra
[[Category:Scripting Commands Armed Assault|ACTIVATEADDONS]]
|timestamp= 20220703084305
[[Category:Command_Group: Mods_and_Addons|{{uc:{{PAGENAME}}}}]]
|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.
[[Category:Scripting Commands Arma 2|{{uc:{{PAGENAME}}}}]]
<sqf>
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
fnc_prepareClassAddons = {
[[Category:Scripting Commands Take On Helicopters|{{uc:{{PAGENAME}}}}]]
private _class = toLower _this;
 
// To avoid double checks
if(isNil"var_addonCheckedClasses") then {var_addonCheckedClasses = createHashMap;};
if(_class in var_addonCheckedClasses) exitWith {};
 
// Finding missing addons
private _needed = unitAddons _class apply {toLower _x};
private _active = activatedAddons;
private _missing = _needed - (_needed arrayIntersect _active);
if(count _missing > 0) then {
// Adding everything again, engine will figure it out itself
_active append _missing;
activateAddons _active;
};
 
var_addonCheckedClasses set [_class, _needed];
};
</sqf>
Usage would be <sqf inline>"Land_BurntGarbage_01_F" call fnc_prepareClassAddons</sqf>.
}}

Latest revision as of 09:43, 3 July 2022

Hover & click on the images for description

Description

Description:
Activates the listed addons.
Groups:
Mods and Addons

Syntax

Syntax:
activateAddons addonsList
Parameters:
addonsList: Array of Strings
Return Value:
Nothing

Examples

Example 1:
activateAddons ["BISOFP"];

Additional Information

See also:
unitAddons activatedAddons

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
WGL.Q - c
Posted on Jan 21, 2009 - 12:37 (UTC)
Be aware that addon's string is the CfgPatches class of the desired addon to preload.
UNN - c
Posted on May 10, 2009 - 11:17 (UTC)
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). To activate the passed addons along with those defined in the mission.sqm, execute the command from a configs init event using spawn or execVM.
samatra - c
Posted on Jul 03, 2022 - 08:43 (UTC)
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.
fnc_prepareClassAddons = { private _class = toLower _this; // To avoid double checks if(isNil"var_addonCheckedClasses") then {var_addonCheckedClasses = createHashMap;}; if(_class in var_addonCheckedClasses) exitWith {}; // Finding missing addons private _needed = unitAddons _class apply {toLower _x}; private _active = activatedAddons; private _missing = _needed - (_needed arrayIntersect _active); if(count _missing > 0) then { // Adding everything again, engine will figure it out itself _active append _missing; activateAddons _active; }; var_addonCheckedClasses set [_class, _needed]; };
Usage would be "Land_BurntGarbage_01_F" call fnc_prepareClassAddons.