mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2026-04-18 10:16:39 +03:00
Advanced trading fixes/modifications (#1698)
* Advanced trading fixes/modifcations This adds combine currency option to the Advanced trading screen since @Airwaves man noticed it didn't have a way of doing it. Updated stringtables with correct "paid" spelling and differing text for buying/selling. This also addds proper currency checking/reporting for the log system that has been introduced, it's untidy but it works, instead of getting "user bought x for 1000 currency" in a non coins server, it will convert it to the proper 1 brief 5 10oz gold etc system (uses a new function z_calcDefaultCurrencyNoImg) This also adds a check to see if the buy list is empty (as per the selling list) and returns text to the user informing them. Re-arranged buy and sell so buy is on top of sell, it's a bit easier to read then. * Advanced trading logging change This was missing from my previous commit, this changes the server_tradeobject to check if it's being passed a number (single currency) or text (my logging currency changes) * Advanced trading rework Fixes all problems @ebaydayz
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
private ["_magazinesToBuy", "_weaponsToBuy", "_backpacksToBuy", "_toolsToBuy", "_sidearmToBuy", "_primaryToBuy", "_priceToBuy"
|
||||
,"_enoughMoney", "_myMoney", "_canBuy", "_moneyInfo","_count","_success","_backpack","_toolClasses","_itemsToLog"
|
||||
,"_enoughMoney", "_myMoney", "_canBuy", "_moneyInfo","_count","_success","_backpack","_toolClasses","_itemsToLog","_tcost"
|
||||
];
|
||||
|
||||
_magazinesToBuy = 0;
|
||||
@@ -14,6 +14,8 @@ _priceToBuy = 0;
|
||||
_toolClasses = [];
|
||||
_itemsToLog = [[],[],[],"buy"];
|
||||
|
||||
if (count Z_BuyingArray < 1) exitWith { systemChat localize "STR_EPOCH_TRADE_BUY_NO_ITEMS"; };
|
||||
|
||||
if (Z_SingleCurrency) then {
|
||||
{
|
||||
if( _x select 1 == "trade_weapons")then{
|
||||
@@ -103,49 +105,49 @@ if (Z_SingleCurrency) then {
|
||||
|
||||
if(_enoughMoney) then {
|
||||
if(_canBuy) then {
|
||||
_buyVehicle = {
|
||||
private "_location";
|
||||
_part_out = _this select 0;
|
||||
_buyingType = _this select 1;
|
||||
_keySelected = "0";
|
||||
_isKeyOK= false;
|
||||
if (_buyingType in ["trade_any_vehicle_free", "trade_any_bicycle", "trade_any_bicycle_old"]) then {
|
||||
_isKeyOK = true;
|
||||
} else {
|
||||
_keyColor = ["Green","Red","Blue","Yellow","Black"] call BIS_fnc_selectRandom;
|
||||
_keyNumber = (floor(random 2500)) + 1;
|
||||
_keySelected = format["ItemKey%1%2",_keyColor,_keyNumber];
|
||||
_isKeyOK = isClass(configFile >> "CfgWeapons" >> _keySelected);
|
||||
};
|
||||
if (!_isKeyOK) exitWith {localize "str_epoch_player_107" call dayz_rollingMessages; "";};
|
||||
_activatingPlayer = player;
|
||||
_dir = round(random 360);
|
||||
_helipad = nearestObjects [player, ["HeliHCivil","HeliHempty"], 100];
|
||||
|
||||
if(count _helipad > 0) then {
|
||||
_location = (getPosATL (_helipad select 0));
|
||||
} else {
|
||||
_location = [([player] call FNC_GetPos),0,20,1,0,2000,0] call BIS_fnc_findSafePos;
|
||||
};
|
||||
_buyVehicle = {
|
||||
private "_location";
|
||||
_part_out = _this select 0;
|
||||
_buyingType = _this select 1;
|
||||
_keySelected = "0";
|
||||
_isKeyOK= false;
|
||||
if (_buyingType in ["trade_any_vehicle_free", "trade_any_bicycle", "trade_any_bicycle_old"]) then {
|
||||
_isKeyOK = true;
|
||||
} else {
|
||||
_keyColor = ["Green","Red","Blue","Yellow","Black"] call BIS_fnc_selectRandom;
|
||||
_keyNumber = (floor(random 2500)) + 1;
|
||||
_keySelected = format["ItemKey%1%2",_keyColor,_keyNumber];
|
||||
_isKeyOK = isClass(configFile >> "CfgWeapons" >> _keySelected);
|
||||
};
|
||||
if (!_isKeyOK) exitWith {localize "str_epoch_player_107" call dayz_rollingMessages; "";};
|
||||
_activatingPlayer = player;
|
||||
_dir = round(random 360);
|
||||
_helipad = nearestObjects [player, ["HeliHCivil","HeliHempty"], 100];
|
||||
|
||||
if(count _helipad > 0) then {
|
||||
_location = (getPosATL (_helipad select 0));
|
||||
} else {
|
||||
_location = [([player] call FNC_GetPos),0,20,1,0,2000,0] call BIS_fnc_findSafePos;
|
||||
};
|
||||
|
||||
_veh = createVehicle ["Sign_arrow_down_large_EP1", _location, [], 0, "CAN_COLLIDE"];
|
||||
_location = ([_veh] call FNC_GetPos);
|
||||
|
||||
if (_buyingType in ["trade_any_vehicle_free", "trade_any_bicycle", "trade_any_bicycle_old"]) then {
|
||||
PVDZE_veh_Publish2 = [_veh,[_dir,_location],_part_out,true,"0",_activatingPlayer];
|
||||
} else {
|
||||
PVDZE_veh_Publish2 = [_veh,[_dir,_location],_part_out,false,_keySelected,_activatingPlayer];
|
||||
_veh = createVehicle ["Sign_arrow_down_large_EP1", _location, [], 0, "CAN_COLLIDE"];
|
||||
_location = ([_veh] call FNC_GetPos);
|
||||
|
||||
if (_buyingType in ["trade_any_vehicle_free", "trade_any_bicycle", "trade_any_bicycle_old"]) then {
|
||||
PVDZE_veh_Publish2 = [_veh,[_dir,_location],_part_out,true,"0",_activatingPlayer];
|
||||
} else {
|
||||
PVDZE_veh_Publish2 = [_veh,[_dir,_location],_part_out,false,_keySelected,_activatingPlayer];
|
||||
};
|
||||
publicVariableServer "PVDZE_veh_Publish2";
|
||||
_keySelected;
|
||||
};
|
||||
publicVariableServer "PVDZE_veh_Publish2";
|
||||
_keySelected;
|
||||
};
|
||||
systemChat localize "STR_EPOCH_PLAYER_105";
|
||||
systemChat localize "STR_EPOCH_PLAYER_105";
|
||||
|
||||
closeDialog 2;
|
||||
closeDialog 2;
|
||||
|
||||
if(Z_SellingFrom == 0) then { //backpack
|
||||
_backpack = unitBackpack player;
|
||||
systemChat format[localize "STR_EPOCH_TRADE_IN_BACKPACK",count (Z_BuyingArray)];
|
||||
_backpack = unitBackpack player;
|
||||
systemChat format[localize "STR_EPOCH_TRADE_IN_BACKPACK",count (Z_BuyingArray)];
|
||||
{
|
||||
if( _x select 1 == "trade_weapons")then{
|
||||
_backpack addWeaponCargoGlobal [_x select 0, _x select 9];
|
||||
@@ -195,13 +197,13 @@ if(_enoughMoney) then {
|
||||
};
|
||||
if( _x select 1 == "trade_items" ) then {
|
||||
_count = 0;
|
||||
while{ _count < (_x select 9)} do {
|
||||
while{ _count < (_x select 9)} do {
|
||||
player addMagazine (_x select 0);
|
||||
_count = _count + 1;
|
||||
};
|
||||
};
|
||||
if( _x select 1 == "trade_backpacks")then{
|
||||
player addBackpack (_x select 0);
|
||||
player addBackpack (_x select 0);
|
||||
};
|
||||
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), (_x select 1)] call _buyVehicle;
|
||||
@@ -212,19 +214,21 @@ if(_enoughMoney) then {
|
||||
} count Z_BuyingArray;
|
||||
};
|
||||
if (!Z_SingleCurrency) then {
|
||||
_success = [player,_priceToBuy, _moneyInfo] call Z_payDefault;
|
||||
if (_success) then {
|
||||
systemChat format[localize "STR_EPOCH_TRADE_SUCCESS", _priceToBuy];
|
||||
} else {
|
||||
systemChat localize "STR_EPOCH_TRADE_DEBUG";
|
||||
};
|
||||
_success = [player,_priceToBuy, _moneyInfo] call Z_payDefault;
|
||||
if (_success) then {
|
||||
_tcost = "";
|
||||
_tcost = _priceToBuy call z_calcDefaultCurrencyNoImg;
|
||||
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, CurrencyName];
|
||||
} else {
|
||||
systemChat localize "STR_EPOCH_TRADE_DEBUG";
|
||||
};
|
||||
_success = [player,_priceToBuy] call SC_fnc_removeCoins;
|
||||
if (_success) then {
|
||||
systemChat format[localize "STR_EPOCH_TRADE_SUCCESS_COINS", _priceToBuy, CurrencyName];
|
||||
} else {
|
||||
systemChat localize "STR_EPOCH_TRADE_DEBUG";
|
||||
};
|
||||
};
|
||||
_itemsToLog call Z_logTrade;
|
||||
} else {
|
||||
@@ -236,4 +240,4 @@ if(_enoughMoney) then {
|
||||
} else {
|
||||
systemChat localize "STR_EPOCH_TRADE_NEED_MONEY";
|
||||
};
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user