mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-13 19:52:38 +03:00
Add buying to and selling from dayz_onBack
Also: - Fixed typo Z_fill(e)TradeTitle - Fixed "not enough slots to accept change" message shows when "not enough money" should show instead
This commit is contained in:
@@ -39,6 +39,7 @@ if (_selection == 2) then { //gear
|
||||
|
||||
_p = primaryWeapon player;
|
||||
_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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
private ["_weaponsToBuy","_backpacksToBuy","_toolsToBuy","_sidearmToBuy","_primaryToBuy","_priceToBuy"
|
||||
,"_enoughMoney","_myMoney","_canBuy","_moneyInfo","_count","_success","_toolClasses","_itemsToLog"
|
||||
,"_tCost","_bTotal","_backpack","_pistolMagsToBuy","_regularMagsToBuy"];
|
||||
,"_tCost","_bTotal","_backpack","_pistolMagsToBuy","_regularMagsToBuy","_hasPrimary","_p"];
|
||||
|
||||
if (count Z_BuyingArray < 1) exitWith { systemChat localize "STR_EPOCH_TRADE_BUY_NO_ITEMS"; };
|
||||
|
||||
@@ -29,7 +29,7 @@ if (Z_SingleCurrency) then {
|
||||
if ('PistolCore' in _parentClasses) then {
|
||||
_sidearmToBuy = _sidearmToBuy + (_x select 9);
|
||||
} else {
|
||||
_primaryToBuy = _primaryToBuy + (_x select 9); // _ammount
|
||||
_primaryToBuy = _primaryToBuy + (_x select 9); // _amount
|
||||
};
|
||||
};
|
||||
_priceToBuy = _priceToBuy + ((_x select 9)*(_x select 2));
|
||||
@@ -115,7 +115,7 @@ if (Z_SingleCurrency) then {
|
||||
|
||||
// Pre-check if player has enough room to accept change
|
||||
_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 (!_success && _enoughMoney) exitWith { systemChat localize "STR_EPOCH_TRADE_GEAR_AND_BAG_FULL"; }; // Not enough room in gear or bag to accept change
|
||||
|
||||
if (_enoughMoney) then {
|
||||
_bTotal = 0;
|
||||
@@ -205,8 +205,14 @@ if (_enoughMoney) then {
|
||||
{
|
||||
if (_x select 1 == "trade_weapons") then {
|
||||
_count = 0;
|
||||
while { _count < (_x select 9)} do {
|
||||
player addWeapon (_x select 0);
|
||||
while {_count < (_x select 9)} do {
|
||||
_p = primaryWeapon player;
|
||||
_hasPrimary = if (!isNil "_p" && _p != "") then {true} else {false};
|
||||
if (_hasPrimary && getNumber (configFile >> "CfgWeapons" >> (_x select 0) >> "type") == 1) then {
|
||||
dayz_onBack = _x select 0; //Add to back
|
||||
} else {
|
||||
player addWeapon (_x select 0);
|
||||
};
|
||||
_count = _count + 1;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -17,9 +17,9 @@ if (!isNull _vehicle) then {
|
||||
if (_this) then { // Set trade title, don't set on menu start up since gear is selected initially.
|
||||
systemChat format[localize "STR_EPOCH_TRADE_SELECTED",typeOf Z_vehicle];
|
||||
if (Z_Selling) then {
|
||||
[format[localize "STR_EPOCH_TRADE_SELLING_FROM", typeOf Z_vehicle]] call Z_filleTradeTitle;
|
||||
[format[localize "STR_EPOCH_TRADE_SELLING_FROM", typeOf Z_vehicle]] call Z_fillTradeTitle;
|
||||
} else {
|
||||
[format[localize "STR_EPOCH_TRADE_BUYING_IN", typeOf Z_vehicle]] call Z_filleTradeTitle;
|
||||
[format[localize "STR_EPOCH_TRADE_BUYING_IN", typeOf Z_vehicle]] call Z_fillTradeTitle;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -13,6 +13,7 @@ if (_selection == 2) then { //gear
|
||||
|
||||
_p = primaryWeapon player;
|
||||
_allowedPrimary = if (!isNil "_p" && _p != "") then {0} else {1};
|
||||
if (DZE_TwoPrimaries == 2 && dayz_onBack == "") then { _allowedPrimary = _allowedPrimary + 1; };
|
||||
|
||||
_allowedSidearm = 1;
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* [_text] call Z_filleTradeTitle
|
||||
* [_text] call Z_fillTradeTitle
|
||||
*
|
||||
* @param String _this select 0 (_text) -> The text you want in the label.
|
||||
*
|
||||
@@ -25,7 +25,7 @@ if (Z_Selling) then {
|
||||
switch (_lbIndex) do {
|
||||
case 0: { //backpack
|
||||
if (!isNull _backpack) then {
|
||||
[localize "STR_EPOCH_TRADE_SELLING_BACKPACK"] call Z_filleTradeTitle;
|
||||
[localize "STR_EPOCH_TRADE_SELLING_BACKPACK"] call Z_fillTradeTitle;
|
||||
Z_SellingFrom = 0;
|
||||
call Z_getBackpackItems;
|
||||
} else {
|
||||
@@ -36,7 +36,7 @@ if (Z_Selling) then {
|
||||
case 1: { //vehicle
|
||||
_canBuyInVehicle = true call Z_checkCloseVehicle;
|
||||
if (_canBuyInVehicle) then {
|
||||
[localize "STR_EPOCH_TRADE_SELLING_VEHICLE"] call Z_filleTradeTitle;
|
||||
[localize "STR_EPOCH_TRADE_SELLING_VEHICLE"] call Z_fillTradeTitle;
|
||||
Z_SellingFrom = 1;
|
||||
call Z_getVehicleItems;
|
||||
} else {
|
||||
@@ -45,7 +45,7 @@ if (Z_Selling) then {
|
||||
};
|
||||
};
|
||||
case 2: { //gear
|
||||
[localize "STR_EPOCH_TRADE_SELLING_GEAR"] call Z_filleTradeTitle;
|
||||
[localize "STR_EPOCH_TRADE_SELLING_GEAR"] call Z_fillTradeTitle;
|
||||
Z_SellingFrom = 2;
|
||||
call Z_getGearItems;
|
||||
};
|
||||
@@ -57,7 +57,7 @@ if (Z_Selling) then {
|
||||
case 0: { //backpack
|
||||
if (!isNull _backpack) then {
|
||||
Z_SellingFrom = 0;
|
||||
[localize "STR_EPOCH_TRADE_BUYING_BACKPACK"] call Z_filleTradeTitle;
|
||||
[localize "STR_EPOCH_TRADE_BUYING_BACKPACK"] call Z_fillTradeTitle;
|
||||
[0] call Z_displayFreeSpace;
|
||||
} else {
|
||||
ctrlSetText [Z_AT_TRADERLINE1, localize "STR_EPOCH_TRADE_NO_BACKPACK"];
|
||||
@@ -68,7 +68,7 @@ if (Z_Selling) then {
|
||||
_canBuyInVehicle = true call Z_checkCloseVehicle;
|
||||
if (_canBuyInVehicle) then {
|
||||
Z_SellingFrom = 1;
|
||||
[localize "STR_EPOCH_TRADE_BUYING_VEHICLE"] call Z_filleTradeTitle;
|
||||
[localize "STR_EPOCH_TRADE_BUYING_VEHICLE"] call Z_fillTradeTitle;
|
||||
[1] call Z_displayFreeSpace;
|
||||
} else {
|
||||
ctrlSetText [Z_AT_TRADERLINE1, localize "STR_EPOCH_PLAYER_245"];
|
||||
@@ -77,7 +77,7 @@ if (Z_Selling) then {
|
||||
};
|
||||
case 2: { //gear
|
||||
Z_SellingFrom = 2;
|
||||
[localize "STR_EPOCH_TRADE_BUYING_GEAR"] call Z_filleTradeTitle;
|
||||
[localize "STR_EPOCH_TRADE_BUYING_GEAR"] call Z_fillTradeTitle;
|
||||
[2] call Z_displayFreeSpace;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -11,6 +11,7 @@ Z_SellArray = [];
|
||||
Z_SellableArray = [];
|
||||
_mags = magazines player;
|
||||
_weaps = weapons player;
|
||||
_weaps set [count _weaps,dayz_onBack];
|
||||
_bag = unitBackpack player;
|
||||
_bags = if (isNull _bag) then {[]} else {[typeOf _bag]};
|
||||
|
||||
|
||||
@@ -107,11 +107,11 @@ _tSold = _itemsArray + _weaponsArray + _bpArray + _vehArray;
|
||||
|
||||
if (Z_SellingFrom == 0) then {
|
||||
_outcome = [unitBackpack player,_itemsArray,_weaponsArray, _vehArray] call ZUPA_fnc_removeWeaponsAndMagazinesCargo;
|
||||
systemchat format[localize "STR_EPOCH_TRADE_SELL_IN_BACKPACK",count _tSold];
|
||||
systemChat format[localize "STR_EPOCH_TRADE_SELL_IN_BACKPACK",count _tSold];
|
||||
};
|
||||
if (Z_SellingFrom == 1) then {
|
||||
_outcome = [Z_vehicle,_itemsArray,_weaponsArray,_vehArray] call ZUPA_fnc_removeWeaponsAndMagazinesCargo;
|
||||
systemchat format[localize "STR_EPOCH_TRADE_SELL_IN_VEHICLE",count _tSold,typeOf Z_vehicle];
|
||||
systemChat format[localize "STR_EPOCH_TRADE_SELL_IN_VEHICLE",count _tSold,typeOf Z_vehicle];
|
||||
};
|
||||
|
||||
_itemsToLog set [0,(_itemsArray + _weaponsArray + _bpArray + [typeOf Z_vehicle])];
|
||||
@@ -140,7 +140,12 @@ if (Z_SellingFrom == 2) then {
|
||||
_type = _x select 1;
|
||||
if (_type == "trade_items") then {_name = configFile >> "CfgMagazines" >> _name;};
|
||||
if (_type == "trade_weapons") then {_name = configFile >> "CfgWeapons" >> _name;};
|
||||
_localResult = [player,_name,1] call BIS_fnc_invRemove; // Use config for BIS_fnc_invRemove
|
||||
if (_x select 0 == dayz_onBack) then {
|
||||
dayz_onBack = ""; // Remove from back
|
||||
_localResult = 1;
|
||||
} else {
|
||||
_localResult = [player,_name,1] call BIS_fnc_invRemove; // Use config for BIS_fnc_invRemove
|
||||
};
|
||||
if (_localResult != 1) then {
|
||||
if (_x select 1 == "trade_items") then {
|
||||
_mA set [count(_mA),0];
|
||||
@@ -168,7 +173,7 @@ if (Z_SellingFrom == 2) then {
|
||||
if (_bagTraded) then {
|
||||
_outcome set [2,[1]];
|
||||
};
|
||||
systemchat format[localize "STR_EPOCH_TRADE_SELL_IN_GEAR",count _tSold];
|
||||
systemChat format[localize "STR_EPOCH_TRADE_SELL_IN_GEAR",count _tSold];
|
||||
};
|
||||
|
||||
{_itemsToLog set [1, (_itemsToLog select 1) + _x]} forEach _outcome;
|
||||
|
||||
@@ -55,7 +55,7 @@ if (isNil "Z_AdvancedTradingInit") then {
|
||||
|
||||
ZUPA_fnc_removeWeaponsAndMagazinesCargo = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\zupa_fnc_removeWeaponsAndMagazinesCargo.sqf");
|
||||
|
||||
Z_filleTradeTitle = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_filleTradeTitle.sqf");
|
||||
Z_fillTradeTitle = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_fillTradeTitle.sqf");
|
||||
Z_clearLists = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_clearLists.sqf");
|
||||
Z_clearSellableList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_clearSellableList.sqf");
|
||||
Z_clearBuyList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_clearBuyList.sqf");
|
||||
|
||||
Reference in New Issue
Block a user