client/addons/store/functions/fnc_buyItem.sqf
Jacob Schmidt 69f8f037df
All checks were successful
Build / Build (push) Successful in 28s
refactor: Remove tasks.json and update documentation in store functions
This commit removes the `tasks.json` file from the `.vscode` directory. Additionally, it enhances the documentation in `fnc_buyItem.sqf` and `fnc_buyVehicle.sqf` by providing clearer descriptions of item and vehicle types. The `fnc_handlePurchase.sqf` has also been updated to improve variable scoping for better code clarity.
2025-04-19 11:12:53 -05:00

55 lines
1.9 KiB
Plaintext

#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 <STRING> - The classname of the item to purchase
* 1: Price <NUMBER> - The price of the item
* 2: Config Type <STRING> - The type of config ("item", "weapon", "magazine", "backpack")
* 3: Item Type <STRING> - 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);