client/addons/arsenal/functions/fnc_addArmoryItem.sqf

56 lines
1.3 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Function: forge_client_arsenal_fnc_addArmoryItem
* Author: IDSolutions
*
* [Description]
* 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 _default = [[],[],[],[]];
private _armory_unlocks = GETVAR(player,Armory_Unlocks,_default);
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);
};
TRACE_2("Item added to armory",_class,_type);
true
} else {
false
};