diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_allowBuying.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_allowBuying.sqf index 0497848a1..a29b6d265 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_allowBuying.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_allowBuying.sqf @@ -2,7 +2,7 @@ private ["_selection","_return","_toBuyWeaps","_toBuyMags","_toBuyBags","_toolsT ,"_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","_ammmounts","_ammmounts2","_ammmounts3", -"_actualMags","_toolClasses","_duplicate","_quantity","_tool" +"_actualMags","_toolClasses","_duplicate","_quantity","_tool","_totalBagSlots" ]; _selection = Z_SellingFrom; _return = false; @@ -205,7 +205,8 @@ if(_selection == 0) then{ //backpack }forEach _kinds2; _allowedWeapons = getNumber (configFile >> 'CfgVehicles' >> (typeOf _backpack) >> 'transportMaxWeapons') - count(_normalWeaps); - _allowedMags = getNumber (configFile >> 'CfgVehicles' >> (typeOf _backpack) >> 'transportMaxMagazines') - count(_normalMags); + _totalBagSlots = getNumber (configFile >> 'CfgVehicles' >> (typeOf _backpack) >> 'transportMaxMagazines'); + _allowedMags = _totalBagSlots - count(_normalMags); @@ -234,7 +235,7 @@ if(_selection == 0) then{ //backpack _totalSpace = _alreadyInBackpack + _totalNewSpace; }else { - systemChat format[localize "STR_EPOCH_TRADE_NEED_BAG", _allowedMags]; + systemChat localize "STR_EPOCH_TRADE_NEED_BAG"; }; _check1 = false; @@ -258,10 +259,10 @@ if(_selection == 0) then{ //backpack systemChat format[localize "STR_EPOCH_TRADE_BAG_BAGS", _allowedBackpacks ]; }; - if( _totalSpace <= _allowedMags)then{ + if( _totalSpace <= _totalBagSlots)then{ _check4 = true; }else{ - systemChat format["Total space succeeded: Mag=1, Tool=1, Side=5, Primary=10 slots and your bag capacity is %1 where you tried %2 slots.", _allowedMags, _totalNewSpace]; + systemChat localize "STR_EPOCH_TRADE_BACKPACK_FULL"; }; if(_check0 && _check1 && _check2 && _check3 && _check4)then{ diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calculateFreeSpace.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calculateFreeSpace.sqf index a1abb714f..e7b96a039 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calculateFreeSpace.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calculateFreeSpace.sqf @@ -1,5 +1,6 @@ private["_selection","_returnArray","_allowedMags","_allowedWeapons","_allowedBackpacks","_allowedTools","_allowedPrimary","_allowedSidearm","_formattedText","_pic" -,"_backpack","_vehicleWeapons","_vehicleMagazines","_vehicleBackpacks","_tempWeaponsArray","_tempBackpackArray","_tempMagazinesArray","_actualMags"]; +,"_backpack","_vehicleWeapons","_vehicleMagazines","_vehicleBackpacks","_tempWeaponsArray","_tempBackpackArray","_tempMagazinesArray","_actualMags" +,"_normalMags","_normalWeaps","_kinds","_kinds2","_amounts","_amounts2","_counter"]; #include "defines.sqf"; _selection = _this select 0; @@ -69,13 +70,11 @@ if(_selection == 1) then{ //vehicle _returnArray = [_allowedMags - _vehicleMagazines, _allowedWeapons - _vehicleWeapons, _allowedBackpacks - _vehicleBackpacks]; }; if(_selection == 0) then{ //backpack - _allowedWeapons = 0; - _allowedMags = 0; _allowedBackpacks = 0; - _vehicleMagazines = 0; - _vehicleWeapons = 0; + _totalBagSlots = 0; + _alreadyInBackpack = 0; _backpack = unitBackpack player; - if (!isNil "_backpack") then { + if (!isNull _backpack) then { _pic = getText (configFile >> 'CfgVehicles' >> (typeOf _backpack) >> 'picture'); _formattedText = format [ @@ -84,23 +83,51 @@ if(_selection == 0) then{ //backpack ]; (findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_CONTAINERINFO) ctrlSetStructuredText parseText _formattedText; - _tempMagazinesArray = getMagazineCargo Z_vehicle; + + _tempMagazinesArray = getMagazineCargo _backpack; + _tempWeaponsArray = getWeaponCargo _backpack; + _normalMags = []; + _normalWeaps = []; + _kinds = _tempMagazinesArray select 0; + _amounts = _tempMagazinesArray select 1; { - _vehicleMagazines = _vehicleMagazines + _x; - }count ( _tempMagazinesArray select 1); - - - _tempWeaponsArray = getWeaponCargo Z_vehicle; + _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; { - _vehicleWeapons = _vehicleWeapons + _x; - }count ( _tempWeaponsArray 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'); - _allowedMags = getNumber (configFile >> 'CfgVehicles' >> (typeOf _backpack) >> 'transportMaxMagazines'); - _allowedBackpacks = 0; + _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 = [_allowedMags - _vehicleMagazines ,_allowedWeapons - _vehicleWeapons, _allowedBackpacks]; + _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]; diff --git a/SQF/dayz_code/stringtable.xml b/SQF/dayz_code/stringtable.xml index e85286edf..08c17f5aa 100644 --- a/SQF/dayz_code/stringtable.xml +++ b/SQF/dayz_code/stringtable.xml @@ -15733,6 +15733,9 @@ You need a backpack. Вам нужен рюкзак. + + Total backpack space exceeded. + Only %1 weapons fit in the backpack. В рюкзак поместится оружия: %1.