From e1b612576162603c51a431c2684bce76c97ddf22 Mon Sep 17 00:00:00 2001 From: ebayShopper Date: Tue, 7 Nov 2017 16:53:33 -0500 Subject: [PATCH] Fix Javelin selling and _HasKey check again @oiad Add the Javelin magazine as trade_items to a trader which only sells magazines (like FriendlyAssaultRifleAmmo) and the Javelin weapon as trade_weapons to a trader which only sells weapons (like FriendlyAssaultRifle), then test your changes from f8a230e with both in your gear. You will see it allows you to sell all the magazines and the weapon at both traders. This is because the only condition to add the item to the sellable array is that it exists as an entry in the category. It never checks the entry type. This commit will check to make sure the type matches in the config and the player's inventory. I changed your static "trade_any_vehicle" to find the type in the config, because it could also be "trade_any_boat/bicycle/vehicle_free". Boats are handled differently for the hitpoints check in sellItems.sqf. Also I noticed that both the _HasKey check and your new _y == _myVehType check were not working for upgraded vehicles _DZE[1-4] because they had been swapped out to _baseVehicle. I forgot to account for that when I added that feature. This should resolve both problems. I tested both and everything looks good. It can do with some more thorough testing though. Note DZE_SaleRequiresKey is false by default. --- CHANGE LOG 1.0.6.2.txt | 3 +- .../functions/z_at_checkArrayInConfig.sqf | 38 ++++++++++--------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/CHANGE LOG 1.0.6.2.txt b/CHANGE LOG 1.0.6.2.txt index 6e8cf7368..00208b612 100644 --- a/CHANGE LOG 1.0.6.2.txt +++ b/CHANGE LOG 1.0.6.2.txt @@ -27,6 +27,7 @@ [UPDATED] Reverted increased waves in stormy weather to Chernarus default settings. [UPDATED] Removed server control panel, because it is abused by players and not currently used by admins [UPDATED] Moved large format strings in dayz_server to str formatText to avoid A2 2048 format character limit corrupting hive data in some cases. +[UPDATED] Vehicles can now only be sold from the "Gear" sell menu. This prevents accidental selling when using the "sell all" feature on backpacks and vehicle inventories. [FIXED] Kamaz refuel trucks no longer allow automatic refueling. #1855 @coresync2k @dreamforceinc [FIXED] Trees at POIs can be chopped down now. Other trees spawned with createVehicle can be added to dayz_treeTypes in variables.sqf to allow chopping them down. @@ -68,7 +69,7 @@ [FIXED] Certain classes (i.e. Satchel Charge) which are both magazines and weapons were not retained through skin change #1981 @AirwavesMan [FIXED] Blocked another A2OA script execution bug from improperly cleared eventhandlers. See dayz_code\system\antihack.sqf. Thanks to Dihan for reporting [FIXED] Missing silencer shadows on some _DZ weapons. Thanks @Streatman -[FIXED] Death message server RPT logs were partially translated, resulting in sloppy mixed language sentences on non-English machines. +[FIXED] Launchers and launcher ammo are now detected correctly in the sell menu when a player has a launcher and ammo with the same classname. [NOTE] Fixes below were included in hotfix 1.0.6.1A (March 10th 2017) and are now in the default files. [FIXED] Fixed food and drink going down 10x faster from melee and other "working" actions. 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 f6e94dd14..f63ae502d 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_checkArrayInConfig.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_checkArrayInConfig.sqf @@ -8,7 +8,7 @@ * * Fills up the sell or buy list if the item has a valid config. **/ -private ["_weaps","_mags","_extraText","_all","_arrayOfTraderCat","_totalPrice","_backUpText","_bags","_baseVehicle","_currencyQty","_swap","_swap2","_myVehType"]; +private ["_weaps","_mags","_extraText","_arrayOfTraderCat","_totalPrice","_backUpText","_bags","_baseVehicle","_currencyQty","_swap","_swap2","_myVehType"]; #include "defines.hpp" _weaps = _this select 0; @@ -37,9 +37,9 @@ _HasKeyCheck = { _totalPrice = 0; _processGear = { - private ["_array","_type","_cat","_exists","_pic","_text","_sell","_buy","_buyCurrency","_sellCurrency","_worth"]; + private ["_configType","_passedType","_cat","_pic","_text","_sell","_buy","_buyCurrency","_sellCurrency","_worth"]; - _type = _this select 1; + _passedType = _this select 1; { _y = _x; _swap = false; @@ -52,34 +52,35 @@ _processGear = { _swap2 = true; }; { - _cat = format["Category_%1",(_arrayOfTraderCat select _forEachIndex select 1)]; + _cat = format["Category_%1",(_arrayOfTraderCat select _forEachIndex select 1)]; if (isNumber (missionConfigFile >> "CfgTraderCategory" >> _cat >> "duplicate")) then { _cat = format["Category_%1",getNumber (missionConfigFile >> "CfgTraderCategory" >> _cat >> "duplicate")]; }; - if (_swap2 && {!isClass(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y)} && {isClass(missionConfigFile >> "CfgTraderCategory" >> _cat >> _baseVehicle)}) then { + if (_swap2 && {!isClass(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y)} && {isClass(missionConfigFile >> "CfgTraderCategory" >> _cat >> _baseVehicle)}) then { //Use base vehicle prices for upgraded _DZE[1-4] variants only if they are not explicitly added in trader config _y = _baseVehicle; }; - _exists = isClass(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y); - if (_exists) exitWith { + if (isClass(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y)) exitWith { _pic = ""; _text = ""; - - _sell = getArray(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "sell"); - _buy = getArray(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "buy"); + _configType = getText(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "type"); + if (_passedType == "find") then {_passedType = _configType;}; + + _sell = getArray(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "sell"); + _buy = getArray(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "buy"); if (_swap) then {_y = "ItemBloodbag"}; switch (true) do { - case (_type == "trade_items") : + case (_passedType == "trade_items") : { _pic = getText (configFile >> 'CfgMagazines' >> _y >> 'picture'); _text = getText (configFile >> 'CfgMagazines' >> _y >> 'displayName'); }; - case (_type == "trade_weapons") : + case (_passedType == "trade_weapons") : { _pic = getText (configFile >> 'CfgWeapons' >> _y >> 'picture'); _text = getText (configFile >> 'CfgWeapons' >> _y >> 'displayName'); }; - case (_type in DZE_tradeObject) : + case (_passedType in DZE_tradeObject) : { _pic = getText (configFile >> 'CfgVehicles' >> _y >> 'picture'); _text = getText (configFile >> 'CfgVehicles' >> _y >> 'displayName'); @@ -88,12 +89,13 @@ _processGear = { if (isNil '_text') then { _text = _y; }; _HasKey = true; - if (_vehTrade && {_y == _myVehType}) then { - if (!(_type in DZE_tradeVehicleKeyless) && DZE_SaleRequiresKey) then { + if (_vehTrade && {_y in [_baseVehicle,_myVehType]}) then { + if (!(_passedType in DZE_tradeVehicleKeyless) && DZE_SaleRequiresKey) then { _HasKey = call _HasKeyCheck; }; + if (Z_SellingFrom != 2) then {_HasKey = false;}; //Only allow selling vehicle from gear }; - if (!_HasKey || {_y == _myVehType && Z_SellingFrom != 2}) exitWith {}; + if (_passedType != _configType or !_HasKey) exitWith {}; _worth = 0; _currencyQty = _buy select 0; @@ -109,7 +111,7 @@ _processGear = { }; if (_currencyQty < 0) then {_buyCurrency = localize "STR_EPOCH_UNAVAILABLE";}; if ((_sell select 0) >= 0) then { - Z_SellableArray set [count(Z_SellableArray) , [_y, _type, _sell select 0, _text, _pic, _forEachIndex, _currencyQty, _sellCurrency, _buyCurrency, 0 ,_cat, _worth]]; + Z_SellableArray set [count(Z_SellableArray) , [_y, _passedType, _sell select 0, _text, _pic, _forEachIndex, _currencyQty, _sellCurrency, _buyCurrency, 0 ,_cat, _worth]]; }; _totalPrice = _totalPrice + (_sell select 0); }; @@ -120,7 +122,7 @@ _processGear = { if (false call Z_checkCloseVehicle) then { _baseVehicle = getText (configFile >> "CfgVehicles" >> _myVehType >> "original"); _vehTrade = true; - [[_myVehType],"trade_any_vehicle"] call _processGear; + [[_myVehType],"find"] call _processGear; }; [_weaps,"trade_weapons"] call _processGear;