client/addons/store/functions/fnc_buyItem.sqf
Jacob Schmidt 55f60dc71f feat: Revamp admin panel, store, and arsenal systems
This commit introduces significant changes to the admin panel, store, and arsenal systems, focusing on improved functionality, UI enhancements, and code optimization.

**Admin Panel:**
- Migrated to a web-based UI for improved user experience and maintainability.
- Implemented dynamic player listing with filtering and search capabilities.
- Added functionality for managing player paygrades, sending messages, and transferring funds.
- Integrated server-side events for handling admin actions.

**Store:**
- Added `handleDelivery` event handler.
- Streamlined product selection and purchase processes.
- Improved handling of organization funds and player balances.
- Refactored code for better readability and maintainability.

**Arsenal:**
- Enhanced initialization process with improved data validation.
- Optimized item unlocking logic.

These changes aim to provide a more robust, user-friendly, and efficient experience for both administrators and players.
2025-05-03 19:33:10 -05:00

52 lines
1.8 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";
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];
};
};
[_locker] spawn FUNC(handleDelivery);
[_className, _itemType] call EFUNC(arsenal,addArmoryItem);
[format ["You have purchased %1 for $%2.", _displayName, _price], "info", 3, "right"] call EFUNC(misc,notify);