mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-14 04:02:37 +03:00
Adv. Trading handle other and free vehicle types
Allow players to sell vehicles without keys and add boat and bike trading classes to buy/sell
This commit is contained in:
@@ -36,7 +36,7 @@ if (Z_SingleCurrency) then {
|
|||||||
_backpacksToBuy = _backpacksToBuy + (_x select 9) ;
|
_backpacksToBuy = _backpacksToBuy + (_x select 9) ;
|
||||||
_priceToBuy = _priceToBuy + ((_x select 9)*(_x select 2)); // _price * _amount
|
_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) ;
|
_vehiclesToBuy = _vehiclesToBuy + (_x select 9) ;
|
||||||
_priceToBuy = _priceToBuy + ((_x select 9)*(_x select 2)); // _price * _amount
|
_priceToBuy = _priceToBuy + ((_x select 9)*(_x select 2)); // _price * _amount
|
||||||
};
|
};
|
||||||
@@ -65,7 +65,7 @@ if (Z_SingleCurrency) then {
|
|||||||
_backpacksToBuy = _backpacksToBuy + (_x select 9) ;
|
_backpacksToBuy = _backpacksToBuy + (_x select 9) ;
|
||||||
_priceToBuy = _priceToBuy + ((_x select 11)*(_x select 2)*(_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) ;
|
_vehiclesToBuy = _vehiclesToBuy + (_x select 9) ;
|
||||||
_priceToBuy = _priceToBuy + ((_x select 11)*(_x select 2)*(_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];
|
_backpack addMagazineCargoGlobal [_x select 0, _x select 9];
|
||||||
diag_log format ["%1 x %2 added", _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;
|
_item2Add = (_x select 0) call _buyVehicle;
|
||||||
if (_item2Add != "") then {
|
if (_item2Add != "") then {
|
||||||
_backpack addWeaponCargoGlobal [_item2Add, 1];
|
_backpack addWeaponCargoGlobal [_item2Add, 1];
|
||||||
@@ -159,7 +159,7 @@ if(_enoughMoney) then {
|
|||||||
Z_vehicle addBackpackCargoGlobal [_x select 0, _x select 9];
|
Z_vehicle addBackpackCargoGlobal [_x select 0, _x select 9];
|
||||||
diag_log format ["%1 x %2 added", _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;
|
_item2Add = (_x select 0) call _buyVehicle;
|
||||||
if (_item2Add != "") then {
|
if (_item2Add != "") then {
|
||||||
Z_vehicle addWeaponCargoGlobal [_item2Add, 1];
|
Z_vehicle addWeaponCargoGlobal [_item2Add, 1];
|
||||||
@@ -191,7 +191,7 @@ if(_enoughMoney) then {
|
|||||||
if( _x select 1 == "trade_backpacks")then{
|
if( _x select 1 == "trade_backpacks")then{
|
||||||
player addBackpack (_x select 0);
|
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;
|
_item2Add = (_x select 0) call _buyVehicle;
|
||||||
if (_item2Add != "") then {
|
if (_item2Add != "") then {
|
||||||
player addWeapon _item2Add;
|
player addWeapon _item2Add;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ _counter = 0;
|
|||||||
_pic = getText (configFile >> 'CfgWeapons' >> _y >> 'picture');
|
_pic = getText (configFile >> 'CfgWeapons' >> _y >> 'picture');
|
||||||
_text = getText (configFile >> 'CfgWeapons' >> _y >> 'displayName');
|
_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');
|
_pic = getText (configFile >> 'CfgVehicles' >> _y >> 'picture');
|
||||||
_text = getText (configFile >> 'CfgVehicles' >> _y >> 'displayName');
|
_text = getText (configFile >> 'CfgVehicles' >> _y >> 'displayName');
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -27,14 +27,18 @@ _HasKeyCheck = {
|
|||||||
_inventory = _this select 1;
|
_inventory = _this select 1;
|
||||||
_keyFound = false;
|
_keyFound = false;
|
||||||
_objectCharacterId = _obj getVariable ["CharacterID","0"];
|
_objectCharacterId = _obj getVariable ["CharacterID","0"];
|
||||||
_keyColor = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"];
|
if (_objectCharacterId == "0") then {
|
||||||
{
|
_keyFound = true;
|
||||||
if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in _keyColor) then {
|
} else {
|
||||||
if (str(getNumber(configFile >> "CfgWeapons" >> _x >> "keyid")) == _objectCharacterId) then {
|
_keyColor = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"];
|
||||||
_keyFound = true;
|
{
|
||||||
|
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;
|
_keyFound;
|
||||||
};
|
};
|
||||||
_totalPrice = 0;
|
_totalPrice = 0;
|
||||||
@@ -62,7 +66,7 @@ if(_total > 0)then{
|
|||||||
_pic = getText (configFile >> 'CfgWeapons' >> _y >> 'picture');
|
_pic = getText (configFile >> 'CfgWeapons' >> _y >> 'picture');
|
||||||
_text = getText (configFile >> 'CfgWeapons' >> _y >> 'displayName');
|
_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');
|
_pic = getText (configFile >> 'CfgVehicles' >> _y >> 'picture');
|
||||||
_text = getText (configFile >> 'CfgVehicles' >> _y >> 'displayName');
|
_text = getText (configFile >> 'CfgVehicles' >> _y >> 'displayName');
|
||||||
@@ -74,7 +78,9 @@ if(_total > 0)then{
|
|||||||
};
|
};
|
||||||
_HasKey = true;
|
_HasKey = true;
|
||||||
if (_vehTrade && {(typeOf Z_vehicle) == _y}) then {
|
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 {};
|
if (!_HasKey) exitWith {};
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ switch (true) do {
|
|||||||
{
|
{
|
||||||
[_item] call Z_displayBackpackInfo;
|
[_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;
|
[_item] call Z_displayVehicleInfo;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,16 +16,20 @@ if(_index > -1)then{
|
|||||||
|
|
||||||
_deleteTradedVehicle = {
|
_deleteTradedVehicle = {
|
||||||
private ["_localResult2","_VehKey2"];
|
private ["_localResult2","_VehKey2"];
|
||||||
_VehKey2 = _this select 0;
|
_VehKey2 = (_this select 0) select 0;
|
||||||
|
_delType = _this select 1;
|
||||||
if ((count _VehKey2) > 0) then {
|
if ((count _VehKey2) > 0) then {
|
||||||
{
|
if ((_VehKey2 select 0) == "0" || _delType 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 {
|
_localResult2 = 1;
|
||||||
if (str(getNumber(configFile >> "CfgWeapons" >> _x >> "keyid")) == (_VehKey2 select 0)) then {
|
} else {
|
||||||
_localResult2 = [player,_x,1] call BIS_fnc_invRemove;
|
{
|
||||||
|
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 {
|
if (isNil "_localResult2") then {
|
||||||
_localResult2 = 0;
|
_localResult2 = 0;
|
||||||
} else {
|
} else {
|
||||||
@@ -40,7 +44,8 @@ if(_index > -1)then{
|
|||||||
};
|
};
|
||||||
_sellVehicle = {
|
_sellVehicle = {
|
||||||
private ["_distance","_damage","_tireDmg","_tires","_okToSell","_returnInfo","_textPartIn","_obj","_hitpoints","_objectID","_objectUID","_objectCharacterId","_notSetup","_part_in","_qty_in","_activatingPlayer","_objects","_qty","_vehicle"];
|
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;
|
_part_in = typeOf _vehicle;
|
||||||
_qty_in = 1;
|
_qty_in = 1;
|
||||||
_activatingPlayer = player;
|
_activatingPlayer = player;
|
||||||
@@ -50,22 +55,23 @@ if(_index > -1)then{
|
|||||||
_qty = ({(typeOf _x) == _part_in} count _objects);
|
_qty = ({(typeOf _x) == _part_in} count _objects);
|
||||||
if (_qty >= _qty_in) then {
|
if (_qty >= _qty_in) then {
|
||||||
_obj = (_objects select 0);
|
_obj = (_objects select 0);
|
||||||
_hitpoints = _obj call vehicle_getHitpoints;
|
|
||||||
_okToSell = true;
|
_okToSell = true;
|
||||||
_tires = 0;
|
_tires = 0;
|
||||||
_tireDmg = 0;
|
_tireDmg = 0;
|
||||||
_damage = 0;
|
_damage = 0;
|
||||||
|
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;
|
if(["Wheel",_x,false] call fnc_inString) then {
|
||||||
_tireDmg = _tireDmg + _damage;
|
_damage = [_obj,_x] call object_getHit;
|
||||||
_tires = _tires + 1;
|
_tireDmg = _tireDmg + _damage;
|
||||||
};
|
_tires = _tires + 1;
|
||||||
} forEach _hitpoints;
|
};
|
||||||
if(_tireDmg > 0 && _tires > 0) then {
|
} forEach _hitpoints;
|
||||||
if((_tireDmg / _tires) > 0.75) then {
|
if(_tireDmg > 0 && _tires > 0) then {
|
||||||
_okToSell = false;
|
if((_tireDmg / _tires) > 0.75) then {
|
||||||
|
_okToSell = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
_objectID = _obj getVariable ["ObjectID","0"];
|
_objectID = _obj getVariable ["ObjectID","0"];
|
||||||
@@ -75,7 +81,7 @@ if(_index > -1)then{
|
|||||||
|
|
||||||
if(local _obj && !isNull _obj && alive _obj && !_notSetup) then {
|
if(local _obj && !isNull _obj && alive _obj && !_notSetup) then {
|
||||||
if(_okToSell) then {
|
if(_okToSell) then {
|
||||||
_returnInfo = [_objectCharacterId, _obj, _objectID, _objectUID];
|
_returnInfo = [_objectCharacterId, _obj, _objectID, _objectUID, _sellType];
|
||||||
} else {
|
} else {
|
||||||
systemChat format[localize "str_epoch_player_182",_textPartIn]; _returnInfo = [];
|
systemChat format[localize "str_epoch_player_182",_textPartIn]; _returnInfo = [];
|
||||||
};
|
};
|
||||||
@@ -106,10 +112,10 @@ if(_index > -1)then{
|
|||||||
_bpArray set [count(_bpArray),_name];
|
_bpArray set [count(_bpArray),_name];
|
||||||
_bpCheckArray set [count(_bpCheckArray),[_x select 2, _x select 11]];
|
_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 {
|
if (local Z_vehicle) then {
|
||||||
_VehKey = Z_vehicle call _sellVehicle;
|
_VehKey = [Z_vehicle, _type] call _sellVehicle;
|
||||||
if (count _VehKey > 0) then {
|
if (count _VehKey > 0) then {
|
||||||
_vehArray set [count(_vehArray),_VehKey];
|
_vehArray set [count(_vehArray),_VehKey];
|
||||||
_vehCheckArray set [count(_vehCheckArray),[_x select 2, _x select 11]];
|
_vehCheckArray set [count(_vehCheckArray),[_x select 2, _x select 11]];
|
||||||
@@ -136,8 +142,8 @@ if(_index > -1)then{
|
|||||||
_vehTraded = false;
|
_vehTraded = false;
|
||||||
|
|
||||||
{
|
{
|
||||||
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 {
|
||||||
_localResult = _vehArray call _deleteTradedVehicle;
|
_localResult = [_vehArray, (_x select 1)] call _deleteTradedVehicle;
|
||||||
if (_localResult == 1) then {_vehTraded = true;};
|
if (_localResult == 1) then {_vehTraded = true;};
|
||||||
} else {
|
} else {
|
||||||
_localResult = [player,(_x select 0),1] call BIS_fnc_invRemove;
|
_localResult = [player,(_x select 0),1] call BIS_fnc_invRemove;
|
||||||
|
|||||||
@@ -108,14 +108,19 @@ _normalItems = _normalItems - ["soldItem"];
|
|||||||
|
|
||||||
|
|
||||||
if (count _vehInfo > 0) then {
|
if (count _vehInfo > 0) then {
|
||||||
{
|
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 {
|
if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"]) then {
|
||||||
_weaps set [count _weaps, _x];
|
if (str(getNumber(configFile >> "CfgWeapons" >> _x >> "keyid")) == _keyID) then {
|
||||||
_deleteVeh = True;
|
_weaps set [count _weaps, _x];
|
||||||
|
_deleteVeh = True;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
} count _normalWeaps;
|
||||||
} count _normalWeaps;
|
if (_keyID == "0") then {_deleteVeh = True;};
|
||||||
|
} else {
|
||||||
|
_deleteVeh = True;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user