client/addons/arsenal/functions/fnc_addArmoryItem.sqf
Jacob Schmidt d474b3676a
All checks were successful
Build / Build (push) Successful in 28s
Refactor: Standardize function descriptions and variable handling
This commit refactors several client-side functions to improve code consistency and readability.

- Standardizes function descriptions by removing redundant "Function: forge_client..." prefixes and "[Description]" sections, focusing on concise descriptions of the function's purpose.
- Updates variable handling in arsenal functions to use GVAR and EGVARS for default values, improving consistency and reducing code duplication.
- Removes the bank init function as it is no longer needed.
- Adds a done variable to the preinit file.
2025-05-25 11:30:26 -05:00

50 lines
1.2 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Author: IDSolutions
* Adds item to player's armory unlocks and updates virtual arsenal
*
* Arguments:
* 0: Classname of item to add <STRING>
* 1: Type of item to add <STRING>
*
* Return Value:
* None
*
* Examples:
* ["B_AssaultPack_rgr", "backpack"] call forge_client_arsenal_fnc_addArmoryItem
*
* Public: Yes
*/
params [["_class", "", [""]], ["_type", "", [""]]];
private _armory_unlocks = GETVAR(player,Armory_Unlocks,GVAR(default_armory));
private _typeToNumber = switch (_type) do {
case "facewear";
case "headgear";
case "hmd";
case "item";
case "uniform";
case "vest": {0};
case "weapon": {1};
case "magazine": {2};
case "backpack": {3};
default {0};
};
private _index = (_armory_unlocks select _typeToNumber) pushBackUnique _class;
if (_index > -1) then {
SETPVAR(player,Armory_Unlocks,_armory_unlocks);
if (GVAR(armory_type) == 0) then {
[GVAR(gear_box), [_class], false, true, 1, _typeToNumber] call BFUNC(addVirtualItemCargo);
} else {
[GVAR(gear_box), [_class]] call AFUNC(arsenal,addVirtualItems);
};
true
} else {
false
};