
All checks were successful
Build / Build (push) Successful in 28s
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.
77 lines
1.9 KiB
Plaintext
77 lines
1.9 KiB
Plaintext
#include "..\script_component.hpp"
|
|
|
|
/*
|
|
* Function: forge_store_fnc_handlePurchase
|
|
* Author: J. Schmidt
|
|
*
|
|
* Description:
|
|
* Handles the purchase of an item.
|
|
*
|
|
* Arguments:
|
|
* 0: Price <NUMBER> - The price of the item
|
|
*
|
|
* Return Value:
|
|
* None
|
|
*
|
|
* Example:
|
|
* [1000] call forge_store_fnc_handlePurchase
|
|
*
|
|
* Public: No
|
|
*/
|
|
|
|
params ["_price"];
|
|
|
|
private _paymentData = GVAR(activePayment);
|
|
private _payment = call compile _paymentData;
|
|
private _store = nil;
|
|
|
|
scopeName "main";
|
|
|
|
if (count _payment > 3) then {
|
|
private _authorizedUIDs = _payment select 3;
|
|
|
|
if !(getPlayerUID player in _authorizedUIDs) then {
|
|
["You are not authorized to use this payment method!", "warning", 3, "right"] call EFUNC(misc,notify);
|
|
false breakOut "main";
|
|
};
|
|
};
|
|
|
|
if (_payment select 0 == "Organization") then {
|
|
_store = call EFUNC(org,verifyOrgStore);
|
|
private _org = _store call ["getOrg", []];
|
|
private _ownerUID = _org get "owner";
|
|
|
|
if (getPlayerUID player != _ownerUID) then {
|
|
["You do not own this organization!", "warning", 3, "right"] call EFUNC(misc,notify);
|
|
false breakOut "main";
|
|
};
|
|
};
|
|
|
|
private _varType = _payment select 2;
|
|
private _balance = switch (_varType) do {
|
|
case "organization": {
|
|
_store call ["getFunds", []];
|
|
};
|
|
case "player": { player getVariable [_payment select 1, 0] };
|
|
case "mission": { missionNamespace getVariable [_payment select 1, 0] };
|
|
default { 0 };
|
|
};
|
|
|
|
if (_balance < _price) exitWith {
|
|
["You do not have enough funds!", "warning", 3, "right"] call EFUNC(misc,notify);
|
|
false
|
|
};
|
|
|
|
switch (_varType) do {
|
|
case "organization": {
|
|
_store call ["updateFunds", -_price];
|
|
};
|
|
case "player": {
|
|
player setVariable [_payment select 1, (_balance - _price), true];
|
|
};
|
|
case "mission": {
|
|
missionNamespace setVariable [_payment select 1, (_balance - _price), true];
|
|
};
|
|
};
|
|
|
|
true |