#include "..\script_component.hpp" /* * Function: forge_store_fnc_buyItem * Author: J. Schmidt * * Description: * Purchases an item and adds it to the player's locker. * * Arguments: * 0: Class Name - The classname of the item to purchase * 1: Price - The price of the item * 2: Config Type - The type of config ("item", "weapon", "magazine", "backpack") * 3: Item Type - The type of item for locker storage ("backpack", "facewear", "headgear", "hmd", "item", "magazine", "uniform", "vest", "weapon") * * Return Value: * None * * Example: * ["arifle_MX_F", 1000, "weapon", "weapon"] call forge_store_fnc_buyItem * * Public: No */ params ["_className", "_price", "_configType", "_itemType"]; private _displayName = ""; private _locker = GETVAR(player,FORGE_Locker,[]); if !([_price] call FUNC(handlePurchase)) exitWith {}; switch (_configType) do { case "item": { _displayName = getText (configFile >> "CfgWeapons" >> _className >> "displayName"); _locker pushBack [_itemType, _className]; }; case "weapon": { _displayName = getText (configFile >> "CfgWeapons" >> _className >> "displayName"); _locker pushBack [_itemType, _className]; }; case "magazine": { _displayName = getText (configFile >> "CfgMagazines" >> _className >> "displayName"); _locker pushBack [_itemType, [_className, getNumber (configFile >> "CfgMagazines" >> _className >> "count"), getNumber (configFile >> "CfgMagazines" >> _className >> "count")]]; }; case "backpack": { _displayName = getText (configFile >> "CfgVehicles" >> _className >> "displayName"); _locker pushBack [_itemType, _className]; }; }; SETPVAR(player,FORGE_Locker,_locker); [_className, _itemType] call EFUNC(arsenal,addArmoryItem); [format ["You have purchased %1 for $%2.", _displayName, _price], "info", 3, "right"] call EFUNC(misc,notify);