Add handling of magazine overflow in AdvTrade and free slot icons

- 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
This commit is contained in:
ebaydayz
2016-07-31 18:38:39 -04:00
parent d7cb2b446e
commit a5be49c546
20 changed files with 359 additions and 422 deletions

View File

@@ -393,10 +393,10 @@ class AdvancedTrading
colorBackground[] = {1,1,1,1};
color[] = {0,0,0,1};
};
class RscText_ATT8: ZSC_RscText
class RscText_ATT8: ZSC_RscStructuredText
{
idc = 7404;
text = "0/0/0";
text = "";
x = 0.45 * safezoneW + safezoneX;
y = 0.32 * safezoneH + safezoneY;
w = 0.15 * safezoneW;

View File

@@ -1,19 +1,24 @@
private ["_selection","_return","_toBuyWeaps","_toBuyMags","_toBuyBags","_toolsToBuy","_sidearmToBuy","_primaryToBuy","_currentPrimarys"
,"_currentSec","_currentPrim","_currentTool","_p","_b","_check0","_check1","_check2","_check3","_check4","_mags","_weaps","_bags"
,"_normalBags","_normalMags","_normalWeaps","_allowedMags","_allowedPrimary","_allowedTools","_allowedSidearm","_allowedWeapons","_allowedBackpacks"
,"_totalSpace","_totalNewSpace","_counter","_parentClasses","_alreadyInBackpack","_kinds","_kinds2","_kinds3","_amounts","_amounts2","_amounts3",
"_actualMags","_toolClasses","_duplicate","_quantity","_tool","_totalBagSlots"
private ["_selection","_return","_toBuyWeaps","_toBuyTotalMags","_toBuyBags","_toolsToBuy","_sidearmToBuy"
,"_primaryToBuy","_currentPrimarys","_p","_b","_check0","_check1","_check2","_check3","_check4","_allowedMags"
,"_allowedPrimary","_allowedTools","_allowedSidearm","_allowedBackpacks","_parentClasses","_toolClasses"
,"_duplicate","_quantity","_tool","_totalBagSlots","_pistolMags","_regularMags","_toBuyPistolMags"
,"_toBuyRegularMags","_type","_freeSpace","_backpack","_totalSpace"
];
_selection = Z_SellingFrom;
_return = false;
_toBuyWeaps = _this select 0;
_toBuyMags = _this select 1;
_toBuyPistolMags = (_this select 1) select 0;
_toBuyRegularMags = (_this select 1) select 1;
_toBuyTotalMags = _toBuyPistolMags + _toBuyRegularMags;
_toBuyBags = _this select 2;
_toolsToBuy = _this select 3;
_sidearmToBuy = _this select 4;
_primaryToBuy = _this select 5;
_vehiclesToBuy = _this select 6;
_toolClasses = _this select 7;
_allowedMags = 0;
_allowedWeapons = 0;
_allowedBackpacks = 0;
if (_vehiclesToBuy > 1) exitWith {systemChat localize "STR_EPOCH_TRADE_ONE_VEHICLE"; false;};
if (_vehiclesToBuy > 0) then {
@@ -21,8 +26,16 @@ if (_vehiclesToBuy > 0) then {
};
if (_selection == 2) then { //gear
_actualMags = {!(_x in MeleeMagazines)} count (magazines player);
_allowedMags = 20 - _actualMags;
_pistolMags = 0;
_regularMags = 0;
{
_type = getNumber (configFile >> "CfgMagazines" >> _x >> "type");
if (_type == 16) then {_pistolMags = _pistolMags + 1;}; // 16 = WeaponSlotHandGunItem (pistol ammo slot)
if (_type == 256) then {_regularMags = _regularMags + 1;}; // 256 = WeaponSlotItem (normal magazine)
} count (magazines player);
_allowedPistolMags = 8 - _pistolMags;
_allowedRegularMags = 12 - _regularMags;
_currentPrimarys = 0;
@@ -75,10 +88,10 @@ if (_selection == 2) then { //gear
} else {
systemChat format[localize "STR_EPOCH_TRADE_GEAR_FULL", _allowedPrimary, _allowedSidearm , _allowedTools];
};
if (_allowedMags >= _toBuyMags) then {
if (_allowedPistolMags >= _toBuyPistolMags && _allowedRegularMags >= _toBuyRegularMags) then {
_check2 = true;
} else {
systemChat format[localize "STR_EPOCH_TRADE_MAGS_FULL",_allowedMags];
systemChat format[localize "STR_EPOCH_TRADE_MAGS_FULL",_allowedRegularMags,_allowedPistolMags];
};
if (_allowedBackpacks >= _toBuyBags) then {
_check3 = true;
@@ -88,52 +101,11 @@ if (_selection == 2) then { //gear
};
if (_selection == 1) then { //vehicle
_allowedMags = 0;
_allowedWeapons = 0;
_allowedBackpacks = 0;
if (!isNull Z_vehicle) then {
_mags = getMagazineCargo Z_vehicle;
_weaps = getWeaponCargo Z_vehicle;
_bags = getBackpackCargo Z_vehicle;
_normalMags = [];
_normalWeaps = [];
_normalBags = [];
_kinds = _mags select 0;
_amounts = _mags select 1;
{
_counter = 0 ;
while {_counter < (_amounts select _forEachIndex)} do {
_normalMags set [count(_normalMags),_x];
_counter = _counter + 1;
};
} forEach _kinds;
_kinds2 = _weaps select 0;
_amounts2 = _weaps select 1;
{
_counter = 0 ;
while {_counter < (_amounts2 select _forEachIndex)} do {
_normalWeaps set [count(_normalWeaps),_x];
_counter = _counter + 1;
};
} forEach _kinds2;
_kinds3 = _bags select 0;
_amounts3 = _bags select 1;
{
_counter = 0 ;
while{_counter < (_amounts3 select _forEachIndex)} do {
_normalBags set [count(_normalBags),_x];
_counter = _counter + 1;
};
} forEach _kinds3;
_allowedWeapons = getNumber (configFile >> 'CfgVehicles' >> (typeOf Z_vehicle) >> 'transportMaxWeapons') - count(_normalWeaps);
_allowedMags = getNumber (configFile >> 'CfgVehicles' >> (typeOf Z_vehicle) >> 'transportMaxMagazines') - count(_normalMags);
_allowedBackpacks = getNumber (configFile >> 'CfgVehicles' >> (typeOf Z_vehicle) >> 'transportMaxBackpacks') - count(_normalBags);
_freeSpace = [Z_vehicle,0,0,0,0] call Z_calcFreeSpace;
_allowedMags = _freeSpace select 1;
_allowedWeapons = _freeSpace select 2;
_allowedBackpacks = _freeSpace select 3;
};
_check1 = false;
@@ -145,7 +117,7 @@ if (_selection == 1) then { //vehicle
} else {
systemChat format[localize "STR_EPOCH_TRADE_VEHICLE_WEPS", _allowedWeapons];
};
if (_allowedMags >= _toBuyMags) then {
if (_allowedMags >= _toBuyTotalMags) then {
_check2 = true;
} else {
systemChat format[localize "STR_EPOCH_TRADE_VEHICLE_MAGS", _allowedMags];
@@ -160,71 +132,18 @@ if (_selection == 1) then { //vehicle
};
if (_selection == 0) then { //backpack
_allowedWeapons = 0;
_allowedMags = 0;
_allowedBackpacks = 0;
_totalSpace = 0;
_totalNewSpace = 0;
_totalBagSlots = 0;
_backpack = unitBackpack player;
_check0 = false;
if (!isNull _backpack) then {
_check0 = true;
_mags = getMagazineCargo _backpack;
_weaps = getWeaponCargo _backpack;
_normalMags = [];
_normalWeaps = [];
_kinds = _mags select 0;
_amounts = _mags select 1;
{
_counter = 0 ;
while {_counter < (_amounts select _forEachIndex)} do {
_normalMags set [count(_normalMags), _x];
_counter = _counter + 1;
};
} forEach _kinds;
_kinds2 = _weaps select 0;
_amounts2 = _weaps select 1;
{
_counter = 0 ;
while {_counter < (_amounts2 select _forEachIndex)} do {
_normalWeaps set [count(_normalWeaps), _x];
_counter = _counter + 1;
};
} forEach _kinds2;
_allowedWeapons = getNumber (configFile >> 'CfgVehicles' >> (typeOf _backpack) >> 'transportMaxWeapons') - count(_normalWeaps);
_totalBagSlots = getNumber (configFile >> 'CfgVehicles' >> (typeOf _backpack) >> 'transportMaxMagazines');
_allowedMags = _totalBagSlots - count(_normalMags);
_currentPrim = 0;
_currentSec = 0;
_currentTool = 0;
{
_parentClasses = [(configFile >> "CfgWeapons" >> _x),true] call BIS_fnc_returnParents;
if ('ItemCore' in _parentClasses || 'Binocular' in _parentClasses) then {
_currentTool = _currentTool + 1;
} else {
if ('PistolCore' in _parentClasses) then {
_currentSec = _currentSec + 1;
} else {
_currentPrim = _currentPrim + 1;
};
};
} count _normalWeaps;
_alreadyInBackpack = (10 * _currentPrim) + (5 * _currentSec) + _currentTool + count(_normalMags);
_totalNewSpace = 10 * _primaryToBuy + 5 * _sidearmToBuy + _toolsToBuy + _toBuyMags;
_totalSpace = _alreadyInBackpack + _totalNewSpace;
_freeSpace = [_backpack,_primaryToBuy,_sidearmToBuy,_toolsToBuy,_toBuyTotalMags] call Z_calcFreeSpace;
_totalSpace = _freeSpace select 0;
_allowedMags = _freeSpace select 1;
_allowedWeapons = _freeSpace select 2;
_totalBagSlots = _freeSpace select 4;
} else {
systemChat localize "STR_EPOCH_TRADE_NO_BACKPACK";
};
@@ -239,12 +158,12 @@ if (_selection == 0) then { //backpack
} else {
systemChat format[localize "STR_EPOCH_TRADE_BAG_WEPS", _allowedWeapons];
};
if (_allowedMags >= _toBuyMags) then {
if (_allowedMags >= _toBuyTotalMags) then {
_check2 = true;
} else {
systemChat format[localize "STR_EPOCH_TRADE_BAG_MAGS", _allowedMags];
};
if (_allowedBackpacks >= _toBuyBags) then {
if (_toBuyBags < 1) then { // A backpack can not hold any backpacks
_check3 = true;
};
@@ -257,4 +176,4 @@ if (_selection == 0) then { //backpack
if (_check0 && _check1 && _check2 && _check3 && _check4) then { _return = true; };
};
_return;
_return

View File

@@ -1,10 +1,11 @@
private ["_magazinesToBuy", "_weaponsToBuy", "_backpacksToBuy", "_toolsToBuy", "_sidearmToBuy", "_primaryToBuy", "_priceToBuy"
,"_enoughMoney", "_myMoney", "_canBuy", "_moneyInfo","_count","_success","_backpack","_toolClasses","_itemsToLog","_tCost","_bTotal","_backpack"
];
private ["_weaponsToBuy","_backpacksToBuy","_toolsToBuy","_sidearmToBuy","_primaryToBuy","_priceToBuy"
,"_enoughMoney","_myMoney","_canBuy","_moneyInfo","_count","_success","_backpack","_toolClasses","_itemsToLog"
,"_tCost","_bTotal","_backpack","_pistolMagsToBuy","_regularMagsToBuy"];
if (count Z_BuyingArray < 1) exitWith { systemChat localize "STR_EPOCH_TRADE_BUY_NO_ITEMS"; };
_magazinesToBuy = 0;
_pistolMagsToBuy = 0;
_regularMagsToBuy = 0;
_weaponsToBuy = 0;
_backpacksToBuy = 0;
_toolsToBuy = 0;
@@ -35,7 +36,11 @@ if (Z_SingleCurrency) then {
_priceToBuy = _priceToBuy + ((_x select 9)*(_x select 2));
};
if (_x select 1 == "trade_items") then {
_magazinesToBuy = _magazinesToBuy + (_x select 9) ;
if (getNumber (configFile >> "CfgMagazines" >> (_x select 0) >> "type") == 16) then { // 16 = WeaponSlotHandGunItem (pistol ammo slot)
_pistolMagsToBuy = _pistolMagsToBuy + (_x select 9);
} else {
_regularMagsToBuy = _regularMagsToBuy + (_x select 9);
};
_priceToBuy = _priceToBuy + ((_x select 9)*(_x select 2));
};
if (_x select 1 == "trade_backpacks") then {
@@ -68,7 +73,11 @@ if (Z_SingleCurrency) then {
_priceToBuy = _priceToBuy + ((_x select 11)*(_x select 2)*(_x select 9)); // _worth * _price * _amount
};
if (_x select 1 == "trade_items") then {
_magazinesToBuy = _magazinesToBuy + (_x select 9) ;
if (getNumber (configFile >> "CfgMagazines" >> (_x select 0) >> "type") == 16) then { // 16 = WeaponSlotHandGunItem (pistol ammo slot)
_pistolMagsToBuy = _pistolMagsToBuy + (_x select 9);
} else {
_regularMagsToBuy = _regularMagsToBuy + (_x select 9);
};
_priceToBuy = _priceToBuy + ((_x select 11) *(_x select 2)*(_x select 9));
};
if (_x select 1 == "trade_backpacks") then {
@@ -85,7 +94,7 @@ if (Z_SingleCurrency) then {
} count Z_BuyingArray;
};
_canBuy = [_weaponsToBuy,_magazinesToBuy,_backpacksToBuy,_toolsToBuy, _sidearmToBuy, _primaryToBuy,_vehiclesToBuy,_toolClasses] call Z_allowBuying;
_canBuy = [_weaponsToBuy,[_pistolMagsToBuy,_regularMagsToBuy],_backpacksToBuy,_toolsToBuy,_sidearmToBuy,_primaryToBuy,_vehiclesToBuy,_toolClasses] call Z_allowBuying;
_myMoney = player getVariable[Z_MoneyVariable,0];
@@ -107,6 +116,9 @@ if (Z_SingleCurrency) then {
if (Z_SellingFrom == 0 && _backpacksToBuy > 0) exitWith { systemChat localize "STR_EPOCH_TRADE_BAG_BAGS"; }; //backpack
if (Z_SellingFrom == 2 && !isNull _backpack && _backpacksToBuy > 0) exitWith { systemChat localize "STR_EPOCH_TRADE_HAVE_BACKPACK"; }; //gear
_success = if (Z_SingleCurrency) then { true } else { [player,_priceToBuy,_moneyInfo,true,_regularMagsToBuy] call Z_payDefault };
if (!_success) exitWith { systemChat localize "STR_EPOCH_TRADE_GEAR_AND_BAG_FULL"; }; // Not enough room in gear or bag to accept change
if (_enoughMoney) then {
if (_canBuy) then {
_bTotal = 0;
@@ -222,7 +234,7 @@ if (_enoughMoney) then {
systemChat format[localize "STR_EPOCH_TRADE_BUY_IN_GEAR",_bTotal];
};
if (!Z_SingleCurrency) then {
_success = [player,_priceToBuy, _moneyInfo] call Z_payDefault;
_success = [player,_priceToBuy,_moneyInfo,false,0] call Z_payDefault;
if (_success) then {
_tCost = "";
_tCost = _priceToBuy call z_calcDefaultCurrencyNoImg;

View File

@@ -0,0 +1,85 @@
private ["_object","_mags","_weaps","_normalMags","_normalWeaps","_kinds","_kinds2","_kinds3","_amounts","_amounts2","_amounts3",
"_counter","_allowedMags","_allowedWeapons","_allowedBackpacks","_currentPrim","_currentSec","_currentTool",
"_parentClasses","_alreadyInBackpack","_totalNewSpace","_primaryToBuy","_sidearmToBuy","_toolsToBuy",
"_toBuyTotalMags","_totalSpace","_bags","_totalBagSlots"];
_object = _this select 0;
_primaryToBuy = _this select 1; // Only needed if backpack
_sidearmToBuy = _this select 2; // Only needed if backpack
_toolsToBuy = _this select 3; // Only needed if backpack
_toBuyTotalMags = _this select 4; // Only needed if backpack
_allowedMags = 0;
_allowedWeapons = 0;
_allowedBackpacks = 0;
_totalSpace = 0;
_totalNewSpace = 0;
_totalBagSlots = 0;
_mags = getMagazineCargo _object;
_weaps = getWeaponCargo _object;
_bags = getBackpackCargo _object;
_normalMags = [];
_normalWeaps = [];
_normalBags = [];
_kinds = _mags select 0;
_amounts = _mags select 1;
{
_counter = 0;
while {_counter < (_amounts select _forEachIndex)} do {
_normalMags set [count _normalMags, _x];
_counter = _counter + 1;
};
} forEach _kinds;
_kinds2 = _weaps select 0;
_amounts2 = _weaps select 1;
{
_counter = 0;
while {_counter < (_amounts2 select _forEachIndex)} do {
_normalWeaps set [count _normalWeaps, _x];
_counter = _counter + 1;
};
} forEach _kinds2;
_kinds3 = _bags select 0;
_amounts3 = _bags select 1;
{
_counter = 0;
while {_counter < (_amounts3 select _forEachIndex)} do {
_normalBags set [count _normalBags, _x];
_counter = _counter + 1;
};
} forEach _kinds3;
_allowedMags = getNumber (configFile >> "CfgVehicles" >> (typeOf _object) >> "transportMaxMagazines") - count(_normalMags);
_allowedWeapons = getNumber (configFile >> "CfgVehicles" >> (typeOf _object) >> "transportMaxWeapons") - count(_normalWeaps);
_allowedBackpacks = getNumber (configFile >> "CfgVehicles" >> (typeOf _object) >> "transportMaxBackpacks") - count(_normalBags);
if (_object isKindOf "Bag_Base_EP1") then {
// Different weapon types take up different amounts of space in backpacks, but not vehicles
_currentPrim = 0;
_currentSec = 0;
_currentTool = 0;
{
_parentClasses = [(configFile >> "CfgWeapons" >> _x),true] call BIS_fnc_returnParents;
if ("ItemCore" in _parentClasses || "Binocular" in _parentClasses) then {
_currentTool = _currentTool + 1;
} else {
if ("PistolCore" in _parentClasses) then {
_currentSec = _currentSec + 1;
} else {
_currentPrim = _currentPrim + 1;
};
};
} count _normalWeaps;
//transportMaxMagazines is the same as total number of 1x slots in backpack
_totalBagSlots = getNumber (configFile >> "CfgVehicles" >> (typeOf _backpack) >> "transportMaxMagazines");
_alreadyInBackpack = (10 * _currentPrim) + (5 * _currentSec) + _currentTool + count(_normalMags);
_totalNewSpace = 10 * _primaryToBuy + 5 * _sidearmToBuy + _toolsToBuy + _toBuyTotalMags;
_totalSpace = _alreadyInBackpack + _totalNewSpace;
};
[_totalSpace,_allowedMags,_allowedWeapons,_allowedBackpacks,_totalBagSlots,_normalMags,_normalWeaps,_normalBags]

View File

@@ -1,132 +0,0 @@
private["_selection","_returnArray","_allowedMags","_allowedWeapons","_allowedBackpacks","_allowedTools","_allowedPrimary","_allowedSidearm","_formattedText","_pic"
,"_backpack","_vehicleWeapons","_vehicleMagazines","_vehicleBackpacks","_tempWeaponsArray","_tempBackpackArray","_tempMagazinesArray","_actualMags"
,"_normalMags","_normalWeaps","_kinds","_kinds2","_amounts","_amounts2","_counter"];
#include "defines.hpp"
_selection = _this select 0;
_returnArray = [0,0,0];
if (_selection == 2) then { //gear
_actualMags = {!(_x in MeleeMagazines)} count (magazines player);
_allowedMags = 20 - _actualMags;
// 12 toolbelt + 1 Binoculars + 1 NVG + 1 Pistol + 1 Primary (onBack isn't counted in weapons player)
_allowedWeapons = 16 - count(weapons player);
_pic = getText (configFile >> 'CfgVehicles' >> (typeOf player) >> 'portrait');
_formattedText = format [
"<img image='%1' size='3' align='center'/>"
, _pic
];
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_CONTAINERINFO) ctrlSetStructuredText parseText _formattedText;
_backpack = unitBackpack player;
_allowedBackpacks = if (isNull _backpack) then {1} else {0};
_returnArray = [_allowedMags, _allowedWeapons, _allowedBackpacks];
};
if (_selection == 1) then { //vehicle
_allowedMags = 0;
_allowedWeapons = 0;
_allowedBackpacks = 0;
_vehicleMagazines = 0;
_vehicleWeapons = 0;
_vehicleBackpacks = 0;
if (!isNull Z_vehicle) then {
_pic = getText (configFile >> 'CfgVehicles' >> (typeOf Z_vehicle) >> 'picture');
_formattedText = format [
"<img image='%1' size='3' align='center'/>"
, _pic
];
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_CONTAINERINFO) ctrlSetStructuredText parseText _formattedText;
_tempMagazinesArray = getMagazineCargo Z_vehicle;
{
_vehicleMagazines = _vehicleMagazines + _x;
} count (_tempMagazinesArray select 1);
_tempWeaponsArray = getWeaponCargo Z_vehicle;
{
_vehicleWeapons = _vehicleWeapons + _x;
} count (_tempWeaponsArray select 1);
_tempBackpackArray = getBackpackCargo Z_vehicle;
{
_vehicleBackpacks = _vehicleBackpacks + _x;
} count (_tempBackpackArray select 1);
_allowedWeapons = getNumber (configFile >> 'CfgVehicles' >> (typeOf Z_vehicle) >> 'transportMaxWeapons');
_allowedMags = getNumber (configFile >> 'CfgVehicles' >> (typeOf Z_vehicle) >> 'transportMaxMagazines');
_allowedBackpacks = getNumber (configFile >> 'CfgVehicles' >> (typeOf Z_vehicle) >> 'transportmaxbackpacks');
};
_returnArray = [_allowedMags - _vehicleMagazines, _allowedWeapons - _vehicleWeapons, _allowedBackpacks - _vehicleBackpacks];
};
if (_selection == 0) then { //backpack
_allowedBackpacks = 0;
_totalBagSlots = 0;
_alreadyInBackpack = 0;
_backpack = unitBackpack player;
if (!isNull _backpack) then {
_pic = getText (configFile >> 'CfgVehicles' >> (typeOf _backpack) >> 'picture');
_formattedText = format [
"<img image='%1' size='3' align='center'/>"
, _pic
];
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_CONTAINERINFO) ctrlSetStructuredText parseText _formattedText;
_tempMagazinesArray = getMagazineCargo _backpack;
_tempWeaponsArray = getWeaponCargo _backpack;
_normalMags = [];
_normalWeaps = [];
_kinds = _tempMagazinesArray select 0;
_amounts = _tempMagazinesArray select 1;
{
_counter = 0;
while {_counter < (_amounts select _forEachIndex)} do {
_normalMags set [count(_normalMags), _x];
_counter = _counter + 1;
};
} forEach _kinds;
_kinds2 = _tempWeaponsArray select 0;
_amounts2 = _tempWeaponsArray select 1;
{
_counter = 0;
while {_counter < (_amounts2 select _forEachIndex)} do {
_normalWeaps set [count(_normalWeaps), _x];
_counter = _counter + 1;
};
} forEach _kinds2;
_totalBagSlots = getNumber (configFile >> 'CfgVehicles' >> (typeOf _backpack) >> 'transportMaxMagazines');
_currentPrim = 0;
_currentSec = 0;
_currentTool = 0;
{
_parentClasses = [(configFile >> "CfgWeapons" >> _x),true] call BIS_fnc_returnParents;
if ('ItemCore' in _parentClasses or 'Binocular' in _parentClasses) then {
_currentTool = _currentTool + 1;
} else {
if ('PistolCore' in _parentClasses) then {
_currentSec = _currentSec + 1;
} else {
_currentPrim = _currentPrim + 1;
};
};
} count _normalWeaps;
_alreadyInBackpack = (10 * _currentPrim) + (5 * _currentSec) + _currentTool + count(_normalMags);
};
_returnArray = [_totalBagSlots - _alreadyInBackpack, floor((_totalBagSlots - _alreadyInBackpack) / 10), _allowedBackpacks];
};
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_SLOTSDISPLAY) ctrlSetText format["%1/%2/%3",_returnArray select 1,_returnArray select 0,_returnArray select 2];

View File

@@ -1,5 +1,4 @@
private ['_worth', '_total_currency','_return','_part','_totalToPay','_inventoryMoney','_backpackMoney',"_kinds","_kinds2","_kinds3","_amounts","_amounts2","_amounts3"
,"_vehicleMoney"];
private ["_worth","_total_currency","_return","_part","_totalToPay","_inventoryMoney","_backpackMoney","_kinds","_amounts","_vehicleMoney"];
_totalToPay = _this;
_return = [false, [], [], [], 0];

View File

@@ -0,0 +1,75 @@
private ["_selection","_returnArray","_allowedMags","_allowedWeapons","_allowedBackpacks","_pic","_backpack","_actualMags","_freeSpace"];
#include "defines.hpp"
_selection = _this select 0;
_returnArray = [0,0,0];
if (_selection == 2) then { //gear
_actualMags = {!(_x in MeleeMagazines)} count (magazines player);
_allowedMags = 20 - _actualMags;
// 12 toolbelt + 1 Binoculars + 1 NVG + 1 Pistol + 1 Primary (onBack isn't counted in weapons player)
_allowedWeapons = 16 - count(weapons player);
_pic = getText (configFile >> "CfgVehicles" >> (typeOf player) >> "portrait");
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_CONTAINERINFO) ctrlSetStructuredText parseText format [
"<img image='%1' size='3' align='center'/>"
, _pic
];
_backpack = unitBackpack player;
_allowedBackpacks = if (isNull _backpack) then {1} else {0};
_returnArray = [_allowedMags, _allowedWeapons, _allowedBackpacks];
};
if (_selection == 1) then { //vehicle
_allowedMags = 0;
_allowedWeapons = 0;
_allowedBackpacks = 0;
if (!isNull Z_vehicle) then {
_freeSpace = [Z_vehicle,0,0,0,0] call Z_calcFreeSpace;
_allowedMags = _freeSpace select 1;
_allowedWeapons = _freeSpace select 2;
_allowedBackpacks = _freeSpace select 3;
_pic = getText (configFile >> "CfgVehicles" >> (typeOf Z_vehicle) >> "picture");
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_CONTAINERINFO) ctrlSetStructuredText parseText format [
"<img image='%1' size='3' align='center'/>"
, _pic
];
};
_returnArray = [_allowedMags, _allowedWeapons, _allowedBackpacks];
};
if (_selection == 0) then { //backpack
_totalBagSlots = 0;
_totalSpace = 0;
_backpack = unitBackpack player;
if (!isNull _backpack) then {
_freeSpace = [_backpack,0,0,0,0] call Z_calcFreeSpace;
_totalSpace = _freeSpace select 0;
_allowedMags = _freeSpace select 1;
_allowedWeapons = _freeSpace select 2;
_totalBagSlots = _freeSpace select 4;
_pic = getText (configFile >> "CfgVehicles" >> (typeOf _backpack) >> "picture");
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_CONTAINERINFO) ctrlSetStructuredText parseText format [
"<img image='%1' size='3' align='center'/>"
, _pic
];
};
_returnArray = [_totalBagSlots - _totalSpace, floor((_totalBagSlots - _totalSpace) / 10), 0];
};
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_SLOTSDISPLAY) ctrlSetStructuredText parseText format [
"<img image='%1'/><t> %2 </t>" + //Weapons
"<img image='%3'/><t> %4 </t>" + //Mags
"<img image='%5'/><t> %6</t>", //Backpacks
"\z\addons\dayz_code\gui\gear\gear_ui_slots_weapons_white.paa",_returnArray select 1,
"\z\addons\dayz_code\gui\gear\gear_ui_slots_items_white.paa",_returnArray select 0,
"\z\addons\dayz_code\gui\gear\gear_ui_slots_backpacks_white.paa",_returnArray select 2
];

View File

@@ -3,7 +3,7 @@
*
* Gets all your items stored in your backpack and innitiates the selling list.
**/
private ["_backpack","_pic","_formattedText","_mags","_weaps","_normalMags","_normalWeaps","_kinds","_kinds2","_amounts","_amounts2"];
private ["_backpack","_pic","_formattedText","_normalMags","_normalWeaps","_freeSpace"];
#include "defines.hpp"
call Z_clearLists;
@@ -20,30 +20,10 @@ if (!isNull _backpack) then {
];
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_CONTAINERINFO) ctrlSetStructuredText parseText _formattedText;
_mags = getMagazineCargo _backpack;
_weaps = getWeaponCargo _backpack;
_normalMags = [];
_normalWeaps = [];
_kinds = _mags select 0;
_amounts = _mags select 1;
{
_counter = 0 ;
while {_counter < (_amounts select _forEachIndex)} do {
_normalMags set [count(_normalMags),_x];
_counter = _counter + 1;
};
} forEach _kinds;
_kinds2 = _weaps select 0;
_amounts2 = _weaps select 1;
{
_counter = 0 ;
while {_counter < (_amounts2 select _forEachIndex)} do {
_normalWeaps set [count(_normalWeaps),_x];
_counter = _counter + 1;
};
} forEach _kinds2;
_freeSpace = [_backpack,0,0,0,0] call Z_calcFreeSpace;
_normalMags = _freeSpace select 5;
_normalWeaps = _freeSpace select 6;
[_normalMags,_normalWeaps, typeOf _backpack,[]] call Z_checkArrayInConfig;
};

View File

@@ -30,7 +30,7 @@ if (Z_Selling) then {
call Z_getBackpackItems;
} else {
ctrlSetText [Z_AT_TRADERLINE1, localize "STR_EPOCH_TRADE_NO_BACKPACK"];
ctrlSetText [Z_AT_SLOTSDISPLAY, " "];
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_SLOTSDISPLAY) ctrlSetStructuredText parseText " ";
};
};
case 1: { //vehicle
@@ -41,7 +41,7 @@ if (Z_Selling) then {
call Z_getVehicleItems;
} else {
ctrlSetText [Z_AT_TRADERLINE1, localize "STR_EPOCH_PLAYER_245"];
ctrlSetText [Z_AT_SLOTSDISPLAY, " "];
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_SLOTSDISPLAY) ctrlSetStructuredText parseText " ";
};
};
case 2: { //gear
@@ -58,10 +58,10 @@ if (Z_Selling) then {
if (!isNull _backpack) then {
Z_SellingFrom = 0;
[localize "STR_EPOCH_TRADE_BUYING_BACKPACK"] call Z_filleTradeTitle;
[0] call Z_calculateFreeSpace;
[0] call Z_displayFreeSpace;
} else {
ctrlSetText [Z_AT_TRADERLINE1, localize "STR_EPOCH_TRADE_NO_BACKPACK"];
ctrlSetText [Z_AT_SLOTSDISPLAY, " "];
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_SLOTSDISPLAY) ctrlSetStructuredText parseText " ";
};
};
case 1: { //vehicle
@@ -69,16 +69,16 @@ if (Z_Selling) then {
if (_canBuyInVehicle) then {
Z_SellingFrom = 1;
[localize "STR_EPOCH_TRADE_BUYING_VEHICLE"] call Z_filleTradeTitle;
[1] call Z_calculateFreeSpace;
[1] call Z_displayFreeSpace;
} else {
ctrlSetText [Z_AT_TRADERLINE1, localize "STR_EPOCH_PLAYER_245"];
ctrlSetText [Z_AT_SLOTSDISPLAY, " "];
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_SLOTSDISPLAY) ctrlSetStructuredText parseText " ";
};
};
case 2: { //gear
Z_SellingFrom = 2;
[localize "STR_EPOCH_TRADE_BUYING_GEAR"] call Z_filleTradeTitle;
[2] call Z_calculateFreeSpace;
[2] call Z_displayFreeSpace;
};
};
};

View File

@@ -9,8 +9,8 @@ private ["_mags","_weaps","_skin","_formattedText","_bag","_bags","_pic"];
call Z_clearLists;
Z_SellArray = [];
Z_SellableArray = [];
_mags = magazines player;
_weaps = weapons player;
_mags = magazines player;
_weaps = weapons player;
_bag = unitBackpack player;
_bags = if (isNull _bag) then {[]} else {[typeOf _bag]};

View File

@@ -3,7 +3,7 @@
*
* Gets all your items stored in your vehicle and innitiates the selling list.
**/
private ["_vehicle","_pos","_list","_formattedText","_pic","_mags","_weaps","_bags","_normalMags","_normalWeaps","_normalBags","_kinds","_amounts","_counter","_kinds2","_amounts2"];
private ["_vehicle","_pos","_list","_formattedText","_pic","_normalMags","_normalWeaps","_freeSpace"];
#include "defines.hpp"
Z_vehicle = objNull;
@@ -31,46 +31,11 @@ if (!isNull _vehicle) then {
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_CONTAINERINFO) ctrlSetStructuredText parseText _formattedText;
Z_vehicle = _vehicle;
_mags = getMagazineCargo _vehicle;
_weaps = getWeaponCargo _vehicle;
_bags = getBackpackCargo _vehicle;
_normalMags = [];
_normalWeaps = [];
_normalBags = [];
_kinds = _mags select 0;
_amounts = _mags select 1;
{
_counter = 0 ;
while {_counter < (_amounts select _forEachIndex)} do {
_normalMags set [count(_normalMags),_x];
_counter = _counter + 1;
};
} forEach _kinds;
_kinds2 = _weaps select 0;
_amounts2 = _weaps select 1;
{
_counter = 0 ;
while {_counter < (_amounts2 select _forEachIndex)} do {
_normalWeaps set [count(_normalWeaps),_x];
_counter = _counter + 1;
};
} forEach _kinds2;
_freeSpace = [_vehicle,0,0,0,0] call Z_calcFreeSpace;
_normalMags = _freeSpace select 5;
_normalWeaps = _freeSpace select 6;
//_normalBags = _freeSpace select 7;
// Can't sell backpacks from vehicle because there is currently no command to remove single backpacks from cargo (only clearBackpackCargo which removes all)
/*
_kinds3 = _bags select 0;
_amounts3 = _bags select 1;
{
_counter = 0 ;
while {_counter < (_amounts3 select _forEachIndex)} do {
_normalBags set [count(_normalBags),_x];
_counter = _counter + 1;
};
} forEach _kinds3;
*/
[_normalWeaps,_normalMags, typeOf _vehicle,_normalBags] call Z_checkArrayInConfig;
[_normalWeaps,_normalMags,typeOf _vehicle,[]] call Z_checkArrayInConfig;
};

View File

@@ -1,28 +1,32 @@
private ["_player","_toPay","_moneyInfo","_totalWorth","_moneyInGear","_moneyInBackpack","_moneyInVehicle", "_success"];
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;
{
_nil = [player, _x , 1] call BIS_fnc_invRemove;
} count _moneyInGear;
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 (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] call Z_returnChange;
_success = [_toPay,_totalWorth,_justChecking,_regularMagsToBuy] call Z_returnChange;
};
_success

View File

@@ -1,11 +1,14 @@
// Made for DayZ Epoch by vbawol edited for AdvancedTrading by Zupa
private ["_return_change","_ItemTopaz","_GemTotal","_GemTotal2","_ItemObsidian","_ItemSapphire","_ItemAmethyst","_ItemEmerald","_ItemCitrine","_ItemRuby","_gem","_value","_total","_briefcase_100oz_a","_gold_10oz_a","_gold_10oz_b","_briefcase_100oz","_gold_10oz","_gold_1oz_a","_gold_1oz_b","_gold_1oz","_silver_10oz_a","_silver_10oz_b","_silver_10oz","_silver_1oz_a","_silver_1oz_b","_silver_1oz","_successful","_trade_total","_total_currency"];
private ["_return_change","_ItemTopaz","_GemTotal","_GemTotal2","_ItemObsidian","_ItemSapphire","_ItemAmethyst","_ItemEmerald","_ItemCitrine","_ItemRuby","_gem","_value","_total","_briefcase_100oz_a","_gold_10oz_a","_gold_10oz_b","_briefcase_100oz","_gold_10oz","_gold_1oz_a","_gold_1oz_b","_gold_1oz","_silver_10oz_a","_silver_10oz_b","_silver_10oz","_silver_1oz_a","_silver_1oz_b","_silver_1oz","_successful","_trade_total","_total_currency","_addRegularMag","_justChecking","_magsAdded","_regularMagsToBuy"];
_successful = false;
_trade_total = _this select 0;
_total_currency = _this select 1;
_total_currency = _this select 1;
_justChecking = _this select 2;
_regularMagsToBuy = _this select 3;
_magsAdded = 0;
Z_ChangeInBackpack = false;
Z_ChangeOverflow = false;
_return_change = 0;
if (!Z_Selling) then {
@@ -14,6 +17,48 @@ if (!Z_Selling) then {
_return_change = _total_currency + _trade_total;
};
_addRegularMag = {
private ["_backpack","_freeBagSpace","_freeSpace","_regularMags","_justChecking","_magsAdded","_item","_gearSpace","_enoughRoom","_regularMagsToBuy"];
_magsAdded = _this select 0;
_justChecking = _this select 1;
_item = _this select 2;
_regularMagsToBuy = _this select 3;
_freeBagSpace = 0;
_regularMags = {(getNumber (configFile >> "CfgMagazines" >> _x >> "type") == 256)} count (magazines player); // 256 = WeaponSlotItem (normal magazine)
_gearSpace = ((12 - (_regularMags + _regularMagsToBuy)) > 0);
if (_justChecking or !_gearSpace) then {
_backpack = unitBackpack player;
if (!isNull _backpack) then {
_freeSpace = [_backpack,0,0,0,0] call Z_calcFreeSpace;
_freeBagSpace = (_freeSpace select 4) - (_freeSpace select 0);
};
_enoughRoom = (((12 - (_regularMags + _regularMagsToBuy)) + _freeBagSpace) >= _magsAdded);
// Return change into vehicle or on ground is not advised due to potential for theft
};
if (_justChecking) exitWith {_enoughRoom};
if (_gearSpace) then {
player addMagazine _item;
} else {
if (Z_Selling) then {
// Items are removed before change is calculated in sellItems, so exiting sale if _enoughRoom=false; is not an option for now.
// Bandaid: notify player of overflow
// Overflow in backpack falls on ground. Overflow in gear does not.
player addMagazine _item;
Z_ChangeOverflow = true;
} else {
// Always enough room since we checked before buying
_backpack addMagazineCargoGlobal [_item,1];
Z_ChangeInBackpack = true;
};
};
};
if (_return_change > 0) then {
_total = _return_change;
@@ -104,74 +149,82 @@ if (_return_change > 0) then {
if (_ItemTopaz > 0) then {
for "_x" from 1 to _ItemTopaz do {
player addMagazine "ItemTopaz";
if (_justChecking) then { _magsAdded = _magsAdded + 1; } else { [0,false,"ItemTopaz",0] call _addRegularMag; };
};
};
if (_ItemObsidian > 0) then {
for "_x" from 1 to _ItemObsidian do {
player addMagazine "ItemObsidian";
if (_justChecking) then { _magsAdded = _magsAdded + 1; } else { [0,false,"ItemObsidian",0] call _addRegularMag; };
};
};
if (_ItemSapphire > 0) then {
for "_x" from 1 to _ItemSapphire do {
player addMagazine "ItemSapphire";
if (_justChecking) then { _magsAdded = _magsAdded + 1; } else { [0,false,"ItemSapphire",0] call _addRegularMag; };
};
};
if (_ItemAmethyst > 0) then {
for "_x" from 1 to _ItemAmethyst do {
player addMagazine "ItemAmethyst";
if (_justChecking) then { _magsAdded = _magsAdded + 1; } else { [0,false,"ItemAmethyst",0] call _addRegularMag; };
};
};
if (_ItemEmerald > 0) then {
for "_x" from 1 to _ItemEmerald do {
player addMagazine "ItemEmerald";
if (_justChecking) then { _magsAdded = _magsAdded + 1; } else { [0,false,"ItemEmerald",0] call _addRegularMag; };
};
};
if (_ItemCitrine > 0) then {
for "_x" from 1 to _ItemCitrine do {
player addMagazine "ItemCitrine";
if (_justChecking) then { _magsAdded = _magsAdded + 1; } else { [0,false,"ItemCitrine",0] call _addRegularMag; };
};
};
if (_ItemRuby > 0) then {
for "_x" from 1 to _ItemRuby do {
player addMagazine "ItemRuby";
if (_justChecking) then { _magsAdded = _magsAdded + 1; } else { [0,false,"ItemRuby",0] call _addRegularMag; };
};
};
if (_briefcase_100oz > 0) then {
for "_x" from 1 to _briefcase_100oz do {
player addMagazine "ItemBriefcase100oz";
if (_justChecking) then { _magsAdded = _magsAdded + 1; } else { [0,false,"ItemBriefcase100oz",0] call _addRegularMag; };
};
};
if (_gold_10oz > 0) then {
if (_gold_10oz == 1) then {
player addMagazine "ItemGoldBar10oz";
if (_justChecking) then { _magsAdded = _magsAdded + 1; } else { [0,false,"ItemGoldBar10oz",0] call _addRegularMag; };
} else {
player addMagazine format["ItemBriefcase%1oz",floor(_gold_10oz*10)];
if (_justChecking) then { _magsAdded = _magsAdded + 1; } else { [0,false,format["ItemBriefcase%1oz",floor(_gold_10oz*10)],0] call _addRegularMag; };
};
};
if (_gold_1oz > 0) then {
if (_gold_1oz == 1) then {
player addMagazine "ItemGoldBar";
if (_justChecking) then { _magsAdded = _magsAdded + 1; } else { [0,false,"ItemGoldBar",0] call _addRegularMag; };
} else {
player addMagazine format["ItemGoldBar%1oz",_gold_1oz];
if (_justChecking) then { _magsAdded = _magsAdded + 1; } else { [0,false,format["ItemGoldBar%1oz",_gold_1oz],0] call _addRegularMag; };
};
};
if (_silver_10oz > 0) then {
if (_silver_10oz == 1) then {
player addMagazine "ItemSilverBar10oz";
if (_justChecking) then { _magsAdded = _magsAdded + 1; } else { [0,false,"ItemSilverBar10oz",0] call _addRegularMag; };
} else {
player addMagazine format["ItemBriefcaseS%1oz",floor(_silver_10oz*10)];
if (_justChecking) then { _magsAdded = _magsAdded + 1; } else { [0,false,format["ItemBriefcaseS%1oz",floor(_silver_10oz*10)],0] call _addRegularMag; };
};
};
if (_silver_1oz > 0) then {
if (_silver_1oz == 1) then {
player addMagazine "ItemSilverBar";
if (_justChecking) then { _magsAdded = _magsAdded + 1; } else { [0,false,"ItemSilverBar",0] call _addRegularMag; };
} else {
player addMagazine format["ItemSilverBar%1oz",_silver_1oz];
if (_justChecking) then { _magsAdded = _magsAdded + 1; } else { [0,false,format["ItemSilverBar%1oz",_silver_1oz],0] call _addRegularMag; };
};
};
_successful = true;
if (_justChecking) then {
_successful = [_magsAdded,true,0,_regularMagsToBuy] call _addRegularMag;
} else {
_successful = true;
};
};
if (Z_ChangeInBackpack) then { systemChat localize "STR_EPOCH_TRADE_CHANGE_IN_BACKPACK"; };
if (Z_ChangeOverflow) then { systemChat localize "STR_EPOCH_TRADE_CHANGE_OVERFLOW"; };
_successful

View File

@@ -220,7 +220,7 @@ if (typeName _money == "SCALAR") then {
_success = [player,_money] call SC_fnc_addCoins;
systemChat format[localize "STR_EPOCH_TRADE_SUCCESS_CHANGE", _money , CurrencyName];
} else {
_success = [_money, 0] call Z_returnChange;
_success = [_money,0,false,0] call Z_returnChange;
_tCost = "";
_tCost = _money call z_calcDefaultCurrencyNoImg;
if (_tCost != "") then { systemChat format[localize "STR_EPOCH_TRADE_SELL_SUCCESS",_tCost]; };

View File

@@ -6,9 +6,9 @@
Author:
Zupa 2014-09-30
---------------------------------------------------------------------------- */
private ["_bags","_vehInfo","_forEachIndex","_counter","_normalBagss","_inCargo","_unit","_items","_weaps","_normalItems","_normalWeaps","_normalBags","_unit_allItems","_unit_allItems_types","_unit_allItems_count","_unit_allWeaps","_unit_allWeaps_types","_unit_allWeaps_count","_unit_allBags","_unit_allBags_types","_unit_allBags_count","_returnVar","_returnMag","_returnWeap","_returnBag"];
private ["_bags","_vehInfo","_inCargo","_object","_items","_weaps","_normalMags","_normalWeaps","_normalBags","_returnVar","_returnMag","_returnWeap","_returnBag","_freeSpace"];
_unit = _this select 0;
_object = _this select 0;
_items = _this select 1;
_weaps = _this select 2;
_bags = [];
@@ -27,68 +27,35 @@ if (count _this > 3) then {
};
};
_normalItems = [];
_normalWeaps = [];
_normalBags = [];
_freeSpace = [_object,0,0,0,0] call Z_calcFreeSpace;
_normalMags = _freeSpace select 5;
_normalWeaps = _freeSpace select 6;
_normalBags = _freeSpace select 7;
_unit_allItems = getMagazineCargo _unit; // [[type1, typeN, ...],[count1, countN, ...]]
_unit_allItems_types = _unit_allItems select 0;
_unit_allItems_count = _unit_allItems select 1;
_unit_allWeaps = getWeaponCargo _unit;
_unit_allWeaps_types = _unit_allWeaps select 0;
_unit_allWeaps_count = _unit_allWeaps select 1;
_unit_allBags = getBackpackCargo _unit;
_unit_allBags_types = _unit_allBags select 0;
_unit_allBags_count = _unit_allBags select 1;
clearMagazineCargoGlobal _unit;
clearWeaponCargoGlobal _unit;
clearMagazineCargoGlobal _object;
clearWeaponCargoGlobal _object;
if (count _bags > 0) then {
clearBackpackCargoGlobal _unit;
clearBackpackCargoGlobal _object;
};
{
_counter = 0 ;
while {_counter < (_unit_allItems_count select _forEachIndex)} do {
_normalItems set [count(_normalItems),_x];
_counter = _counter + 1;
};
} forEach _unit_allItems_types;
{
_counter = 0 ;
while {_counter < (_unit_allWeaps_count select _forEachIndex)} do {
_normalWeaps set [count(_normalWeaps),_x];
_counter = _counter + 1;
};
} forEach _unit_allWeaps_types;
{
_counter = 0 ;
while {_counter < (_unit_allBags_count select _forEachIndex)} do {
_normalBagss set [count(_normalBags),_x];
_counter = _counter + 1;
};
} forEach _unit_allBags_types;
_returnVar = [];
_returnMag = [];
_returnWeap = [];
_returnBag = [];
{
_inCargo = _normalItems find _x;
_inCargo = _normalMags find _x;
if (_inCargo > -1) then {
_normalItems set [_inCargo, "soldItem"];
_normalMags set [_inCargo, "soldItem"];
_returnMag set [count(_returnMag),1];
} else {
_returnMag set [count(_returnMag),0];
};
} count _items;
_normalItems = _normalItems - ["soldItem"];
_normalMags = _normalMags - ["soldItem"];
{
_unit addMagazineCargoGlobal [_x, 1];
} count _normalItems;
_object addMagazineCargoGlobal [_x, 1];
} count _normalMags;
{
_inCargo = _normalBags find _x;
@@ -100,7 +67,7 @@ _normalItems = _normalItems - ["soldItem"];
};
} count _bags;
{
_unit addBackpackCargoGlobal [_x, 1];
_object addBackpackCargoGlobal [_x, 1];
} count _normalBags;
{
@@ -115,12 +82,12 @@ _normalItems = _normalItems - ["soldItem"];
_normalWeaps = _normalWeaps - ["soldItem"];
{
_unit addWeaponCargoGlobal [_x, 1];
_object addWeaponCargoGlobal [_x, 1];
} count _normalWeaps;
_normalWeaps = _normalWeaps - ["soldItem"];
if (count _vehInfo > 0) then {
_sell = [_vehInfo, ((_vehInfo select 0) select 4), _unit] call DZE_deleteTradedVehicle;
_sell = [_vehInfo, ((_vehInfo select 0) select 4), _object] call DZE_deleteTradedVehicle;
if (_sell > 0) then {
_returnVar set [3,[1]];
};
@@ -130,4 +97,4 @@ _returnVar set [0,_returnMag];
_returnVar set [1,_returnWeap];
_returnVar set [2,_returnBag];
_returnVar;
_returnVar

View File

@@ -91,7 +91,8 @@ if (isNil "Z_AdvancedTradingInit") then {
Z_calcBuyableList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_calcBuyableList.sqf");
Z_fillBuyableList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_fillBuyableList.sqf");
Z_fillBuyingList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_fillBuyingList.sqf");
Z_calculateFreeSpace = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_calculateFreeSpace.sqf");
Z_calcFreeSpace = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_calcFreeSpace.sqf");
Z_displayFreeSpace = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_displayFreeSpace.sqf");
Z_checkCloseVehicle = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_checkCloseVehicle.sqf");
Z_allowBuying = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_allowBuying.sqf");
Z_canAfford = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_canAfford.sqf");

Binary file not shown.

Binary file not shown.

View File

@@ -16187,7 +16187,7 @@
<Russian>Вы можете купить в снаряжение: оружия-%1, пистолетов-%2, инструментов-%3.</Russian>
</Key>
<Key ID="STR_EPOCH_TRADE_MAGS_FULL">
<English>You can only buy %1 magazines into your gear.</English>
<English>You can only buy %1 regular magazines and %2 pistol magazines into your gear.</English>
<Russian>Вы можете купить предметов в снаряжение: %1.</Russian>
</Key>
<Key ID="STR_EPOCH_TRADE_VEHICLE_WEPS">
@@ -16270,6 +16270,9 @@
<Polish>Nie można kupić: brak wolnych miejsc!</Polish>
<Hungarian>Nem vásárolhatsz! Nincs üres hely!</Hungarian>
</Key>
<Key ID="STR_EPOCH_TRADE_GEAR_AND_BAG_FULL">
<English>Cannot buy: Not enough empty slots in your gear or bag to accept change!</English>
</Key>
<Key ID="STR_EPOCH_TRADE_NEED_COINS">
<English>You need %1 %2 to buy all these items.</English>
<Russian>Вам нужно %1 %2 для покупки.</Russian>
@@ -16299,6 +16302,12 @@
<Key ID="STR_EPOCH_TRADE_TOTAL_SPACE_SUCCEEDED">
<English>Total space succeeded: Mag=1, Tool=1, Side=5, Primary=10 slots and your bag capacity is %1 where you tried %2 slots.</English>
</Key>
<Key ID="STR_EPOCH_TRADE_CHANGE_IN_BACKPACK">
<English>Some change was added to your backpack.</English>
</Key>
<Key ID="STR_EPOCH_TRADE_CHANGE_OVERFLOW">
<English>Some change is hidden in the overflow slots of your gear.</English>
</Key>
<Key ID="STR_EPOCH_APLOTFORLIFE_TAKE_OWNERSHIP">
<English>Take Ownership: %1 objects ownership changed.</English>
</Key>