Skip to content

Commit

Permalink
Config to make Temp Vehicles tradeable
Browse files Browse the repository at this point in the history
  • Loading branch information
He-Man authored and He-Man committed Apr 6, 2018
1 parent 8b6d609 commit 561012b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
5 changes: 3 additions & 2 deletions Sources/epoch_code/compile/traders/EPOCH_startNpcTrade.sqf
Expand Up @@ -13,12 +13,13 @@
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/compile/traders/EPOCH_startNpcTrade.sqf
*/

private ["_PlayerItemsOutBox","_TraderItemsOutBox","_config","_current_crypto","_sizeIn","_arrayIn","_item","_rounds","_mags","_itemMags","_index","_sizeOut","_arrayOut","_itemWorth","_itemTax","_tax","_maxrnd"];
private ["_EnableTempVehTrade","_PlayerItemsOutBox","_TraderItemsOutBox","_config","_current_crypto","_sizeIn","_arrayIn","_item","_rounds","_mags","_itemMags","_index","_sizeOut","_arrayOut","_itemWorth","_itemTax","_tax","_maxrnd"];

if (!isNil "EPOCH_TRADE_STARTED") exitWith{};
if (isNull _this) exitWith{};

if (alive _this) then {
_EnableTempVehTrade = ["CfgEpochClient", "EnableTempVehTrade", false] call EPOCH_fnc_returnConfigEntryV2;
_PlayerItemsOutBox = 41501;
_TraderItemsOutBox = 41502;
_config = 'CfgPricing' call EPOCH_returnConfig;
Expand Down Expand Up @@ -65,7 +66,7 @@ if (alive _this) then {
if (!isNull _vehicle) then {
if (local _vehicle) then {
_vehSlot = _vehicle getVariable["VEHICLE_SLOT", "ABORT"];
if (_vehSlot != "ABORT") then {
if (_vehSlot != "ABORT" || _EnableTempVehTrade) then {
_arrayIn pushBack [_item,_rounds];
_added = true;
};
Expand Down
2 changes: 2 additions & 0 deletions Sources/epoch_config/Configs/CfgEpochClient.hpp
Expand Up @@ -200,6 +200,8 @@ class CfgEpochClient
Fav_FastWeaponSwitching = "false"; // If enabled, same slot weapons from favorites bar are equipped instantly, otherwise reload action is played (recommended for immersion)
Fav_BannedItems[] = {"FAK"}; // Items that users are not allowed to pin

EnableTempVehTrade = "false"; // Enable selling of temp Vehicles (not handled by Epoch). Temp Vehicles will not be stored in Traders, but can be sold

// Advanced Vehicle Repair
UseAdvancedVehicleRepair = "true"; // Switch On / Off Advanced Vehicle Repair (Does not effect SuppressedCraftingItems !)
EnableRemoveParts = "true"; // Enable removing Tires / Engines from Vehicles
Expand Down
Expand Up @@ -17,12 +17,13 @@ private [ "_MaxBankDebit","_SkipOut","_VAL","_aiItems","_bankBalance","_bankData
"_group","_helipad","_helipads","_item","_itemClasses","_itemQty","_itemQtys","_itemTax","_itemWorth","_itemsIn","_itemsOut","_lockOwner","_makeTradeIn","_message","_nearByHolder",
"_objHiveKey","_objOwner","_playerCryptoLimit","_playerGroup","_playerNetID","_playerUID","_position","_qtyIndex","_response","_return","_returnIn","_returnOut","_road",
"_serverSettingsConfig","_slot","_smoke","_tax","_tmpposition","_tradeIn","_tradeOut","_tradeQtyTotal","_tradeTotal","_vars","_vehHiveKey","_vehObj","_vehSlot","_vehicle","_vehicleBought",
"_vehicleSold","_vehicles","_vehslot","_wH","_wHPos","_wp","_kIndex","_playerCStats","_playerKarma","_playerKarmaAdj"
"_vehicleSold","_vehicles","_vehslot","_wH","_wHPos","_wp","_kIndex","_playerCStats","_playerKarma","_playerKarmaAdj","_EnableTempVehTrade"
];
params ["_trader","_itemsIn","_itemsOut","_player",["_token","",[""]] ];

_playerUID = getplayeruid _player;

_EnableTempVehTrade = ["CfgEpochClient", "EnableTempVehTrade", false] call EPOCH_fnc_returnConfigEntryV2;
_serverSettingsConfig = configFile >> "CfgEpochServer";
_vehicleSold = false;
_vehicleBought = false;
Expand Down Expand Up @@ -75,21 +76,27 @@ if (_slot != -1) then {
_playerNetID = owner _player;
if (_playerNetID == (owner _vehicle)) then {
_vehSlot = _vehicle getVariable["VEHICLE_SLOT", "ABORT"];
if (!_vehicleSold && _vehSlot != "ABORT") then {
if (!_vehicleSold && (_vehSlot != "ABORT" || _EnableTempVehTrade)) then {
_vehicleSold = true;
_makeTradeIn = true;
if (_vehSlot == "ABORT") exitwith {
_itemQty = 0;
_itemsIn set [_foreachindex,[_item,_itemQty]];
removeFromRemainsCollector [_vehicle];
deleteVehicle _vehicle;
};
_BaseClass = _vehicle getvariable ["VEHICLE_BaseClass",""];
if !(_BaseClass isequalto "") then {
_item = _BaseClass;
_itemsIn set [_foreachindex,[_item,_itemQty]];
};
removeFromRemainsCollector [_vehicle];
deleteVehicle _vehicle;
_vehicleSold = true;
_vehHiveKey = format["%1:%2", (call EPOCH_fn_InstanceID), _vehSlot];
_VAL = [];
["Vehicle", _vehHiveKey, _VAL] call EPOCH_fnc_server_hiveSET;
EPOCH_VehicleSlots pushBack _vehSlot;
missionNamespace setVariable ['EPOCH_VehicleSlotCount', count EPOCH_VehicleSlots, true];
_makeTradeIn = true;
};
};
};
Expand Down

0 comments on commit 561012b

Please sign in to comment.