mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-13 19:52:38 +03:00
Merge branch 'master' of https://github.com/EpochModTeam/DayZ-Epoch
This commit is contained in:
@@ -2,7 +2,7 @@ private ["_selection","_return","_toBuyWeaps","_toBuyTotalMags","_toBuyBags","_t
|
||||
,"_primaryToBuy","_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"
|
||||
,"_toBuyRegularMags","_type","_freeSpace","_backpack","_totalSpace","_toolAmounts","_allowedBinocular"
|
||||
];
|
||||
_selection = Z_SellingFrom;
|
||||
_return = false;
|
||||
@@ -16,6 +16,7 @@ _sidearmToBuy = _this select 4;
|
||||
_primaryToBuy = _this select 5;
|
||||
_vehiclesToBuy = _this select 6;
|
||||
_toolClasses = _this select 7;
|
||||
_toolAmounts = _this select 8;
|
||||
_allowedMags = 0;
|
||||
_allowedWeapons = 0;
|
||||
_allowedBackpacks = 0;
|
||||
@@ -41,42 +42,50 @@ if (_selection == 2) then { //gear
|
||||
_allowedPrimary = if (!isNil "_p" && _p != "") then {0} else {1};
|
||||
if (DZE_TwoPrimaries == 2 && dayz_onBack == "") then { _allowedPrimary = _allowedPrimary + 1; };
|
||||
|
||||
// (secondaryWeapon player) returns launcher, doesn't work for pistol
|
||||
_allowedSidearm = 1;
|
||||
{
|
||||
if (getNumber (configFile >> "CfgWeapons" >> _x >> "type") == 2) exitWith { // 2 = WeaponSlotHandGun (occupies pistol slot)
|
||||
_allowedSidearm = 0;
|
||||
};
|
||||
} count (weapons player);
|
||||
|
||||
_b = unitBackpack player;
|
||||
_allowedBackpacks = if (isNull _b) then {1} else {0};
|
||||
|
||||
_allowedTools = 14; // 12 toolbelt + 1 Binocular + 1 NVG
|
||||
_allowedSidearm = 1;
|
||||
_allowedBinocular = 2;
|
||||
_duplicate = false;
|
||||
{
|
||||
_parentClasses = [(configFile >> "CfgWeapons" >> _x),true] call BIS_fnc_returnParents;
|
||||
if ('ItemCore' in _parentClasses || 'Binocular' in _parentClasses) then {
|
||||
if ("ItemCore" in _parentClasses || "Binocular" in _parentClasses) then {
|
||||
_allowedTools = _allowedTools - 1;
|
||||
if (_x in _toolClasses) then {_duplicate = true;}; // Forbid purchasing duplicate tools into gear
|
||||
}
|
||||
};
|
||||
_type = getNumber (configFile >> "CfgWeapons" >> _x >> "type");
|
||||
if (_type == 2) then { _allowedSidearm = 0; }; // 2 = WeaponSlotHandGun (occupies pistol slot) // (secondaryWeapon player) returns launcher, doesn't work for pistol
|
||||
if (_type == 4096) then { _allowedBinocular = _allowedBinocular - 1; }; // 4096 = WeaponSlotBinocular
|
||||
} count (weapons player);
|
||||
|
||||
{
|
||||
_tool = _x;
|
||||
_quantity = {(_tool == _x)} count _toolClasses;
|
||||
if (_quantity > 1) exitWith {_duplicate = true;}; // Forbid purchasing multiples of the same tool into gear
|
||||
if (_quantity > 1) exitWith {_duplicate = true;}; // Forbid buying multiples of same tool into gear. Ok to exit since duplicate will cancel buy
|
||||
if (getNumber (configFile >> "CfgWeapons" >> _x >> "type") == 4096) then {
|
||||
_allowedBinocular = _allowedBinocular - (_toolAmounts select _forEachIndex);
|
||||
};
|
||||
} forEach _toolClasses;
|
||||
|
||||
{
|
||||
if (_x > 1) exitWith {_duplicate = true;};
|
||||
} count _toolAmounts;
|
||||
|
||||
_check1 = false;
|
||||
_check2 = false;
|
||||
_check3 = false;
|
||||
_check4 = false;
|
||||
|
||||
if (_allowedPrimary >= _primaryToBuy && _allowedSidearm >= _sidearmToBuy && _allowedTools >= _toolsToBuy && !_duplicate) then {
|
||||
_check1 = true;
|
||||
} else {
|
||||
systemChat format[localize "STR_EPOCH_TRADE_GEAR_FULL", _allowedPrimary, _allowedSidearm , _allowedTools];
|
||||
if (_duplicate) then { systemChat localize "STR_EPOCH_TRADE_DUPLICATE_TOOL"; };
|
||||
if (_duplicate) then {
|
||||
systemChat localize "STR_EPOCH_TRADE_DUPLICATE_TOOL";
|
||||
} else {
|
||||
systemChat format[localize "STR_EPOCH_TRADE_GEAR_FULL", _allowedPrimary, _allowedSidearm , _allowedTools];
|
||||
};
|
||||
};
|
||||
if (_allowedPistolMags >= _toBuyPistolMags && _allowedRegularMags >= _toBuyRegularMags) then {
|
||||
_check2 = true;
|
||||
@@ -88,8 +97,12 @@ if (_selection == 2) then { //gear
|
||||
} else {
|
||||
systemChat localize "STR_EPOCH_TRADE_HAVE_BACKPACK";
|
||||
};
|
||||
|
||||
if (_check1 && _check2 && _check3) then { _return = true; };
|
||||
if (_allowedBinocular > -1) then {
|
||||
_check4 = true;
|
||||
} else {
|
||||
systemChat localize "STR_EPOCH_TRADE_BINOCULARS_FULL";
|
||||
};
|
||||
if (_check1 && _check2 && _check3 && _check4) then { _return = true; };
|
||||
};
|
||||
|
||||
if (_selection == 1) then { //vehicle
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
private ["_weaponsToBuy","_backpacksToBuy","_toolsToBuy","_sidearmToBuy","_primaryToBuy","_priceToBuy"
|
||||
,"_enoughMoney","_myMoney","_canBuy","_moneyInfo","_count","_success","_toolClasses","_itemsToLog"
|
||||
,"_tCost","_bTotal","_backpack","_pistolMagsToBuy","_regularMagsToBuy","_hasPrimary","_p"];
|
||||
,"_tCost","_bTotal","_backpack","_pistolMagsToBuy","_regularMagsToBuy","_hasPrimary","_p","_toolAmounts"];
|
||||
|
||||
if (count Z_BuyingArray < 1) exitWith { systemChat localize "STR_EPOCH_TRADE_BUY_NO_ITEMS"; };
|
||||
|
||||
@@ -13,7 +13,7 @@ _sidearmToBuy = 0;
|
||||
_primaryToBuy = 0;
|
||||
_vehiclesToBuy = 0;
|
||||
_priceToBuy = 0;
|
||||
|
||||
_toolAmounts = [];
|
||||
_toolClasses = [];
|
||||
_itemsToLog = [[],[],[],"buy"];
|
||||
|
||||
@@ -24,6 +24,7 @@ if (Z_SingleCurrency) then {
|
||||
if ('ItemCore' in _parentClasses || 'Binocular' in _parentClasses) then {
|
||||
_toolsToBuy = _toolsToBuy + (_x select 9);
|
||||
_toolClasses set [count _toolClasses,(_x select 0)];
|
||||
_toolAmounts set [count _toolAmounts,(_x select 9)];
|
||||
} else {
|
||||
_weaponsToBuy = _weaponsToBuy + (_x select 9);
|
||||
if ('PistolCore' in _parentClasses) then {
|
||||
@@ -61,6 +62,7 @@ if (Z_SingleCurrency) then {
|
||||
if ('ItemCore' in _parentClasses || 'Binocular' in _parentClasses) then {
|
||||
_toolsToBuy = _toolsToBuy + (_x select 9);
|
||||
_toolClasses set [count _toolClasses,(_x select 0)];
|
||||
_toolAmounts set [count _toolAmounts,(_x select 9)];
|
||||
} else {
|
||||
_weaponsToBuy = _weaponsToBuy + (_x select 9);
|
||||
if ('PistolCore' in _parentClasses) then {
|
||||
@@ -93,7 +95,7 @@ if (Z_SingleCurrency) then {
|
||||
} count Z_BuyingArray;
|
||||
};
|
||||
|
||||
_canBuy = [_weaponsToBuy,[_pistolMagsToBuy,_regularMagsToBuy],_backpacksToBuy,_toolsToBuy,_sidearmToBuy,_primaryToBuy,_vehiclesToBuy,_toolClasses] call Z_allowBuying;
|
||||
_canBuy = [_weaponsToBuy,[_pistolMagsToBuy,_regularMagsToBuy],_backpacksToBuy,_toolsToBuy,_sidearmToBuy,_primaryToBuy,_vehiclesToBuy,_toolClasses,_toolAmounts] call Z_allowBuying;
|
||||
if (!_canBuy) exitWith {}; // Keep systemChat reasons for failure in Z_allowBuying for sanity
|
||||
|
||||
_myMoney = player getVariable[Z_MoneyVariable,0];
|
||||
|
||||
@@ -16265,6 +16265,9 @@
|
||||
<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_BINOCULARS_FULL">
|
||||
<English>Cannot buy: Not enough empty binocular slots in your gear!</English>
|
||||
</Key>
|
||||
<Key ID="STR_EPOCH_TRADE_NEED_COINS">
|
||||
<English>You need %1 %2 to buy all these items.</English>
|
||||
<Russian>Вам нужно %1 %2 для покупки.</Russian>
|
||||
|
||||
Reference in New Issue
Block a user