mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-13 19:52:38 +03:00
- Added proper handling of pistol mags and regular mags in gear to prevent magazine overflow - Added pre-check if return change will overflow gear + backpack free space. If change will not fit in gear + backpack free space then buy is prevented with a message notifying the player. In the case of a sale it proceeds anyway, but notifies player if overflow occurs (see comments in returnChange) - Consolidated duplicate code for calculating free space and returning cargo of an object into new calcFreeSpace - Old calculateFreeSpace renamed to displayFreeSpace - Added Weps/Mags/Bags icons to free slot numbers display
33 lines
1.0 KiB
Plaintext
33 lines
1.0 KiB
Plaintext
private ["_player","_toPay","_moneyInfo","_totalWorth","_moneyInGear","_moneyInBackpack","_moneyInVehicle","_success","_justChecking","_regularMagsToBuy"];
|
|
|
|
_player = _this select 0;
|
|
_toPay = _this select 1;
|
|
_moneyInfo = _this select 2;
|
|
_justChecking = _this select 3;
|
|
_regularMagsToBuy = _this select 4;
|
|
_totalWorth = _moneyInfo select 4;
|
|
_moneyInGear = _moneyInfo select 1;
|
|
_moneyInBackpack = _moneyInfo select 2;
|
|
_moneyInVehicle = _moneyInfo select 3;
|
|
|
|
if (!_justChecking) then {
|
|
{
|
|
_nil = [player, _x , 1] call BIS_fnc_invRemove;
|
|
} count _moneyInGear;
|
|
|
|
if (count _moneyInBackpack > 0) then {
|
|
_nil = [unitBackpack _player, _moneyInBackpack, []] call ZUPA_fnc_removeWeaponsAndMagazinesCargo;
|
|
};
|
|
if (!isNull Z_vehicle && count _moneyInVehicle > 0) then {
|
|
_nil = [Z_vehicle, _moneyInVehicle, []] call ZUPA_fnc_removeWeaponsAndMagazinesCargo;
|
|
};
|
|
};
|
|
|
|
if (_totalWorth - _toPay == 0) then { // Money in inventory was exact amount
|
|
_success = true;
|
|
} else {
|
|
_success = [_toPay,_totalWorth,_justChecking,_regularMagsToBuy] call Z_returnChange;
|
|
};
|
|
|
|
_success
|