mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-14 20:13:13 +03:00
Fix javelin/stinger selling
The previous fix 4fa36dfd94 was not working correctly, if you had say the a stinger launcher and a stinger ammo it would detect them both as weapons, this properly classifies them and all others as how they should be.
Moved to use epoch_tempKeys also
This forces the player to only be able to sell a vehicle from the gear menu instead of backpack and vehicle menu since most of the time you would be using add all.
From: https://epochmod.com/forum/topic/44413-prevent-selling-vehicles-from-backpack/?tab=comments#comment-297328
This commit is contained in:
@@ -19,37 +19,28 @@ _vehTrade = false;
|
|||||||
_baseVehicle = "";
|
_baseVehicle = "";
|
||||||
_myVehType = typeOf DZE_myVehicle;
|
_myVehType = typeOf DZE_myVehicle;
|
||||||
|
|
||||||
if (false call Z_checkCloseVehicle) then {
|
|
||||||
_baseVehicle = getText (configFile >> "CfgVehicles" >> _myVehType >> "original");
|
|
||||||
_all = _weaps + _mags + _bags + [_myVehType];
|
|
||||||
_vehTrade = true;
|
|
||||||
} else {
|
|
||||||
_all = _weaps + _mags + _bags;
|
|
||||||
};
|
|
||||||
|
|
||||||
_arrayOfTraderCat = Z_traderData;
|
_arrayOfTraderCat = Z_traderData;
|
||||||
_HasKeyCheck = {
|
_HasKeyCheck = {
|
||||||
_obj = _this select 0;
|
private ["_objectCharacterID","_keyFound","_tempKeys"];
|
||||||
_inventory = _this select 1;
|
|
||||||
_keyFound = false;
|
_keyFound = false;
|
||||||
_objectCharacterId = _obj getVariable ["CharacterID","0"];
|
_objectCharacterId = DZE_myVehicle getVariable ["CharacterID","0"];
|
||||||
if (_objectCharacterId == "0") then {
|
if (_objectCharacterId == "0") then {
|
||||||
_keyFound = true;
|
_keyFound = true;
|
||||||
} else {
|
} else {
|
||||||
_keyColor = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"];
|
_tempKeys = call epoch_tempKeys;
|
||||||
{
|
if (((_tempKeys select 0) find _objectCharacterID) >= 0) then {_keyFound = true;};
|
||||||
if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in _keyColor) then {
|
|
||||||
if (str(getNumber(configFile >> "CfgWeapons" >> _x >> "keyid")) == _objectCharacterId) then {
|
|
||||||
_keyFound = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
} count _inventory;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
_keyFound;
|
_keyFound;
|
||||||
};
|
};
|
||||||
_totalPrice = 0;
|
_totalPrice = 0;
|
||||||
|
|
||||||
{
|
_processGear = {
|
||||||
|
private ["_array","_type","_cat","_exists","_pic","_text","_sell","_buy","_buyCurrency","_sellCurrency","_worth"];
|
||||||
|
|
||||||
|
_type = _this select 1;
|
||||||
|
{
|
||||||
_y = _x;
|
_y = _x;
|
||||||
_swap = false;
|
_swap = false;
|
||||||
_swap2 = false;
|
_swap2 = false;
|
||||||
@@ -61,7 +52,6 @@ _totalPrice = 0;
|
|||||||
_swap2 = true;
|
_swap2 = true;
|
||||||
};
|
};
|
||||||
{
|
{
|
||||||
private ["_cat","_exists","_pic","_text","_type","_sell","_buy","_buyCurrency","_sellCurrency","_worth"];
|
|
||||||
_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 {
|
if (isNumber (missionConfigFile >> "CfgTraderCategory" >> _cat >> "duplicate")) then {
|
||||||
_cat = format["Category_%1",getNumber (missionConfigFile >> "CfgTraderCategory" >> _cat >> "duplicate")];
|
_cat = format["Category_%1",getNumber (missionConfigFile >> "CfgTraderCategory" >> _cat >> "duplicate")];
|
||||||
@@ -74,9 +64,7 @@ _totalPrice = 0;
|
|||||||
if (_exists) exitWith {
|
if (_exists) exitWith {
|
||||||
_pic = "";
|
_pic = "";
|
||||||
_text = "";
|
_text = "";
|
||||||
_type = getText(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "type");
|
|
||||||
// Make sure type matches for items that have the same weapon and magazine classname (i.e. PipeBomb, Mine, Javelin, etc.)
|
|
||||||
if ((_type == "trade_items" && !(_y in _mags) && !_swap) or (_type == "trade_weapons" && !(_y in _weaps))) exitWith {};
|
|
||||||
_sell = getArray(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "sell");
|
_sell = getArray(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "sell");
|
||||||
_buy = getArray(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "buy");
|
_buy = getArray(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "buy");
|
||||||
if (_swap) then {_y = "ItemBloodbag"};
|
if (_swap) then {_y = "ItemBloodbag"};
|
||||||
@@ -102,10 +90,10 @@ _totalPrice = 0;
|
|||||||
_HasKey = true;
|
_HasKey = true;
|
||||||
if (_vehTrade && {_y == _myVehType}) then {
|
if (_vehTrade && {_y == _myVehType}) then {
|
||||||
if (!(_type in DZE_tradeVehicleKeyless) && DZE_SaleRequiresKey) then {
|
if (!(_type in DZE_tradeVehicleKeyless) && DZE_SaleRequiresKey) then {
|
||||||
_HasKey = [DZE_myVehicle, _all] call _HasKeyCheck;
|
_HasKey = call _HasKeyCheck;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
if (!_HasKey) exitWith {};
|
if (!_HasKey || {_y == _myVehType && Z_SellingFrom != 2}) exitWith {};
|
||||||
|
|
||||||
_worth = 0;
|
_worth = 0;
|
||||||
_currencyQty = _buy select 0;
|
_currencyQty = _buy select 0;
|
||||||
@@ -126,7 +114,18 @@ _totalPrice = 0;
|
|||||||
_totalPrice = _totalPrice + (_sell select 0);
|
_totalPrice = _totalPrice + (_sell select 0);
|
||||||
};
|
};
|
||||||
} forEach _arrayOfTraderCat;
|
} forEach _arrayOfTraderCat;
|
||||||
} count _all;
|
} count (_this select 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (false call Z_checkCloseVehicle) then {
|
||||||
|
_baseVehicle = getText (configFile >> "CfgVehicles" >> _myVehType >> "original");
|
||||||
|
_vehTrade = true;
|
||||||
|
[[_myVehType],"trade_any_vehicle"] call _processGear;
|
||||||
|
};
|
||||||
|
|
||||||
|
[_weaps,"trade_weapons"] call _processGear;
|
||||||
|
[_mags,"trade_items"] call _processGear;
|
||||||
|
[_bags,"trade_backpacks"] call _processGear;
|
||||||
|
|
||||||
Z_OriginalSellableArray = [] + Z_SellableArray;
|
Z_OriginalSellableArray = [] + Z_SellableArray;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user