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 a282bd53f..7124eba86 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_buyItems.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_buyItems.sqf @@ -36,7 +36,7 @@ if (Z_SingleCurrency) then { _backpacksToBuy = _backpacksToBuy + (_x select 9) ; _priceToBuy = _priceToBuy + ((_x select 9)*(_x select 2)); // _price * _amount }; - if( _x select 1 == "trade_any_vehicle")then{ + if((_x select 1) in ["trade_any_vehicle", "trade_any_vehicle_free", "trade_any_vehicle_old", "trade_any_bicycle", "trade_any_bicycle_old", "trade_any_boat", "trade_any_boat_old"])then{ _vehiclesToBuy = _vehiclesToBuy + (_x select 9) ; _priceToBuy = _priceToBuy + ((_x select 9)*(_x select 2)); // _price * _amount }; @@ -65,7 +65,7 @@ if (Z_SingleCurrency) then { _backpacksToBuy = _backpacksToBuy + (_x select 9) ; _priceToBuy = _priceToBuy + ((_x select 11)*(_x select 2)*(_x select 9)); }; - if( _x select 1 == "trade_any_vehicle")then{ + if((_x select 1) in ["trade_any_vehicle", "trade_any_vehicle_free", "trade_any_vehicle_old", "trade_any_bicycle", "trade_any_bicycle_old", "trade_any_boat", "trade_any_boat_old"])then{ _vehiclesToBuy = _vehiclesToBuy + (_x select 9) ; _priceToBuy = _priceToBuy + ((_x select 11)*(_x select 2)*(_x select 9)); }; @@ -134,7 +134,7 @@ if(_enoughMoney) then { _backpack addMagazineCargoGlobal [_x select 0, _x select 9]; diag_log format ["%1 x %2 added", _x select 0, _x select 9]; }; - if( _x select 1 == "trade_any_vehicle")then{ + if((_x select 1) in ["trade_any_vehicle", "trade_any_vehicle_free", "trade_any_vehicle_old", "trade_any_bicycle", "trade_any_bicycle_old", "trade_any_boat", "trade_any_boat_old"])then{ _item2Add = (_x select 0) call _buyVehicle; if (_item2Add != "") then { _backpack addWeaponCargoGlobal [_item2Add, 1]; @@ -159,7 +159,7 @@ if(_enoughMoney) then { Z_vehicle addBackpackCargoGlobal [_x select 0, _x select 9]; diag_log format ["%1 x %2 added", _x select 0, _x select 9]; }; - if( _x select 1 == "trade_any_vehicle")then{ + if((_x select 1) in ["trade_any_vehicle", "trade_any_vehicle_free", "trade_any_vehicle_old", "trade_any_bicycle", "trade_any_bicycle_old", "trade_any_boat", "trade_any_boat_old"])then{ _item2Add = (_x select 0) call _buyVehicle; if (_item2Add != "") then { Z_vehicle addWeaponCargoGlobal [_item2Add, 1]; @@ -191,7 +191,7 @@ if(_enoughMoney) then { if( _x select 1 == "trade_backpacks")then{ player addBackpack (_x select 0); }; - if( _x select 1 == "trade_any_vehicle")then{ + if((_x select 1) in ["trade_any_vehicle", "trade_any_vehicle_free", "trade_any_vehicle_old", "trade_any_bicycle", "trade_any_bicycle_old", "trade_any_boat", "trade_any_boat_old"])then{ _item2Add = (_x select 0) call _buyVehicle; if (_item2Add != "") then { player addWeapon _item2Add; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcBuyableList.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcBuyableList.sqf index a59ff7b87..5ad066d7d 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcBuyableList.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcBuyableList.sqf @@ -31,7 +31,7 @@ _counter = 0; _pic = getText (configFile >> 'CfgWeapons' >> _y >> 'picture'); _text = getText (configFile >> 'CfgWeapons' >> _y >> 'displayName'); }; - if(_type == "trade_any_vehicle" || _type == "trade_backpacks")then{ + if(_type in ["trade_backpacks", "trade_any_vehicle", "trade_any_vehicle_free", "trade_any_vehicle_old", "trade_any_bicycle", "trade_any_bicycle_old", "trade_any_boat", "trade_any_boat_old"])then{ _pic = getText (configFile >> 'CfgVehicles' >> _y >> 'picture'); _text = getText (configFile >> 'CfgVehicles' >> _y >> 'displayName'); }; 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 0776f52d0..be2b94eb8 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_checkArrayInConfig.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_checkArrayInConfig.sqf @@ -27,14 +27,18 @@ _HasKeyCheck = { _inventory = _this select 1; _keyFound = false; _objectCharacterId = _obj getVariable ["CharacterID","0"]; - _keyColor = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"]; - { - if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in _keyColor) then { - if (str(getNumber(configFile >> "CfgWeapons" >> _x >> "keyid")) == _objectCharacterId) then { - _keyFound = true; + if (_objectCharacterId == "0") then { + _keyFound = true; + } else { + _keyColor = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"]; + { + if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in _keyColor) then { + if (str(getNumber(configFile >> "CfgWeapons" >> _x >> "keyid")) == _objectCharacterId) then { + _keyFound = true; + }; }; - }; - } count _inventory; + } count _inventory; + }; _keyFound; }; _totalPrice = 0; @@ -62,7 +66,7 @@ if(_total > 0)then{ _pic = getText (configFile >> 'CfgWeapons' >> _y >> 'picture'); _text = getText (configFile >> 'CfgWeapons' >> _y >> 'displayName'); }; - case (_type in ["trade_backpacks", "trade_any_vehicle"]) : + case (_type in ["trade_backpacks", "trade_any_vehicle", "trade_any_vehicle_free", "trade_any_vehicle_old", "trade_any_bicycle", "trade_any_bicycle_old", "trade_any_boat", "trade_any_boat_old"]) : { _pic = getText (configFile >> 'CfgVehicles' >> _y >> 'picture'); _text = getText (configFile >> 'CfgVehicles' >> _y >> 'displayName'); @@ -74,7 +78,9 @@ if(_total > 0)then{ }; _HasKey = true; if (_vehTrade && {(typeOf Z_vehicle) == _y}) then { - _HasKey = [Z_vehicle, _all] call _HasKeyCheck; + if (!(_type in ["trade_any_bicycle", "trade_any_bicycle_old", "trade_any_vehicle_free"])) then { + _HasKey = [Z_vehicle, _all] call _HasKeyCheck; + }; }; if (!_HasKey) exitWith {}; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getItemConfig.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getItemConfig.sqf index 072fef4ba..913b7f544 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getItemConfig.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getItemConfig.sqf @@ -17,7 +17,7 @@ switch (true) do { { [_item] call Z_displayBackpackInfo; }; - case (_type == "trade_any_vehicle") : + case (_type in ["trade_any_vehicle", "trade_any_vehicle_free", "trade_any_vehicle_old", "trade_any_bicycle", "trade_any_bicycle_old", "trade_any_boat", "trade_any_boat_old"]) : { [_item] call Z_displayVehicleInfo; }; 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 3fcb80ff2..250113c22 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_sellItems.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_sellItems.sqf @@ -16,16 +16,20 @@ if(_index > -1)then{ _deleteTradedVehicle = { private ["_localResult2","_VehKey2"]; - _VehKey2 = _this select 0; - + _VehKey2 = (_this select 0) select 0; + _delType = _this select 1; if ((count _VehKey2) > 0) then { - { - if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"]) then { - if (str(getNumber(configFile >> "CfgWeapons" >> _x >> "keyid")) == (_VehKey2 select 0)) then { - _localResult2 = [player,_x,1] call BIS_fnc_invRemove; + if ((_VehKey2 select 0) == "0" || _delType in ["trade_any_bicycle", "trade_any_bicycle_old", "trade_any_vehicle_free"]) then { + _localResult2 = 1; + } else { + { + if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"]) then { + if (str(getNumber(configFile >> "CfgWeapons" >> _x >> "keyid")) == (_VehKey2 select 0)) then { + _localResult2 = [player,_x,1] call BIS_fnc_invRemove; + }; }; - }; - } forEach (items player); + } forEach (items player); + }; if (isNil "_localResult2") then { _localResult2 = 0; } else { @@ -40,7 +44,8 @@ if(_index > -1)then{ }; _sellVehicle = { private ["_distance","_damage","_tireDmg","_tires","_okToSell","_returnInfo","_textPartIn","_obj","_hitpoints","_objectID","_objectUID","_objectCharacterId","_notSetup","_part_in","_qty_in","_activatingPlayer","_objects","_qty","_vehicle"]; - _vehicle = _this; + _vehicle = _this select 0; + _sellType = _this select 1; _part_in = typeOf _vehicle; _qty_in = 1; _activatingPlayer = player; @@ -50,22 +55,23 @@ if(_index > -1)then{ _qty = ({(typeOf _x) == _part_in} count _objects); if (_qty >= _qty_in) then { _obj = (_objects select 0); - _hitpoints = _obj call vehicle_getHitpoints; _okToSell = true; _tires = 0; _tireDmg = 0; _damage = 0; - - { - if(["Wheel",_x,false] call fnc_inString) then { - _damage = [_obj,_x] call object_getHit; - _tireDmg = _tireDmg + _damage; - _tires = _tires + 1; - }; - } forEach _hitpoints; - if(_tireDmg > 0 && _tires > 0) then { - if((_tireDmg / _tires) > 0.75) then { - _okToSell = false; + if (!(_sellType in ["trade_any_boat", "trade_any_boat_old"])) then { + _hitpoints = _obj call vehicle_getHitpoints; + { + if(["Wheel",_x,false] call fnc_inString) then { + _damage = [_obj,_x] call object_getHit; + _tireDmg = _tireDmg + _damage; + _tires = _tires + 1; + }; + } forEach _hitpoints; + if(_tireDmg > 0 && _tires > 0) then { + if((_tireDmg / _tires) > 0.75) then { + _okToSell = false; + }; }; }; _objectID = _obj getVariable ["ObjectID","0"]; @@ -75,7 +81,7 @@ if(_index > -1)then{ if(local _obj && !isNull _obj && alive _obj && !_notSetup) then { if(_okToSell) then { - _returnInfo = [_objectCharacterId, _obj, _objectID, _objectUID]; + _returnInfo = [_objectCharacterId, _obj, _objectID, _objectUID, _sellType]; } else { systemChat format[localize "str_epoch_player_182",_textPartIn]; _returnInfo = []; }; @@ -106,10 +112,10 @@ if(_index > -1)then{ _bpArray set [count(_bpArray),_name]; _bpCheckArray set [count(_bpCheckArray),[_x select 2, _x select 11]]; }; - case (_type == "trade_any_vehicle") : + case (_type in ["trade_any_vehicle", "trade_any_vehicle_free", "trade_any_vehicle_old", "trade_any_bicycle", "trade_any_bicycle_old", "trade_any_boat", "trade_any_boat_old"]) : { if (local Z_vehicle) then { - _VehKey = Z_vehicle call _sellVehicle; + _VehKey = [Z_vehicle, _type] call _sellVehicle; if (count _VehKey > 0) then { _vehArray set [count(_vehArray),_VehKey]; _vehCheckArray set [count(_vehCheckArray),[_x select 2, _x select 11]]; @@ -136,8 +142,8 @@ if(_index > -1)then{ _vehTraded = false; { - if (_x select 1 == "trade_any_vehicle") then { - _localResult = _vehArray call _deleteTradedVehicle; + if ((_x select 1) in ["trade_any_vehicle", "trade_any_vehicle_free", "trade_any_vehicle_old", "trade_any_bicycle", "trade_any_bicycle_old", "trade_any_boat", "trade_any_boat_old"]) then { + _localResult = [_vehArray, (_x select 1)] call _deleteTradedVehicle; if (_localResult == 1) then {_vehTraded = true;}; } else { _localResult = [player,(_x select 0),1] call BIS_fnc_invRemove; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/zupa_fnc_removeWeaponsAndMagazinesCargo.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/zupa_fnc_removeWeaponsAndMagazinesCargo.sqf index 9792cb3ec..ee3777378 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/zupa_fnc_removeWeaponsAndMagazinesCargo.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/zupa_fnc_removeWeaponsAndMagazinesCargo.sqf @@ -108,14 +108,19 @@ _normalItems = _normalItems - ["soldItem"]; if (count _vehInfo > 0) then { - { - if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"]) then { - if (str(getNumber(configFile >> "CfgWeapons" >> _x >> "keyid")) == _keyID) then { - _weaps set [count _weaps, _x]; - _deleteVeh = True; + if (!((_vehInfo select 4) in ["trade_any_bicycle", "trade_any_bicycle_old", "trade_any_vehicle_free"])) then { + { + if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"]) then { + if (str(getNumber(configFile >> "CfgWeapons" >> _x >> "keyid")) == _keyID) then { + _weaps set [count _weaps, _x]; + _deleteVeh = True; + }; }; - }; - } count _normalWeaps; + } count _normalWeaps; + if (_keyID == "0") then {_deleteVeh = True;}; + } else { + _deleteVeh = True; + }; }; {