From 1c7e96a0ffbe62af1229077786bce1770e9b4e25 Mon Sep 17 00:00:00 2001 From: oiad Date: Sat, 29 Oct 2016 12:29:04 +1300 Subject: [PATCH] Advanced trading modifications, maintain_area modifications (#1780) * Advanced trading modifications, maintain_area modifications This lot of changes brings forth the following: Sets up a "default" set of compiles that are the minimum needed for maintain_area.sqf and custom scripts to utilize the gem based currency that @icomrade added. maintain_area.sqf: This will now utilize the gem based currency system. Removed the redundant Z_Vehicle and replaced it with the Epoch built in DZE_myVehicle z_at_buyItems: Code tidying and optimization z_at_checkCloseVehicle: Tidied up the code since removing Z_Vehicle allowed us to remove some now useless code. z_at_getVehicleItems: Removed the nearestObjects check for your vehicle since we now do z_checkCloseVehicle on Advanced trading start up. * Advanced trading missed redundant variables As per description * Advanced trading rework We don't need to check for close vehicle anymore now for backpack money since we've made z_vehicle redundant. * Revert "Advanced trading rework" This reverts commit a589bd19b9e0193ccdb4fae0818ca5b05d4a3467. * Advanced trading rework We don't need to check for close vehicle anymore now for backpack money since we've made z_vehicle redundant. * Advanced trading rework More rework * Remove single currency add/remove coins functions at request of @ebaydayz. --- .../actions/AdvancedTrading/defaultInit.sqf | 35 +++++ .../functions/DZE_deleteTradedVehicle.sqf | 2 +- .../functions/SC_fnc_addCoins.sqf | 15 -- .../functions/SC_fnc_removeCoins.sqf | 23 --- .../functions/z_at_allowBuying.sqf | 4 +- .../functions/z_at_buyItems.sqf | 57 ++++---- .../functions/z_at_canAfford.sqf | 4 +- .../functions/z_at_checkArrayInConfig.sqf | 10 +- .../functions/z_at_checkCloseVehicle.sqf | 20 +-- .../functions/z_at_displayFreeSpace.sqf | 6 +- .../functions/z_at_fillBuyableList.sqf | 2 +- .../functions/z_at_getVehicleItems.sqf | 20 +-- .../functions/z_at_payDefault.sqf | 4 +- .../functions/z_at_sellItems.sqf | 38 ++--- .../actions/AdvancedTrading/init.sqf | 110 +++++--------- .../actions/plotManagement/maintain_area.sqf | 137 +++++++++--------- SQF/dayz_code/init/compiles.sqf | 5 +- SQF/dayz_code/stringtable.xml | 6 +- 18 files changed, 226 insertions(+), 272 deletions(-) create mode 100644 SQF/dayz_code/actions/AdvancedTrading/defaultInit.sqf delete mode 100644 SQF/dayz_code/actions/AdvancedTrading/functions/SC_fnc_addCoins.sqf delete mode 100644 SQF/dayz_code/actions/AdvancedTrading/functions/SC_fnc_removeCoins.sqf diff --git a/SQF/dayz_code/actions/AdvancedTrading/defaultInit.sqf b/SQF/dayz_code/actions/AdvancedTrading/defaultInit.sqf new file mode 100644 index 000000000..042e2b286 --- /dev/null +++ b/SQF/dayz_code/actions/AdvancedTrading/defaultInit.sqf @@ -0,0 +1,35 @@ +private ["_tempGemList","_tempWorthList","_largest","_LargestGem"]; + +Z_SellingFrom = 2; +DZE_GemList = []; +DZE_GemWorthList = []; + +_tempGemList = []; +_tempWorthList = []; + +{ + _tempGemList set [(count _tempGemList), (_x select 0)]; + _tempWorthList set [(count _tempWorthList), (_x select 1)]; +} count DZE_GemWorthArray; + +for "_i" from 0 to ((count _tempGemList) - 1) do { + _largest = -1e9; + + { + _largest = _largest max _x; + } forEach _tempWorthList; + + _LargestGem = _tempGemList select (_tempWorthList find _largest); + _tempWorthList = _tempWorthList - [_largest]; + _tempGemList = _tempGemList - [_LargestGem]; + DZE_GemList set [(count DZE_GemList), _LargestGem]; + DZE_GemWorthList set [(count DZE_GemWorthList), _largest]; +}; + +Z_checkCloseVehicle = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_checkCloseVehicle.sqf"); +Z_canAfford = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_canAfford.sqf"); +Z_calcFreeSpace = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_calcFreeSpace.sqf"); +Z_returnChange = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_returnChange.sqf"); +Z_payDefault = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_payDefault.sqf"); +z_calcDefaultCurrencyNoImg = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_calcDefaultCurrencyNoImg.sqf"); +ZUPA_fnc_removeWeaponsAndMagazinesCargo = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\zupa_fnc_removeWeaponsAndMagazinesCargo.sqf"); diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/DZE_deleteTradedVehicle.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/DZE_deleteTradedVehicle.sqf index d2ced9bf2..4494c182f 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/DZE_deleteTradedVehicle.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/DZE_deleteTradedVehicle.sqf @@ -38,7 +38,7 @@ if ((count _VehKey2) > 0) then { }; }; }; - _vehicle = Z_vehicle; + _vehicle = DZE_myVehicle; if (count _this > 2 && {isNull _vehicle}) then { _vehicle = _this select 2; }; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/SC_fnc_addCoins.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/SC_fnc_addCoins.sqf deleted file mode 100644 index e25281fe9..000000000 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/SC_fnc_addCoins.sqf +++ /dev/null @@ -1,15 +0,0 @@ -private ["_player","_amount","_wealth","_newwealth", "_result"]; - -_player = _this select 0; -_amount = _this select 1; -_result = false; -_wealth = _player getVariable[Z_MoneyVariable,0]; -_player setVariable[Z_MoneyVariable,_wealth + _amount, true]; -// can't use (magazines _player), server_playerSync expects nested array with ammo counts from player_countMagazines -// also fourth parameter in PVDZ_plr_Save is now used for achievements -if (_player == player) then {call player_forceSave;}; -_player setVariable ["moneychanged",1,true]; -_newwealth = _player getVariable[Z_MoneyVariable,0]; -if (_newwealth >= _wealth) then { _result = true; }; - -_result diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/SC_fnc_removeCoins.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/SC_fnc_removeCoins.sqf deleted file mode 100644 index a92bb1643..000000000 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/SC_fnc_removeCoins.sqf +++ /dev/null @@ -1,23 +0,0 @@ -private ["_player","_amount","_wealth","_newwealth", "_result"]; - -_player = _this select 0; -_amount = _this select 1; -_result = false; -_wealth = _player getVariable[Z_MoneyVariable,0]; -if (_amount > 0) then { - if (_wealth < _amount) then { - _result = false; - } else { - _newwealth = _wealth - _amount; - _player setVariable[Z_MoneyVariable,_newwealth, true]; - _player setVariable ["moneychanged",1,true]; - _result = true; - // can't use (magazines _player), server_playerSync expects nested array with ammo counts from player_countMagazines - // also fourth parameter in PVDZ_plr_Save is now used for achievements - if (_player == player) then { call player_forceSave; }; - }; -} else { - _result = true; -}; - -_result 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 ed94ed523..d47deb22b 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_allowBuying.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_allowBuying.sqf @@ -105,8 +105,8 @@ if (_selection == 2) then { //gear }; if (_selection == 1) then { //vehicle - if (!isNull Z_vehicle) then { - _freeSpace = [Z_vehicle,0,0,0,0] call Z_calcFreeSpace; + if (!isNull DZE_myVehicle) then { + _freeSpace = [DZE_myVehicle,0,0,0,0] call Z_calcFreeSpace; _allowedMags = _freeSpace select 1; _allowedWeapons = _freeSpace select 2; _allowedBackpacks = _freeSpace select 3; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_buyItems.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_buyItems.sqf index d2a9e0e95..13930f87a 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_buyItems.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_buyItems.sqf @@ -1,4 +1,4 @@ -private ["_activatingPlayer","_bTotal","_backpack","_backpacksToBuy","_buyVehicle","_buyingType","_canBuy","_count","_dir","_enoughMoney","_hasPrimary","_helipad","_isKeyOK","_item2Add","_itemsToLog","_keyColor","_keyNumber","_keySelected","_location","_moneyInfo","_myMoney","_parentClasses","_part_out","_pistolMagsToBuy","_priceToBuy","_primaryToBuy","_regularMagsToBuy","_sidearmToBuy","_sign","_success","_tCost","_toolAmounts","_toolClasses","_toolsToBuy","_vehiclesToBuy","_weaponsToBuy"]; +private ["_activatingPlayer","_bTotal","_backpack","_backpacksToBuy","_buyVehicle","_buyingType","_canBuy","_count","_dir","_enoughMoney","_hasPrimary","_helipad","_isKeyOK","_item2Add","_itemsToLog","_keyColor","_keyNumber","_keySelected","_location","_moneyInfo","_wealth","_parentClasses","_part_out","_pistolMagsToBuy","_priceToBuy","_primaryToBuy","_regularMagsToBuy","_sidearmToBuy","_sign","_success","_tCost","_toolAmounts","_toolClasses","_toolsToBuy","_vehiclesToBuy","_weaponsToBuy"]; if (count Z_BuyingArray < 1) exitWith { systemChat localize "STR_EPOCH_TRADE_BUY_NO_ITEMS"; }; @@ -42,11 +42,11 @@ if (Z_SingleCurrency) then { _priceToBuy = _priceToBuy + ((_x select 9)*(_x select 2)); }; if (_x select 1 == "trade_backpacks") then { - _backpacksToBuy = _backpacksToBuy + (_x select 9) ; + _backpacksToBuy = _backpacksToBuy + (_x select 9); _priceToBuy = _priceToBuy + ((_x select 9)*(_x select 2)); }; if ((_x select 1) in DZE_tradeVehicle) then { - _vehiclesToBuy = _vehiclesToBuy + (_x select 9) ; + _vehiclesToBuy = _vehiclesToBuy + (_x select 9); _priceToBuy = _priceToBuy + ((_x select 9)*(_x select 2)); }; _itemsToLog set [0, (_itemsToLog select 0) + [_x select 0]]; @@ -80,11 +80,11 @@ if (Z_SingleCurrency) then { _priceToBuy = _priceToBuy + ((_x select 11) *(_x select 2)*(_x select 9)); }; if (_x select 1 == "trade_backpacks") then { - _backpacksToBuy = _backpacksToBuy + (_x select 9) ; + _backpacksToBuy = _backpacksToBuy + (_x select 9); _priceToBuy = _priceToBuy + ((_x select 11)*(_x select 2)*(_x select 9)); }; if ((_x select 1) in DZE_tradeVehicle) then { - _vehiclesToBuy = _vehiclesToBuy + (_x select 9) ; + _vehiclesToBuy = _vehiclesToBuy + (_x select 9); _priceToBuy = _priceToBuy + ((_x select 11)*(_x select 2)*(_x select 9)); }; _itemsToLog set [0, (_itemsToLog select 0) + [_x select 0]]; @@ -96,18 +96,14 @@ if (Z_SingleCurrency) then { _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]; +_wealth = player getVariable[Z_MoneyVariable,0]; _enoughMoney = false; _moneyInfo = [false, [], [], [], 0]; if (Z_SingleCurrency) then { - if (_myMoney >= _priceToBuy) then { - _enoughMoney = true; - } else { - _enoughMoney = false; - }; + _enoughMoney = if (_wealth >= _priceToBuy) then { true } else { false }; } else { _moneyInfo = _priceToBuy call Z_canAfford; _enoughMoney = _moneyInfo select 0; @@ -157,7 +153,6 @@ if (_enoughMoney) then { publicVariableServer "PVDZE_veh_Publish2"; _keySelected; }; - //systemChat localize "STR_EPOCH_PLAYER_105"; // "Stand still to complete trade". Medic animation loop no longer used. closeDialog 2; _item2Add = "0"; @@ -189,26 +184,26 @@ if (_enoughMoney) then { if (Z_SellingFrom == 1) then { //vehicle { if (_x select 1 == "trade_weapons") then { - Z_vehicle addWeaponCargoGlobal [_x select 0, _x select 9]; + DZE_myVehicle addWeaponCargoGlobal [_x select 0, _x select 9]; }; if (_x select 1 == "trade_items") then { - Z_vehicle addMagazineCargoGlobal [_x select 0, _x select 9]; + DZE_myVehicle addMagazineCargoGlobal [_x select 0, _x select 9]; }; if (_x select 1 == "trade_backpacks") then { - Z_vehicle addBackpackCargoGlobal [_x select 0, _x select 9]; + DZE_myVehicle addBackpackCargoGlobal [_x select 0, _x select 9]; }; if ((_x select 1) in DZE_tradeVehicle) then { _item2Add = [(_x select 0), (_x select 1)] call _buyVehicle; if (_item2Add != "0") then { - Z_vehicle addWeaponCargoGlobal [_item2Add, 1]; + DZE_myVehicle addWeaponCargoGlobal [_item2Add, 1]; }; }; _bTotal = _bTotal + (_x select 9); } count Z_BuyingArray; if (_item2Add != "0") then { - systemChat format[localize "STR_EPOCH_TRADE_BUY_VEH_IN_VEHICLE",(Z_BuyingArray select 0) select 3,typeOf (Z_vehicle)]; + systemChat format[localize "STR_EPOCH_TRADE_BUY_VEH_IN_VEHICLE",(Z_BuyingArray select 0) select 3,typeOf (DZE_myVehicle)]; } else { - systemChat format[localize "STR_EPOCH_TRADE_BUY_IN_VEHICLE",_bTotal,typeOf Z_vehicle]; + systemChat format[localize "STR_EPOCH_TRADE_BUY_IN_VEHICLE",_bTotal,typeOf DZE_myVehicle]; }; }; @@ -217,7 +212,7 @@ if (_enoughMoney) then { if (_x select 1 == "trade_weapons") then { _count = 0; while {_count < (_x select 9)} do { - _hasPrimary = if (primaryWeapon player != "") then {true} else {false}; + _hasPrimary = if (primaryWeapon player != "") then {true} else {false}; if (_hasPrimary && getNumber (configFile >> "CfgWeapons" >> (_x select 0) >> "type") == 1) then { dayz_onBack = _x select 0; //Add to back } else { @@ -250,29 +245,29 @@ if (_enoughMoney) then { systemChat format[localize "STR_EPOCH_TRADE_BUY_IN_GEAR",_bTotal]; }; }; - if (!Z_SingleCurrency) then { - _success = [player,_priceToBuy,_moneyInfo,false,0] call Z_payDefault; - if (_success) then { + + _success = if (Z_SingleCurrency) then {_priceToBuy <= _wealth} else {[player,_priceToBuy,_moneyInfo,false,0] call Z_payDefault}; + + if (_success) then { + if (Z_SingleCurrency) then { + player setVariable[Z_MoneyVariable,(_wealth - _priceToBuy),true]; + systemChat format[localize "STR_EPOCH_TRADE_SUCCESS_COINS",[_priceToBuy] call BIS_fnc_numberText,CurrencyName]; + } else { _tCost = ""; _tCost = _priceToBuy call z_calcDefaultCurrencyNoImg; if (_tCost != "") then { systemChat format[localize "STR_EPOCH_TRADE_BUY_SUCCESS",_tCost]; }; - } else { - systemChat localize "STR_EPOCH_TRADE_DEBUG"; }; } else { - _success = [player,_priceToBuy] call SC_fnc_removeCoins; - if (_success) then { - systemChat format[localize "STR_EPOCH_TRADE_SUCCESS_COINS",[_priceToBuy] call BIS_fnc_numberText,CurrencyName]; - } else { - systemChat localize "STR_EPOCH_TRADE_DEBUG"; - }; + systemChat localize "STR_EPOCH_TRADE_DEBUG"; }; + _itemsToLog call Z_logTrade; call player_forceSave; if (Z_SellingFrom == 1) then { - PVDZ_veh_Save = [Z_vehicle,"gear"]; + PVDZ_veh_Save = [DZE_myVehicle,"gear"]; publicVariableServer "PVDZ_veh_Save"; }; + } else { if (Z_SingleCurrency) then { systemChat format[localize "STR_EPOCH_TRADE_NEED_COINS",[_priceToBuy] call BIS_fnc_numberText,CurrencyName]; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_canAfford.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_canAfford.sqf index 5ce6f16a1..0b70c0d7d 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_canAfford.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_canAfford.sqf @@ -58,8 +58,8 @@ if (Z_AllowTakingMoneyFromBackpack) then { }; if (Z_AllowTakingMoneyFromVehicle) then { - if (!isNull Z_vehicle) then { - _mags = getMagazineCargo Z_vehicle; + if (!isNull DZE_myVehicle) then { + _mags = getMagazineCargo DZE_myVehicle; _vehicleMoney = []; _kinds = _mags select 0; _amounts = _mags select 1; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_checkArrayInConfig.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_checkArrayInConfig.sqf index 07a96ddc3..d0986015b 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_checkArrayInConfig.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_checkArrayInConfig.sqf @@ -19,8 +19,8 @@ _vehTrade = false; _vehUpgraded = ""; if (false call Z_checkCloseVehicle) then { - _vehUpgraded = getText (configFile >> 'CfgVehicles' >> typeOf (Z_vehicle) >> 'original'); - _all = _weaps + _mags + _bags + [(typeOf Z_vehicle)]; + _vehUpgraded = getText (configFile >> 'CfgVehicles' >> typeOf (DZE_myVehicle) >> 'original'); + _all = _weaps + _mags + _bags + [(typeOf DZE_myVehicle)]; _vehTrade = true; } else { _all = _weaps + _mags + _bags; @@ -56,7 +56,7 @@ _totalPrice = 0; if (isNumber (missionConfigFile >> "CfgTraderCategory" >> _cat >> "duplicate")) then { _cat = format["Category_%1",getNumber (missionConfigFile >> "CfgTraderCategory" >> _cat >> "duplicate")]; }; - if (_vehUpgraded != "" && _y == (typeOf Z_vehicle)) then { _y = _vehUpgraded; }; + if (_vehUpgraded != "" && _y == (typeOf DZE_myVehicle)) then { _y = _vehUpgraded; }; _exists = isClass(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y); if (_exists) exitWith { _pic = ""; @@ -84,9 +84,9 @@ _totalPrice = 0; if (isNil '_text') then { _text = _y; }; _HasKey = true; - if (_vehTrade && {(typeOf Z_vehicle) == _y}) then { + if (_vehTrade && {(typeOf DZE_myVehicle) == _y}) then { if (!(_type in DZE_tradeVehicleKeyless) && DZE_SaleRequiresKey) then { - _HasKey = [Z_vehicle, _all] call _HasKeyCheck; + _HasKey = [DZE_myVehicle, _all] call _HasKeyCheck; }; }; if (!_HasKey) exitWith {}; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_checkCloseVehicle.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_checkCloseVehicle.sqf index 2c956eee0..07031de7b 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_checkCloseVehicle.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_checkCloseVehicle.sqf @@ -1,25 +1,17 @@ -private ["_vehicle","_list","_result","_pos"]; +private ["_list","_result","_pos"]; -Z_vehicle = objNull; -_vehicle = objNull; +_result = false; _pos = [player] call FNC_GetPos; _list = nearestObjects [_pos, ["Air","LandVehicle","Ship"], Z_VehicleDistance]; -if (!isNull DZE_myVehicle && local DZE_myVehicle && alive DZE_myVehicle && DZE_myVehicle in _list) then { - _vehicle = DZE_myVehicle; -}; - -_result = false; - -if (!isNull _vehicle) then { - Z_vehicle = _vehicle; +if (!isNull DZE_myVehicle && {local DZE_myVehicle} && {alive DZE_myVehicle} && {DZE_myVehicle in _list}) then { _result = true; 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]; + systemChat format[localize "STR_EPOCH_TRADE_SELECTED",typeOf DZE_myVehicle]; if (Z_Selling) then { - [format[localize "STR_EPOCH_TRADE_SELLING_FROM", typeOf Z_vehicle]] call Z_fillTradeTitle; + [format[localize "STR_EPOCH_TRADE_SELLING_FROM", typeOf DZE_myVehicle]] call Z_fillTradeTitle; } else { - [format[localize "STR_EPOCH_TRADE_BUYING_IN", typeOf Z_vehicle]] call Z_fillTradeTitle; + [format[localize "STR_EPOCH_TRADE_BUYING_IN", typeOf DZE_myVehicle]] call Z_fillTradeTitle; }; }; }; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayFreeSpace.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayFreeSpace.sqf index e40f35a2f..aa01feeb4 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayFreeSpace.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayFreeSpace.sqf @@ -45,13 +45,13 @@ if (_selection == 1) then { //vehicle _allowedWeapons = 0; _allowedBackpacks = 0; - if (!isNull Z_vehicle) then { - _freeSpace = [Z_vehicle,0,0,0,0] call Z_calcFreeSpace; + if (!isNull DZE_myVehicle) then { + _freeSpace = [DZE_myVehicle,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"); + _pic = getText (configFile >> "CfgVehicles" >> (typeOf DZE_myVehicle) >> "picture"); (findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_CONTAINERINFO) ctrlSetStructuredText parseText format [ "" diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_fillBuyableList.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_fillBuyableList.sqf index 6c7866c08..a6784eba1 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_fillBuyableList.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_fillBuyableList.sqf @@ -12,7 +12,7 @@ _typeOf = typeOf (unitBackPack player); _type = _x select 1; _count = 0; - if (_type in DZE_tradeVehicle && {_name == typeOf Z_vehicle}) then { + if (_type in DZE_tradeVehicle && {_name == typeOf DZE_myVehicle}) then { _count = 1; }; if (_type == "trade_items") then { diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getVehicleItems.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getVehicleItems.sqf index ee36247e8..645578832 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getVehicleItems.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getVehicleItems.sqf @@ -3,24 +3,15 @@ * * Gets all your items stored in your vehicle and initiates the selling list. **/ -private ["_vehicle","_pos","_list","_formattedText","_pic","_normalMags","_normalWeaps","_freeSpace"]; +private ["_formattedText","_pic","_normalMags","_normalWeaps","_freeSpace"]; #include "defines.hpp" -Z_vehicle = objNull; call Z_clearLists; Z_SellableArray = []; Z_SellArray = []; -_vehicle = objNull; -_pos = [player] call FNC_GetPos; -_list = nearestObjects [_pos, ["Air","LandVehicle","Ship"], Z_VehicleDistance]; - -if (!isNull DZE_myVehicle && local DZE_myVehicle && alive DZE_myVehicle && DZE_myVehicle in _list) then { - _vehicle = DZE_myVehicle; -}; - -if (!isNull _vehicle) then { - _pic = getText (configFile >> 'CfgVehicles' >> (typeOf _vehicle) >> 'picture'); +if (!isNull DZE_myVehicle) then { + _pic = getText (configFile >> 'CfgVehicles' >> (typeOf DZE_myVehicle) >> 'picture'); _formattedText = format [ "" @@ -28,13 +19,12 @@ if (!isNull _vehicle) then { ]; (findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_CONTAINERINFO) ctrlSetStructuredText parseText _formattedText; - Z_vehicle = _vehicle; - _freeSpace = [_vehicle,0,0,0,0] call Z_calcFreeSpace; + _freeSpace = [DZE_myVehicle,0,0,0,0] call Z_calcFreeSpace; _normalMags = _freeSpace select 5; _normalWeaps = _freeSpace select 6; //_normalBags = _freeSpace select 7; // Don't allow selling backpacks from vehicles because we can not get backpack contents. // We can only remove all backpacks with clearBackpackCargo and then add back new empty backpacks for ones that weren't sold. - [_normalWeaps,_normalMags,typeOf _vehicle,[]] call Z_checkArrayInConfig; + [_normalWeaps,_normalMags,typeOf DZE_myVehicle,[]] call Z_checkArrayInConfig; }; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_payDefault.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_payDefault.sqf index 269e1a99a..01c8c8286 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_payDefault.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_payDefault.sqf @@ -20,8 +20,8 @@ if (!_justChecking) then { 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 (!isNull DZE_myVehicle && count _moneyInVehicle > 0) then { + _nil = [DZE_myVehicle, _moneyInVehicle, [], []] call ZUPA_fnc_removeWeaponsAndMagazinesCargo; }; }; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_sellItems.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_sellItems.sqf index bb650cddf..f7657a78c 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_sellItems.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_sellItems.sqf @@ -1,7 +1,7 @@ -private ["_tempArray","_outcome","_vehCheckArray","_vehArray","_weaponsArray","_itemsArray","_bpArray","_bpCheckArray","_weaponsCheckArray","_itemsCheckArray","_VehKey","_wA","_mA","_money","_itemData","_success","_bag","_itemsToLog","_tCost","_tSold"]; +private ["_tempArray","_outcome","_vehCheckArray","_vehArray","_weaponsArray","_itemsArray","_bpArray","_bpCheckArray","_weaponsCheckArray","_itemsCheckArray","_VehKey","_wA","_mA","_money","_itemData","_success","_bag","_itemsToLog","_tCost","_tSold","_wealth"]; if (count Z_SellArray < 1) exitWith { systemChat localize "STR_EPOCH_TRADE_SELL_NO_ITEMS"; }; -if (Z_SellingFrom == 1 && (isNull Z_vehicle or !local Z_vehicle)) exitWith { systemChat localize "STR_EPOCH_PLAYER_245"; }; +if (Z_SellingFrom == 1 && (isNull DZE_myVehicle or !local DZE_myVehicle)) exitWith { systemChat localize "STR_EPOCH_PLAYER_245"; }; _tempArray = Z_SellArray; closeDialog 2; @@ -17,15 +17,14 @@ _itemsCheckArray = []; _itemsToLog = [[],[],[],"sell"]; _sellVehicle = { - private ["_distance","_damage","_tireDmg","_tires","_okToSell","_returnInfo","_obj","_hitpoints","_objectID","_objectUID","_objectCharacterId","_notSetup","_part_in","_qty_in","_activatingPlayer","_objects","_qty","_vehicle"]; + private ["_damage","_tireDmg","_tires","_okToSell","_returnInfo","_obj","_hitpoints","_objectID","_objectUID","_objectCharacterId","_notSetup","_part_in","_qty_in","_activatingPlayer","_objects","_qty","_vehicle"]; _vehicle = _this select 0; _sellType = _this select 1; _part_in = typeOf _vehicle; _qty_in = 1; _activatingPlayer = player; - _distance = Z_VehicleDistance; _returnInfo = []; - _objects = nearestObjects [(getPosATL player), [_part_in], _distance]; + _objects = nearestObjects [(getPosATL player), [_part_in], Z_VehicleDistance]; _qty = ({(typeOf _x) == _part_in} count _objects); if (_qty >= _qty_in) then { _obj = (_objects select 0); @@ -51,17 +50,17 @@ _sellVehicle = { _objectID = _obj getVariable ["ObjectID","0"]; _objectUID = _obj getVariable ["ObjectUID","0"]; _objectCharacterId = _obj getVariable ["CharacterID","0"]; - _notSetup = (_objectID == "0" && _objectUID == "0"); + _notSetup = (_objectID == "0" && _objectUID == "0"); if (local _obj && !isNull _obj && alive _obj && !_notSetup) then { if (_okToSell) then { _returnInfo = [_objectCharacterId, _obj, _objectID, _objectUID, _sellType]; } else { - systemChat format[localize "str_epoch_player_182",typeOf _obj]; + systemChat format[localize "str_epoch_player_182",typeOf _obj]; _returnInfo = []; }; } else { - systemChat localize "str_epoch_player_245"; + systemChat localize "str_epoch_player_245"; _returnInfo = []; }; }; @@ -91,8 +90,8 @@ _sellVehicle = { }; case (_type in DZE_tradeVehicle) : { - if (local Z_vehicle) then { - _VehKey = [Z_vehicle, _type] call _sellVehicle; + if (local DZE_myVehicle) then { + _VehKey = [DZE_myVehicle, _type] call _sellVehicle; if (count _VehKey > 0) then { _vehArray set [count(_vehArray),_VehKey]; _vehCheckArray set [count(_vehCheckArray),[_x select 2, _x select 11]]; @@ -111,11 +110,11 @@ if (Z_SellingFrom == 0) then { 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]; + _outcome = [DZE_myVehicle,_itemsArray,_weaponsArray,_vehArray] call ZUPA_fnc_removeWeaponsAndMagazinesCargo; + systemChat format[localize "STR_EPOCH_TRADE_SELL_IN_VEHICLE",count _tSold,typeOf DZE_myVehicle]; }; -_itemsToLog set [0,(_itemsArray + _weaponsArray + _bpArray + [typeOf Z_vehicle])]; +_itemsToLog set [0,(_itemsArray + _weaponsArray + _bpArray + [typeOf DZE_myVehicle])]; //gear if (Z_SellingFrom == 2) then { @@ -181,15 +180,15 @@ _money = 0; if (Z_SingleCurrency) then { { - _money = _money + ((((_itemsCheckArray select _forEachIndex) select 0)) * _x) ; + _money = _money + ((((_itemsCheckArray select _forEachIndex) select 0)) * _x); _itemsToLog set [2, (_itemsToLog select 2) + [((((_itemsCheckArray select _forEachIndex) select 0)) * _x)]]; } forEach (_outcome select 0); { - _money = _money + ((((_weaponsCheckArray select _forEachIndex) select 0)) * _x) ; + _money = _money + ((((_weaponsCheckArray select _forEachIndex) select 0)) * _x); _itemsToLog set [2, (_itemsToLog select 2) + [((((_weaponsCheckArray select _forEachIndex) select 0)) * _x)]]; } forEach (_outcome select 1); { - _money = _money + ((((_bpCheckArray select _forEachIndex) select 0)) * _x) ; + _money = _money + ((((_bpCheckArray select _forEachIndex) select 0)) * _x); _itemsToLog set [2, (_itemsToLog select 2) + [((((_bpCheckArray select _forEachIndex) select 0)) * _x)]]; } forEach (_outcome select 2); @@ -222,7 +221,8 @@ if (Z_SingleCurrency) then { if (typeName _money == "SCALAR") then { if (Z_SingleCurrency) then { - _success = [player,_money] call SC_fnc_addCoins; + _wealth = player getVariable[Z_MoneyVariable,0]; + player setVariable[Z_MoneyVariable,(_wealth + _money),true]; systemChat format[localize "STR_EPOCH_TRADE_SUCCESS_CHANGE",[_money] call BIS_fnc_numberText,CurrencyName]; } else { _success = [_money,0,false,0,[],[],false] call Z_returnChange; @@ -233,10 +233,10 @@ if (typeName _money == "SCALAR") then { _itemsToLog call Z_logTrade; call player_forceSave; if (Z_SellingFrom == 1) then { - PVDZ_veh_Save = [Z_vehicle,"gear"]; + PVDZ_veh_Save = [DZE_myVehicle,"gear"]; publicVariableServer "PVDZ_veh_Save"; }; } else { systemChat localize "STR_EPOCH_TRADE_DEBUG"; diag_log "Money is not a number. Something went wrong."; -}; +}; \ No newline at end of file diff --git a/SQF/dayz_code/actions/AdvancedTrading/init.sqf b/SQF/dayz_code/actions/AdvancedTrading/init.sqf index 6c40d47ac..ed90fd6d3 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/init.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/init.sqf @@ -10,33 +10,11 @@ if (dayz_actionInProgress) exitWith { localize "str_player_actionslimit" call da if (isNil "Z_AdvancedTradingInit") then { - //#include "config.sqf"; // Moved to dayz_code/configVariables.sqf #include "\z\addons\dayz_code\actions\AdvancedTrading\functions\defines.hpp" /* Configs that needs to be defined but not changed in config file */ - _tempGemList = []; - _tempWorthList = []; - DZE_GemList = []; - DZE_GemWorthList = []; - { - _tempGemList set [(count _tempGemList), (_x select 0)]; - _tempWorthList set [(count _tempWorthList), (_x select 1)]; - } count DZE_GemWorthArray; - - //sort the array - for "_i" from 0 to ((count _tempGemList) - 1) do { - _largest = _tempWorthList call BIS_fnc_greatestNum; - _LargestGem = _tempGemList select (_tempWorthList find _largest); - _tempWorthList = _tempWorthList - [_largest]; - _tempGemList = _tempGemList - [_LargestGem]; - DZE_GemList set [(count DZE_GemList), _LargestGem]; - DZE_GemWorthList set [(count DZE_GemWorthList), _largest]; - }; - Z_Selling = true; - Z_SellingFrom = 2; - Z_vehicle = objNull; Z_OriginalSellableArray = []; Z_SellableArray = []; Z_SellArray = []; @@ -46,54 +24,46 @@ if (isNil "Z_AdvancedTradingInit") then { /* end script config */ - ZUPA_fnc_removeWeaponsAndMagazinesCargo = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\zupa_fnc_removeWeaponsAndMagazinesCargo.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"); - Z_clearBuyingList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_clearBuyingList.sqf"); - Z_fillCategories = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_fillCategories.sqf"); - Z_getItemInfo = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_getItemInfo.sqf"); - Z_getItemConfig = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_getItemConfig.sqf"); - Z_displayItemInfo = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_displayItemInfo.sqf"); - Z_displayWeaponInfo = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_displayWeaponInfo.sqf"); - Z_displayBackpackInfo = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_displayBackpackInfo.sqf"); - Z_displayVehicleInfo = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_displayVehicleInfo.sqf"); - Z_getContainer = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_getContainer.sqf"); - Z_getBackpackItems = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_getBackpackItems.sqf"); - Z_getVehicleItems = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_getVehicleItems.sqf"); - Z_getGearItems = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_getGearItems.sqf"); - Z_logTrade = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_logTrade.sqf"); - Z_filterList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_filterList.sqf"); - Z_checkArrayInConfig = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_checkArrayInConfig.sqf"); - Z_calcPrice = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_calcPrice.sqf"); - Z_fillCategoryList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_fillCategoryList.sqf"); - Z_fillSellList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_fillSellList.sqf"); - Z_fillSellingList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_fillSellingList.sqf"); - Z_pushItemToList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_pushItemToList.sqf"); - Z_removeItemFromList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_removeItemFromList.sqf"); - Z_pushAllToList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_pushAllToList.sqf"); - Z_removeAllToList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_removeAllToList.sqf"); - Z_SellItems = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_sellItems.sqf"); - Z_BuyItems = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_buyItems.sqf"); - Z_ChangeBuySell = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_changeBuySell.sqf"); - Z_removeAllFromBuyingList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_removeAllFromBuyingList.sqf"); - Z_removeItemFromBuyingList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_removeItemFromBuyingList.sqf"); - Z_toBuyingList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_toBuyingList.sqf"); - 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_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"); - Z_returnChange = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_returnChange.sqf"); - Z_payDefault = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_payDefault.sqf"); - Z_calcDefaultCurrency = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_calcDefaultCurrency.sqf"); - z_calcDefaultCurrencyNoImg = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_calcDefaultCurrencyNoImg.sqf"); - DZE_deleteTradedVehicle = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\DZE_deleteTradedVehicle.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"); + Z_clearBuyingList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_clearBuyingList.sqf"); + Z_fillCategories = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_fillCategories.sqf"); + Z_getItemInfo = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_getItemInfo.sqf"); + Z_getItemConfig = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_getItemConfig.sqf"); + Z_displayItemInfo = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_displayItemInfo.sqf"); + Z_displayWeaponInfo = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_displayWeaponInfo.sqf"); + Z_displayBackpackInfo = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_displayBackpackInfo.sqf"); + Z_displayVehicleInfo = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_displayVehicleInfo.sqf"); + Z_getContainer = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_getContainer.sqf"); + Z_getBackpackItems = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_getBackpackItems.sqf"); + Z_getVehicleItems = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_getVehicleItems.sqf"); + Z_getGearItems = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_getGearItems.sqf"); + Z_logTrade = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_logTrade.sqf"); + Z_filterList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_filterList.sqf"); + Z_checkArrayInConfig = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_checkArrayInConfig.sqf"); + Z_calcPrice = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_calcPrice.sqf"); + Z_fillCategoryList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_fillCategoryList.sqf"); + Z_fillSellList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_fillSellList.sqf"); + Z_fillSellingList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_fillSellingList.sqf"); + Z_pushItemToList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_pushItemToList.sqf"); + Z_removeItemFromList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_removeItemFromList.sqf"); + Z_pushAllToList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_pushAllToList.sqf"); + Z_removeAllToList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_removeAllToList.sqf"); + Z_SellItems = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_sellItems.sqf"); + Z_BuyItems = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_buyItems.sqf"); + Z_ChangeBuySell = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_changeBuySell.sqf"); + Z_removeAllFromBuyingList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_removeAllFromBuyingList.sqf"); + Z_removeItemFromBuyingList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_removeItemFromBuyingList.sqf"); + Z_toBuyingList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_toBuyingList.sqf"); + 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_displayFreeSpace = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_displayFreeSpace.sqf"); + Z_allowBuying = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_allowBuying.sqf"); + Z_calcDefaultCurrency = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_calcDefaultCurrency.sqf"); + DZE_deleteTradedVehicle = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\DZE_deleteTradedVehicle.sqf"); Z_AdvancedTradingInit = true; }; diff --git a/SQF/dayz_code/actions/plotManagement/maintain_area.sqf b/SQF/dayz_code/actions/plotManagement/maintain_area.sqf index 66ae07fce..e607de9f2 100644 --- a/SQF/dayz_code/actions/plotManagement/maintain_area.sqf +++ b/SQF/dayz_code/actions/plotManagement/maintain_area.sqf @@ -19,82 +19,80 @@ _requirements = []; _count = 0; _req = { - private ["_count","_requirements","_type","_amount","_itemText","_wealth"]; + private ["_count","_amount","_itemText"]; + _count = _this; - _wealth = 0; - - _requirements = switch true do { - case (_count <= 10): {["ItemGoldBar10oz",1]}; - case (_count <= 20): {["ItemGoldBar10oz",2]}; - case (_count <= 35): {["ItemGoldBar10oz",3]}; - case (_count <= 50): {["ItemGoldBar10oz",4]}; - case (_count <= 75): {["ItemGoldBar10oz",6]}; - case (_count <= 100): {["ItemBriefcase100oz",1]}; - case (_count <= 175): {["ItemBriefcase100oz",2]}; - case (_count <= 250): {["ItemBriefcase100oz",3]}; - case (_count <= 325): {["ItemBriefcase100oz",4]}; - case (_count <= 400): {["ItemBriefcase100oz",5]}; - case (_count <= 475): {["ItemBriefcase100oz",6]}; - case (_count <= 550): {["ItemBriefcase100oz",7]}; - case (_count <= 625): {["ItemBriefcase100oz",8]}; - case (_count > 625): {["ItemBriefcase100oz",9]}; - }; + _amount = _count * 100; + _itemText = if (Z_SingleCurrency) then { CurrencyName } else { _amount call z_calcDefaultCurrencyNoImg }; - _type = _requirements select 0; - _amount = _requirements select 1; - - if (Z_SingleCurrency) then { - _amount = _count * 100; - _itemText = CurrencyName; - _wealth = player getVariable[Z_MoneyVariable,0]; - } else { - _itemText = getText(configFile >> "CfgMagazines" >> _type >> "displayName"); - if ("ItemBriefcase100oz" == _type && _amount > 1) then { - _itemText = _itemText + "s"; - }; - }; - - [_type,_amount,_itemText,_wealth] + [_amount,_itemText] }; _maintain = { - private ["_requirements","_count","_type","_amount","_itemText","_wealth","_success","_message1","_message2","_ctrl"]; + private ["_requirements","_count","_amount","_itemText","_wealth","_success","_message1","_message2","_ctrl","_enoughMoney","_moneyInfo"]; _count = count (_this select 0); _requirements = _count call _req; - _type = _requirements select 0; - _amount = _requirements select 1; - _itemText = _requirements select 2; - _wealth = _requirements select 3; - - _success = if (Z_SingleCurrency) then {_amount <= _wealth} else {[[[_type, _amount]],0] call epoch_returnChange}; - - if (_success) then { - player playActionNow "Medic"; - [player,DZE_maintainRange,true,(getPosATL player)] spawn player_alertZombies; + _amount = _requirements select 0; + _itemText = _requirements select 1; - if (Z_SingleCurrency) then { - player setVariable[Z_MoneyVariable,(_wealth - _amount),true]; - }; - call player_forceSave; + _enoughMoney = false; + _moneyInfo = [false, [], [], [], 0]; + _wealth = player getVariable[Z_MoneyVariable,0]; - PVDZE_maintainArea = [player,1,_this select 0]; - publicVariableServer "PVDZE_maintainArea"; + if (Z_SingleCurrency) then { + _enoughMoney = if (_wealth >= _amount) then { true } else { false }; + } else { + Z_Selling = false; // Initialize gem currency before Z_canAfford. + _moneyInfo = _amount call Z_canAfford; + _enoughMoney = _moneyInfo select 0; + }; - systemChat format[localize "STR_EPOCH_ACTIONS_4", _count]; - _message1 = format [localize "STR_EPOCH_PLOTMANAGEMENT_OBJECTS_MAINTAINED_SUCCESS", _count, [_amount] call BIS_fnc_numberText, _itemText]; - _message2 = " "; - if (DZE_permanentPlot) then { - _ctrl = (uiNamespace getVariable "PlotManagement") displayCtrl 7012; - _ctrl ctrlSetText _message1; - _ctrl = (uiNamespace getVariable "PlotManagement") displayCtrl 7013; - _ctrl ctrlSetText _message2; + _success = if (Z_SingleCurrency) then { true } else { [player,_amount,_moneyInfo,true,0] call Z_payDefault }; + + 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 { + _success = if (Z_SingleCurrency) then {_amount <= _wealth} else {[player,_amount,_moneyInfo,false,0] call Z_payDefault}; + if (_success) then { + + PVDZE_maintainArea = [player,1,_this select 0]; + publicVariableServer "PVDZE_maintainArea"; + + systemChat format[localize "STR_EPOCH_ACTIONS_4",_count]; + if (Z_SingleCurrency) then { + player setVariable[Z_MoneyVariable,(_wealth - _amount),true]; + _message1 = format [localize "STR_EPOCH_PLOTMANAGEMENT_OBJECTS_MAINTAINED_SUCCESS",_count,[_amount] call BIS_fnc_numberText,_itemText]; + } else { + _message1 = format [localize "STR_EPOCH_PLOTMANAGEMENT_OBJECTS_MAINTAINED_SUCCESS",_count,_itemText,""]; + }; + _message2 = " "; + call player_forceSave; // Call player_forceSave BEFORE the medic animation because it can override the animation and make it finish prematurely. + + player playActionNow "Medic"; + + [player,"repair",0,false,20] call dayz_zombieSpeak; + [player,DZE_maintainRange,true,(getPosATL player)] spawn player_alertZombies; + ["Working",0,[100,15,10,0]] call dayz_NutritionSystem; + + if (DZE_permanentPlot) then { + _ctrl = (uiNamespace getVariable "PlotManagement") displayCtrl 7012; + _ctrl ctrlSetText _message1; + _ctrl = (uiNamespace getVariable "PlotManagement") displayCtrl 7013; + _ctrl ctrlSetText _message2; + } else { + _message1 call dayz_rollingMessages; + }; } else { - _message1 call dayz_rollingMessages; + systemChat localize "STR_EPOCH_TRADE_DEBUG"; }; } else { - _message1 = format[localize "STR_EPOCH_PLOTMANAGEMENT_OBJECTS_MAINTAINED_FAILED", _count, [_amount] call BIS_fnc_numberText, _itemText]; + if (Z_SingleCurrency) then { + _message1 = format[localize "STR_EPOCH_PLOTMANAGEMENT_OBJECTS_MAINTAINED_FAILED",_count,[_amount] call BIS_fnc_numberText,_itemText]; + } else { + _message1 = format[localize "STR_EPOCH_PLOTMANAGEMENT_OBJECTS_MAINTAINED_FAILED",_count,_itemText,""]; + }; _message2 = " "; if (DZE_permanentPlot) then { _ctrl = (uiNamespace getVariable "PlotManagement") displayCtrl 7012; @@ -108,12 +106,12 @@ _maintain = { }; { - if (damage _x >= DZE_DamageBeforeMaint) then { + if (damage _x >= DZE_DamageBeforeMaint) then { _objectUID = _x getVariable ["ObjectUID","0"]; _objectID = _x getVariable ["ObjectID","0"]; _objects_filtered set [count _objects_filtered, [_x, _objectID, _objectUID]]; _count = _count + 1; - }; + }; } count _objects; _option = if (typeName _this == "ARRAY") then {_this select 3} else {_this}; @@ -137,7 +135,12 @@ switch _option do { }; } else { _requirements = _count call _req; - _message1 = format [localize "STR_EPOCH_PLOTMANAGEMENT_MAINTAIN_PRICE", _count,[_requirements select 1] call BIS_fnc_numberText,_requirements select 2]; + + if (Z_SingleCurrency) then { + _message1 = format [localize "STR_EPOCH_PLOTMANAGEMENT_MAINTAIN_PRICE", _count,[_requirements select 0] call BIS_fnc_numberText,_requirements select 1]; + } else { + _message1 = format [localize "STR_EPOCH_PLOTMANAGEMENT_MAINTAIN_PRICE", _count,_requirements select 1,""]; + }; if (DZE_permanentPlot) then { _ctrl = (uiNamespace getVariable "PlotManagement") displayCtrl 7012; _ctrl ctrlSetText _message1; @@ -146,7 +149,11 @@ switch _option do { }; }; _requirements = count _objects call _req; - _message2 = format [localize "STR_EPOCH_PLOTMANAGEMENT_MAINTAIN_FORCE",count _objects,[_requirements select 1] call BIS_fnc_numberText,_requirements select 2]; + if (Z_SingleCurrency) then { + _message2 = format [localize "STR_EPOCH_PLOTMANAGEMENT_MAINTAIN_FORCE",count _objects,[_requirements select 0] call BIS_fnc_numberText,_requirements select 1]; + } else { + _message2 = format [localize "STR_EPOCH_PLOTMANAGEMENT_MAINTAIN_FORCE",count _objects,_requirements select 1,""]; + }; if (_count != count _objects) then { if (DZE_permanentPlot) then { _ctrl = (uiNamespace getVariable "PlotManagement") displayCtrl 7013; diff --git a/SQF/dayz_code/init/compiles.sqf b/SQF/dayz_code/init/compiles.sqf index c1adbdd8e..160a1754c 100644 --- a/SQF/dayz_code/init/compiles.sqf +++ b/SQF/dayz_code/init/compiles.sqf @@ -205,6 +205,9 @@ if (!isDedicated) then { player_enterCode = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\doorManagement\player_enterCode.sqf"; FNC_check_access = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_check_access.sqf"; + // Advanced trading default inits for maintaining, Advanced Trading and custom scripts to utilize gem based currency. + call compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\AdvancedTrading\defaultInit.sqf"; + dayz_losChance = { private["_agent","_maxDis","_dis","_val","_maxExp","_myExp"]; _agent = _this select 0; @@ -935,4 +938,4 @@ dayz_engineSwitch = { PVDZ_send = [_vehicle,"SetEngineState",[_vehicle,_state]]; publicVariableServer "PVDZ_send"; }; -}; \ No newline at end of file +}; diff --git a/SQF/dayz_code/stringtable.xml b/SQF/dayz_code/stringtable.xml index 51c10dd57..428bf7a54 100644 --- a/SQF/dayz_code/stringtable.xml +++ b/SQF/dayz_code/stringtable.xml @@ -15241,15 +15241,15 @@ Preis zum Instandsetzen von %1 Objekten: %2 %3 - Success! %1 objects maintained for %2 %3. + Success! %1 objects maintained for %2 %3 Du hast %1 Objekte erfolgreich instandgesetzt für %2 %3. - Price to force maintain %1 objects: %2 %3. + Price to force maintain %1 objects: %2 %3 Instandsetzen erzwingen: Preis für %1 Objekten: %2 %3 - Failed to maintain %1 objects. You need %2 %3. + Failed to maintain %1 objects. You need %2 %3 Instandsetzen von %1 Objekten fehlgeschlagen. Du brauchst %2 %3