mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-14 20:13:13 +03:00
Advanced trading modifications, maintain_area modifications (#1780)
* Advanced trading modifications, maintain_area modifications
This lot of changes brings forth the following:
Sets up a "default" set of compiles that are the minimum needed for
maintain_area.sqf and custom scripts to utilize the gem based currency
that @icomrade added.
maintain_area.sqf: This will now utilize the gem based currency system.
Removed the redundant Z_Vehicle and replaced it with the Epoch built in
DZE_myVehicle
z_at_buyItems: Code tidying and optimization
z_at_checkCloseVehicle: Tidied up the code since removing Z_Vehicle
allowed us to remove some now useless code.
z_at_getVehicleItems: Removed the nearestObjects check for your vehicle
since we now do z_checkCloseVehicle on Advanced trading start up.
* Advanced trading missed redundant variables
As per description
* Advanced trading rework
We don't need to check for close vehicle anymore now for backpack money
since we've made z_vehicle redundant.
* Revert "Advanced trading rework"
This reverts commit a589bd19b9.
* Advanced trading rework
We don't need to check for close vehicle anymore now for backpack money
since we've made z_vehicle redundant.
* Advanced trading rework
More rework
* Remove single currency add/remove coins functions
at request of @ebaydayz.
This commit is contained in:
@@ -38,7 +38,7 @@ if ((count _VehKey2) > 0) then {
|
||||
};
|
||||
};
|
||||
};
|
||||
_vehicle = Z_vehicle;
|
||||
_vehicle = DZE_myVehicle;
|
||||
if (count _this > 2 && {isNull _vehicle}) then {
|
||||
_vehicle = _this select 2;
|
||||
};
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
private ["_player","_amount","_wealth","_newwealth", "_result"];
|
||||
|
||||
_player = _this select 0;
|
||||
_amount = _this select 1;
|
||||
_result = false;
|
||||
_wealth = _player getVariable[Z_MoneyVariable,0];
|
||||
_player setVariable[Z_MoneyVariable,_wealth + _amount, true];
|
||||
// can't use (magazines _player), server_playerSync expects nested array with ammo counts from player_countMagazines
|
||||
// also fourth parameter in PVDZ_plr_Save is now used for achievements
|
||||
if (_player == player) then {call player_forceSave;};
|
||||
_player setVariable ["moneychanged",1,true];
|
||||
_newwealth = _player getVariable[Z_MoneyVariable,0];
|
||||
if (_newwealth >= _wealth) then { _result = true; };
|
||||
|
||||
_result
|
||||
@@ -1,23 +0,0 @@
|
||||
private ["_player","_amount","_wealth","_newwealth", "_result"];
|
||||
|
||||
_player = _this select 0;
|
||||
_amount = _this select 1;
|
||||
_result = false;
|
||||
_wealth = _player getVariable[Z_MoneyVariable,0];
|
||||
if (_amount > 0) then {
|
||||
if (_wealth < _amount) then {
|
||||
_result = false;
|
||||
} else {
|
||||
_newwealth = _wealth - _amount;
|
||||
_player setVariable[Z_MoneyVariable,_newwealth, true];
|
||||
_player setVariable ["moneychanged",1,true];
|
||||
_result = true;
|
||||
// can't use (magazines _player), server_playerSync expects nested array with ammo counts from player_countMagazines
|
||||
// also fourth parameter in PVDZ_plr_Save is now used for achievements
|
||||
if (_player == player) then { call player_forceSave; };
|
||||
};
|
||||
} else {
|
||||
_result = true;
|
||||
};
|
||||
|
||||
_result
|
||||
@@ -105,8 +105,8 @@ if (_selection == 2) then { //gear
|
||||
};
|
||||
|
||||
if (_selection == 1) then { //vehicle
|
||||
if (!isNull Z_vehicle) then {
|
||||
_freeSpace = [Z_vehicle,0,0,0,0] call Z_calcFreeSpace;
|
||||
if (!isNull DZE_myVehicle) then {
|
||||
_freeSpace = [DZE_myVehicle,0,0,0,0] call Z_calcFreeSpace;
|
||||
_allowedMags = _freeSpace select 1;
|
||||
_allowedWeapons = _freeSpace select 2;
|
||||
_allowedBackpacks = _freeSpace select 3;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
private ["_activatingPlayer","_bTotal","_backpack","_backpacksToBuy","_buyVehicle","_buyingType","_canBuy","_count","_dir","_enoughMoney","_hasPrimary","_helipad","_isKeyOK","_item2Add","_itemsToLog","_keyColor","_keyNumber","_keySelected","_location","_moneyInfo","_myMoney","_parentClasses","_part_out","_pistolMagsToBuy","_priceToBuy","_primaryToBuy","_regularMagsToBuy","_sidearmToBuy","_sign","_success","_tCost","_toolAmounts","_toolClasses","_toolsToBuy","_vehiclesToBuy","_weaponsToBuy"];
|
||||
private ["_activatingPlayer","_bTotal","_backpack","_backpacksToBuy","_buyVehicle","_buyingType","_canBuy","_count","_dir","_enoughMoney","_hasPrimary","_helipad","_isKeyOK","_item2Add","_itemsToLog","_keyColor","_keyNumber","_keySelected","_location","_moneyInfo","_wealth","_parentClasses","_part_out","_pistolMagsToBuy","_priceToBuy","_primaryToBuy","_regularMagsToBuy","_sidearmToBuy","_sign","_success","_tCost","_toolAmounts","_toolClasses","_toolsToBuy","_vehiclesToBuy","_weaponsToBuy"];
|
||||
|
||||
if (count Z_BuyingArray < 1) exitWith { systemChat localize "STR_EPOCH_TRADE_BUY_NO_ITEMS"; };
|
||||
|
||||
@@ -42,11 +42,11 @@ if (Z_SingleCurrency) then {
|
||||
_priceToBuy = _priceToBuy + ((_x select 9)*(_x select 2));
|
||||
};
|
||||
if (_x select 1 == "trade_backpacks") then {
|
||||
_backpacksToBuy = _backpacksToBuy + (_x select 9) ;
|
||||
_backpacksToBuy = _backpacksToBuy + (_x select 9);
|
||||
_priceToBuy = _priceToBuy + ((_x select 9)*(_x select 2));
|
||||
};
|
||||
if ((_x select 1) in DZE_tradeVehicle) then {
|
||||
_vehiclesToBuy = _vehiclesToBuy + (_x select 9) ;
|
||||
_vehiclesToBuy = _vehiclesToBuy + (_x select 9);
|
||||
_priceToBuy = _priceToBuy + ((_x select 9)*(_x select 2));
|
||||
};
|
||||
_itemsToLog set [0, (_itemsToLog select 0) + [_x select 0]];
|
||||
@@ -80,11 +80,11 @@ if (Z_SingleCurrency) then {
|
||||
_priceToBuy = _priceToBuy + ((_x select 11) *(_x select 2)*(_x select 9));
|
||||
};
|
||||
if (_x select 1 == "trade_backpacks") then {
|
||||
_backpacksToBuy = _backpacksToBuy + (_x select 9) ;
|
||||
_backpacksToBuy = _backpacksToBuy + (_x select 9);
|
||||
_priceToBuy = _priceToBuy + ((_x select 11)*(_x select 2)*(_x select 9));
|
||||
};
|
||||
if ((_x select 1) in DZE_tradeVehicle) then {
|
||||
_vehiclesToBuy = _vehiclesToBuy + (_x select 9) ;
|
||||
_vehiclesToBuy = _vehiclesToBuy + (_x select 9);
|
||||
_priceToBuy = _priceToBuy + ((_x select 11)*(_x select 2)*(_x select 9));
|
||||
};
|
||||
_itemsToLog set [0, (_itemsToLog select 0) + [_x select 0]];
|
||||
@@ -96,18 +96,14 @@ if (Z_SingleCurrency) then {
|
||||
_canBuy = [_weaponsToBuy,[_pistolMagsToBuy,_regularMagsToBuy],_backpacksToBuy,_toolsToBuy,_sidearmToBuy,_primaryToBuy,_vehiclesToBuy,_toolClasses,_toolAmounts] call Z_allowBuying;
|
||||
if (!_canBuy) exitWith {}; // Keep systemChat reasons for failure in Z_allowBuying for sanity
|
||||
|
||||
_myMoney = player getVariable[Z_MoneyVariable,0];
|
||||
_wealth = player getVariable[Z_MoneyVariable,0];
|
||||
|
||||
_enoughMoney = false;
|
||||
|
||||
_moneyInfo = [false, [], [], [], 0];
|
||||
|
||||
if (Z_SingleCurrency) then {
|
||||
if (_myMoney >= _priceToBuy) then {
|
||||
_enoughMoney = true;
|
||||
} else {
|
||||
_enoughMoney = false;
|
||||
};
|
||||
_enoughMoney = if (_wealth >= _priceToBuy) then { true } else { false };
|
||||
} else {
|
||||
_moneyInfo = _priceToBuy call Z_canAfford;
|
||||
_enoughMoney = _moneyInfo select 0;
|
||||
@@ -157,7 +153,6 @@ if (_enoughMoney) then {
|
||||
publicVariableServer "PVDZE_veh_Publish2";
|
||||
_keySelected;
|
||||
};
|
||||
//systemChat localize "STR_EPOCH_PLAYER_105"; // "Stand still to complete trade". Medic animation loop no longer used.
|
||||
|
||||
closeDialog 2;
|
||||
_item2Add = "0";
|
||||
@@ -189,26 +184,26 @@ if (_enoughMoney) then {
|
||||
if (Z_SellingFrom == 1) then { //vehicle
|
||||
{
|
||||
if (_x select 1 == "trade_weapons") then {
|
||||
Z_vehicle addWeaponCargoGlobal [_x select 0, _x select 9];
|
||||
DZE_myVehicle addWeaponCargoGlobal [_x select 0, _x select 9];
|
||||
};
|
||||
if (_x select 1 == "trade_items") then {
|
||||
Z_vehicle addMagazineCargoGlobal [_x select 0, _x select 9];
|
||||
DZE_myVehicle addMagazineCargoGlobal [_x select 0, _x select 9];
|
||||
};
|
||||
if (_x select 1 == "trade_backpacks") then {
|
||||
Z_vehicle addBackpackCargoGlobal [_x select 0, _x select 9];
|
||||
DZE_myVehicle addBackpackCargoGlobal [_x select 0, _x select 9];
|
||||
};
|
||||
if ((_x select 1) in DZE_tradeVehicle) then {
|
||||
_item2Add = [(_x select 0), (_x select 1)] call _buyVehicle;
|
||||
if (_item2Add != "0") then {
|
||||
Z_vehicle addWeaponCargoGlobal [_item2Add, 1];
|
||||
DZE_myVehicle addWeaponCargoGlobal [_item2Add, 1];
|
||||
};
|
||||
};
|
||||
_bTotal = _bTotal + (_x select 9);
|
||||
} count Z_BuyingArray;
|
||||
if (_item2Add != "0") then {
|
||||
systemChat format[localize "STR_EPOCH_TRADE_BUY_VEH_IN_VEHICLE",(Z_BuyingArray select 0) select 3,typeOf (Z_vehicle)];
|
||||
systemChat format[localize "STR_EPOCH_TRADE_BUY_VEH_IN_VEHICLE",(Z_BuyingArray select 0) select 3,typeOf (DZE_myVehicle)];
|
||||
} else {
|
||||
systemChat format[localize "STR_EPOCH_TRADE_BUY_IN_VEHICLE",_bTotal,typeOf Z_vehicle];
|
||||
systemChat format[localize "STR_EPOCH_TRADE_BUY_IN_VEHICLE",_bTotal,typeOf DZE_myVehicle];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -217,7 +212,7 @@ if (_enoughMoney) then {
|
||||
if (_x select 1 == "trade_weapons") then {
|
||||
_count = 0;
|
||||
while {_count < (_x select 9)} do {
|
||||
_hasPrimary = if (primaryWeapon player != "") then {true} else {false};
|
||||
_hasPrimary = if (primaryWeapon player != "") then {true} else {false};
|
||||
if (_hasPrimary && getNumber (configFile >> "CfgWeapons" >> (_x select 0) >> "type") == 1) then {
|
||||
dayz_onBack = _x select 0; //Add to back
|
||||
} else {
|
||||
@@ -250,29 +245,29 @@ if (_enoughMoney) then {
|
||||
systemChat format[localize "STR_EPOCH_TRADE_BUY_IN_GEAR",_bTotal];
|
||||
};
|
||||
};
|
||||
if (!Z_SingleCurrency) then {
|
||||
_success = [player,_priceToBuy,_moneyInfo,false,0] call Z_payDefault;
|
||||
if (_success) then {
|
||||
|
||||
_success = if (Z_SingleCurrency) then {_priceToBuy <= _wealth} else {[player,_priceToBuy,_moneyInfo,false,0] call Z_payDefault};
|
||||
|
||||
if (_success) then {
|
||||
if (Z_SingleCurrency) then {
|
||||
player setVariable[Z_MoneyVariable,(_wealth - _priceToBuy),true];
|
||||
systemChat format[localize "STR_EPOCH_TRADE_SUCCESS_COINS",[_priceToBuy] call BIS_fnc_numberText,CurrencyName];
|
||||
} else {
|
||||
_tCost = "";
|
||||
_tCost = _priceToBuy call z_calcDefaultCurrencyNoImg;
|
||||
if (_tCost != "") then { systemChat format[localize "STR_EPOCH_TRADE_BUY_SUCCESS",_tCost]; };
|
||||
} else {
|
||||
systemChat localize "STR_EPOCH_TRADE_DEBUG";
|
||||
};
|
||||
} else {
|
||||
_success = [player,_priceToBuy] call SC_fnc_removeCoins;
|
||||
if (_success) then {
|
||||
systemChat format[localize "STR_EPOCH_TRADE_SUCCESS_COINS",[_priceToBuy] call BIS_fnc_numberText,CurrencyName];
|
||||
} else {
|
||||
systemChat localize "STR_EPOCH_TRADE_DEBUG";
|
||||
};
|
||||
systemChat localize "STR_EPOCH_TRADE_DEBUG";
|
||||
};
|
||||
|
||||
_itemsToLog call Z_logTrade;
|
||||
call player_forceSave;
|
||||
if (Z_SellingFrom == 1) then {
|
||||
PVDZ_veh_Save = [Z_vehicle,"gear"];
|
||||
PVDZ_veh_Save = [DZE_myVehicle,"gear"];
|
||||
publicVariableServer "PVDZ_veh_Save";
|
||||
};
|
||||
|
||||
} else {
|
||||
if (Z_SingleCurrency) then {
|
||||
systemChat format[localize "STR_EPOCH_TRADE_NEED_COINS",[_priceToBuy] call BIS_fnc_numberText,CurrencyName];
|
||||
|
||||
@@ -58,8 +58,8 @@ if (Z_AllowTakingMoneyFromBackpack) then {
|
||||
};
|
||||
|
||||
if (Z_AllowTakingMoneyFromVehicle) then {
|
||||
if (!isNull Z_vehicle) then {
|
||||
_mags = getMagazineCargo Z_vehicle;
|
||||
if (!isNull DZE_myVehicle) then {
|
||||
_mags = getMagazineCargo DZE_myVehicle;
|
||||
_vehicleMoney = [];
|
||||
_kinds = _mags select 0;
|
||||
_amounts = _mags select 1;
|
||||
|
||||
@@ -19,8 +19,8 @@ _vehTrade = false;
|
||||
_vehUpgraded = "";
|
||||
|
||||
if (false call Z_checkCloseVehicle) then {
|
||||
_vehUpgraded = getText (configFile >> 'CfgVehicles' >> typeOf (Z_vehicle) >> 'original');
|
||||
_all = _weaps + _mags + _bags + [(typeOf Z_vehicle)];
|
||||
_vehUpgraded = getText (configFile >> 'CfgVehicles' >> typeOf (DZE_myVehicle) >> 'original');
|
||||
_all = _weaps + _mags + _bags + [(typeOf DZE_myVehicle)];
|
||||
_vehTrade = true;
|
||||
} else {
|
||||
_all = _weaps + _mags + _bags;
|
||||
@@ -56,7 +56,7 @@ _totalPrice = 0;
|
||||
if (isNumber (missionConfigFile >> "CfgTraderCategory" >> _cat >> "duplicate")) then {
|
||||
_cat = format["Category_%1",getNumber (missionConfigFile >> "CfgTraderCategory" >> _cat >> "duplicate")];
|
||||
};
|
||||
if (_vehUpgraded != "" && _y == (typeOf Z_vehicle)) then { _y = _vehUpgraded; };
|
||||
if (_vehUpgraded != "" && _y == (typeOf DZE_myVehicle)) then { _y = _vehUpgraded; };
|
||||
_exists = isClass(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y);
|
||||
if (_exists) exitWith {
|
||||
_pic = "";
|
||||
@@ -84,9 +84,9 @@ _totalPrice = 0;
|
||||
|
||||
if (isNil '_text') then { _text = _y; };
|
||||
_HasKey = true;
|
||||
if (_vehTrade && {(typeOf Z_vehicle) == _y}) then {
|
||||
if (_vehTrade && {(typeOf DZE_myVehicle) == _y}) then {
|
||||
if (!(_type in DZE_tradeVehicleKeyless) && DZE_SaleRequiresKey) then {
|
||||
_HasKey = [Z_vehicle, _all] call _HasKeyCheck;
|
||||
_HasKey = [DZE_myVehicle, _all] call _HasKeyCheck;
|
||||
};
|
||||
};
|
||||
if (!_HasKey) exitWith {};
|
||||
|
||||
@@ -1,25 +1,17 @@
|
||||
private ["_vehicle","_list","_result","_pos"];
|
||||
private ["_list","_result","_pos"];
|
||||
|
||||
Z_vehicle = objNull;
|
||||
_vehicle = objNull;
|
||||
_result = false;
|
||||
_pos = [player] call FNC_GetPos;
|
||||
_list = nearestObjects [_pos, ["Air","LandVehicle","Ship"], Z_VehicleDistance];
|
||||
|
||||
if (!isNull DZE_myVehicle && local DZE_myVehicle && alive DZE_myVehicle && DZE_myVehicle in _list) then {
|
||||
_vehicle = DZE_myVehicle;
|
||||
};
|
||||
|
||||
_result = false;
|
||||
|
||||
if (!isNull _vehicle) then {
|
||||
Z_vehicle = _vehicle;
|
||||
if (!isNull DZE_myVehicle && {local DZE_myVehicle} && {alive DZE_myVehicle} && {DZE_myVehicle in _list}) then {
|
||||
_result = true;
|
||||
if (_this) then { // Set trade title, don't set on menu start up since gear is selected initially.
|
||||
systemChat format[localize "STR_EPOCH_TRADE_SELECTED",typeOf Z_vehicle];
|
||||
systemChat format[localize "STR_EPOCH_TRADE_SELECTED",typeOf DZE_myVehicle];
|
||||
if (Z_Selling) then {
|
||||
[format[localize "STR_EPOCH_TRADE_SELLING_FROM", typeOf Z_vehicle]] call Z_fillTradeTitle;
|
||||
[format[localize "STR_EPOCH_TRADE_SELLING_FROM", typeOf DZE_myVehicle]] call Z_fillTradeTitle;
|
||||
} else {
|
||||
[format[localize "STR_EPOCH_TRADE_BUYING_IN", typeOf Z_vehicle]] call Z_fillTradeTitle;
|
||||
[format[localize "STR_EPOCH_TRADE_BUYING_IN", typeOf DZE_myVehicle]] call Z_fillTradeTitle;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -45,13 +45,13 @@ if (_selection == 1) then { //vehicle
|
||||
_allowedWeapons = 0;
|
||||
_allowedBackpacks = 0;
|
||||
|
||||
if (!isNull Z_vehicle) then {
|
||||
_freeSpace = [Z_vehicle,0,0,0,0] call Z_calcFreeSpace;
|
||||
if (!isNull DZE_myVehicle) then {
|
||||
_freeSpace = [DZE_myVehicle,0,0,0,0] call Z_calcFreeSpace;
|
||||
_allowedMags = _freeSpace select 1;
|
||||
_allowedWeapons = _freeSpace select 2;
|
||||
_allowedBackpacks = _freeSpace select 3;
|
||||
|
||||
_pic = getText (configFile >> "CfgVehicles" >> (typeOf Z_vehicle) >> "picture");
|
||||
_pic = getText (configFile >> "CfgVehicles" >> (typeOf DZE_myVehicle) >> "picture");
|
||||
|
||||
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_CONTAINERINFO) ctrlSetStructuredText parseText format [
|
||||
"<img image='%1' size='3' align='center'/>"
|
||||
|
||||
@@ -12,7 +12,7 @@ _typeOf = typeOf (unitBackPack player);
|
||||
_type = _x select 1;
|
||||
_count = 0;
|
||||
|
||||
if (_type in DZE_tradeVehicle && {_name == typeOf Z_vehicle}) then {
|
||||
if (_type in DZE_tradeVehicle && {_name == typeOf DZE_myVehicle}) then {
|
||||
_count = 1;
|
||||
};
|
||||
if (_type == "trade_items") then {
|
||||
|
||||
@@ -3,24 +3,15 @@
|
||||
*
|
||||
* Gets all your items stored in your vehicle and initiates the selling list.
|
||||
**/
|
||||
private ["_vehicle","_pos","_list","_formattedText","_pic","_normalMags","_normalWeaps","_freeSpace"];
|
||||
private ["_formattedText","_pic","_normalMags","_normalWeaps","_freeSpace"];
|
||||
#include "defines.hpp"
|
||||
|
||||
Z_vehicle = objNull;
|
||||
call Z_clearLists;
|
||||
Z_SellableArray = [];
|
||||
Z_SellArray = [];
|
||||
_vehicle = objNull;
|
||||
|
||||
_pos = [player] call FNC_GetPos;
|
||||
_list = nearestObjects [_pos, ["Air","LandVehicle","Ship"], Z_VehicleDistance];
|
||||
|
||||
if (!isNull DZE_myVehicle && local DZE_myVehicle && alive DZE_myVehicle && DZE_myVehicle in _list) then {
|
||||
_vehicle = DZE_myVehicle;
|
||||
};
|
||||
|
||||
if (!isNull _vehicle) then {
|
||||
_pic = getText (configFile >> 'CfgVehicles' >> (typeOf _vehicle) >> 'picture');
|
||||
if (!isNull DZE_myVehicle) then {
|
||||
_pic = getText (configFile >> 'CfgVehicles' >> (typeOf DZE_myVehicle) >> 'picture');
|
||||
|
||||
_formattedText = format [
|
||||
"<img image='%1' size='3' align='center'/>"
|
||||
@@ -28,13 +19,12 @@ if (!isNull _vehicle) then {
|
||||
];
|
||||
|
||||
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_CONTAINERINFO) ctrlSetStructuredText parseText _formattedText;
|
||||
Z_vehicle = _vehicle;
|
||||
_freeSpace = [_vehicle,0,0,0,0] call Z_calcFreeSpace;
|
||||
_freeSpace = [DZE_myVehicle,0,0,0,0] call Z_calcFreeSpace;
|
||||
_normalMags = _freeSpace select 5;
|
||||
_normalWeaps = _freeSpace select 6;
|
||||
//_normalBags = _freeSpace select 7;
|
||||
// Don't allow selling backpacks from vehicles because we can not get backpack contents.
|
||||
// We can only remove all backpacks with clearBackpackCargo and then add back new empty backpacks for ones that weren't sold.
|
||||
|
||||
[_normalWeaps,_normalMags,typeOf _vehicle,[]] call Z_checkArrayInConfig;
|
||||
[_normalWeaps,_normalMags,typeOf DZE_myVehicle,[]] call Z_checkArrayInConfig;
|
||||
};
|
||||
|
||||
@@ -20,8 +20,8 @@ if (!_justChecking) then {
|
||||
if (count _moneyInBackpack > 0) then {
|
||||
_nil = [unitBackpack _player, _moneyInBackpack, [], []] call ZUPA_fnc_removeWeaponsAndMagazinesCargo;
|
||||
};
|
||||
if (!isNull Z_vehicle && count _moneyInVehicle > 0) then {
|
||||
_nil = [Z_vehicle, _moneyInVehicle, [], []] call ZUPA_fnc_removeWeaponsAndMagazinesCargo;
|
||||
if (!isNull DZE_myVehicle && count _moneyInVehicle > 0) then {
|
||||
_nil = [DZE_myVehicle, _moneyInVehicle, [], []] call ZUPA_fnc_removeWeaponsAndMagazinesCargo;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
private ["_tempArray","_outcome","_vehCheckArray","_vehArray","_weaponsArray","_itemsArray","_bpArray","_bpCheckArray","_weaponsCheckArray","_itemsCheckArray","_VehKey","_wA","_mA","_money","_itemData","_success","_bag","_itemsToLog","_tCost","_tSold"];
|
||||
private ["_tempArray","_outcome","_vehCheckArray","_vehArray","_weaponsArray","_itemsArray","_bpArray","_bpCheckArray","_weaponsCheckArray","_itemsCheckArray","_VehKey","_wA","_mA","_money","_itemData","_success","_bag","_itemsToLog","_tCost","_tSold","_wealth"];
|
||||
|
||||
if (count Z_SellArray < 1) exitWith { systemChat localize "STR_EPOCH_TRADE_SELL_NO_ITEMS"; };
|
||||
if (Z_SellingFrom == 1 && (isNull Z_vehicle or !local Z_vehicle)) exitWith { systemChat localize "STR_EPOCH_PLAYER_245"; };
|
||||
if (Z_SellingFrom == 1 && (isNull DZE_myVehicle or !local DZE_myVehicle)) exitWith { systemChat localize "STR_EPOCH_PLAYER_245"; };
|
||||
|
||||
_tempArray = Z_SellArray;
|
||||
closeDialog 2;
|
||||
@@ -17,15 +17,14 @@ _itemsCheckArray = [];
|
||||
_itemsToLog = [[],[],[],"sell"];
|
||||
|
||||
_sellVehicle = {
|
||||
private ["_distance","_damage","_tireDmg","_tires","_okToSell","_returnInfo","_obj","_hitpoints","_objectID","_objectUID","_objectCharacterId","_notSetup","_part_in","_qty_in","_activatingPlayer","_objects","_qty","_vehicle"];
|
||||
private ["_damage","_tireDmg","_tires","_okToSell","_returnInfo","_obj","_hitpoints","_objectID","_objectUID","_objectCharacterId","_notSetup","_part_in","_qty_in","_activatingPlayer","_objects","_qty","_vehicle"];
|
||||
_vehicle = _this select 0;
|
||||
_sellType = _this select 1;
|
||||
_part_in = typeOf _vehicle;
|
||||
_qty_in = 1;
|
||||
_activatingPlayer = player;
|
||||
_distance = Z_VehicleDistance;
|
||||
_returnInfo = [];
|
||||
_objects = nearestObjects [(getPosATL player), [_part_in], _distance];
|
||||
_objects = nearestObjects [(getPosATL player), [_part_in], Z_VehicleDistance];
|
||||
_qty = ({(typeOf _x) == _part_in} count _objects);
|
||||
if (_qty >= _qty_in) then {
|
||||
_obj = (_objects select 0);
|
||||
@@ -51,17 +50,17 @@ _sellVehicle = {
|
||||
_objectID = _obj getVariable ["ObjectID","0"];
|
||||
_objectUID = _obj getVariable ["ObjectUID","0"];
|
||||
_objectCharacterId = _obj getVariable ["CharacterID","0"];
|
||||
_notSetup = (_objectID == "0" && _objectUID == "0");
|
||||
_notSetup = (_objectID == "0" && _objectUID == "0");
|
||||
|
||||
if (local _obj && !isNull _obj && alive _obj && !_notSetup) then {
|
||||
if (_okToSell) then {
|
||||
_returnInfo = [_objectCharacterId, _obj, _objectID, _objectUID, _sellType];
|
||||
} else {
|
||||
systemChat format[localize "str_epoch_player_182",typeOf _obj];
|
||||
systemChat format[localize "str_epoch_player_182",typeOf _obj];
|
||||
_returnInfo = [];
|
||||
};
|
||||
} else {
|
||||
systemChat localize "str_epoch_player_245";
|
||||
systemChat localize "str_epoch_player_245";
|
||||
_returnInfo = [];
|
||||
};
|
||||
};
|
||||
@@ -91,8 +90,8 @@ _sellVehicle = {
|
||||
};
|
||||
case (_type in DZE_tradeVehicle) :
|
||||
{
|
||||
if (local Z_vehicle) then {
|
||||
_VehKey = [Z_vehicle, _type] call _sellVehicle;
|
||||
if (local DZE_myVehicle) then {
|
||||
_VehKey = [DZE_myVehicle, _type] call _sellVehicle;
|
||||
if (count _VehKey > 0) then {
|
||||
_vehArray set [count(_vehArray),_VehKey];
|
||||
_vehCheckArray set [count(_vehCheckArray),[_x select 2, _x select 11]];
|
||||
@@ -111,11 +110,11 @@ if (Z_SellingFrom == 0) then {
|
||||
systemChat format[localize "STR_EPOCH_TRADE_SELL_IN_BACKPACK",count _tSold];
|
||||
};
|
||||
if (Z_SellingFrom == 1) then {
|
||||
_outcome = [Z_vehicle,_itemsArray,_weaponsArray,_vehArray] call ZUPA_fnc_removeWeaponsAndMagazinesCargo;
|
||||
systemChat format[localize "STR_EPOCH_TRADE_SELL_IN_VEHICLE",count _tSold,typeOf Z_vehicle];
|
||||
_outcome = [DZE_myVehicle,_itemsArray,_weaponsArray,_vehArray] call ZUPA_fnc_removeWeaponsAndMagazinesCargo;
|
||||
systemChat format[localize "STR_EPOCH_TRADE_SELL_IN_VEHICLE",count _tSold,typeOf DZE_myVehicle];
|
||||
};
|
||||
|
||||
_itemsToLog set [0,(_itemsArray + _weaponsArray + _bpArray + [typeOf Z_vehicle])];
|
||||
_itemsToLog set [0,(_itemsArray + _weaponsArray + _bpArray + [typeOf DZE_myVehicle])];
|
||||
|
||||
//gear
|
||||
if (Z_SellingFrom == 2) then {
|
||||
@@ -181,15 +180,15 @@ _money = 0;
|
||||
|
||||
if (Z_SingleCurrency) then {
|
||||
{
|
||||
_money = _money + ((((_itemsCheckArray select _forEachIndex) select 0)) * _x) ;
|
||||
_money = _money + ((((_itemsCheckArray select _forEachIndex) select 0)) * _x);
|
||||
_itemsToLog set [2, (_itemsToLog select 2) + [((((_itemsCheckArray select _forEachIndex) select 0)) * _x)]];
|
||||
} forEach (_outcome select 0);
|
||||
{
|
||||
_money = _money + ((((_weaponsCheckArray select _forEachIndex) select 0)) * _x) ;
|
||||
_money = _money + ((((_weaponsCheckArray select _forEachIndex) select 0)) * _x);
|
||||
_itemsToLog set [2, (_itemsToLog select 2) + [((((_weaponsCheckArray select _forEachIndex) select 0)) * _x)]];
|
||||
} forEach (_outcome select 1);
|
||||
{
|
||||
_money = _money + ((((_bpCheckArray select _forEachIndex) select 0)) * _x) ;
|
||||
_money = _money + ((((_bpCheckArray select _forEachIndex) select 0)) * _x);
|
||||
_itemsToLog set [2, (_itemsToLog select 2) + [((((_bpCheckArray select _forEachIndex) select 0)) * _x)]];
|
||||
} forEach (_outcome select 2);
|
||||
|
||||
@@ -222,7 +221,8 @@ if (Z_SingleCurrency) then {
|
||||
|
||||
if (typeName _money == "SCALAR") then {
|
||||
if (Z_SingleCurrency) then {
|
||||
_success = [player,_money] call SC_fnc_addCoins;
|
||||
_wealth = player getVariable[Z_MoneyVariable,0];
|
||||
player setVariable[Z_MoneyVariable,(_wealth + _money),true];
|
||||
systemChat format[localize "STR_EPOCH_TRADE_SUCCESS_CHANGE",[_money] call BIS_fnc_numberText,CurrencyName];
|
||||
} else {
|
||||
_success = [_money,0,false,0,[],[],false] call Z_returnChange;
|
||||
@@ -233,10 +233,10 @@ if (typeName _money == "SCALAR") then {
|
||||
_itemsToLog call Z_logTrade;
|
||||
call player_forceSave;
|
||||
if (Z_SellingFrom == 1) then {
|
||||
PVDZ_veh_Save = [Z_vehicle,"gear"];
|
||||
PVDZ_veh_Save = [DZE_myVehicle,"gear"];
|
||||
publicVariableServer "PVDZ_veh_Save";
|
||||
};
|
||||
} else {
|
||||
systemChat localize "STR_EPOCH_TRADE_DEBUG";
|
||||
diag_log "Money is not a number. Something went wrong.";
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user