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:
oiad
2016-06-22 12:18:41 +12:00
committed by ebaydayz
parent 63d6cfa87b
commit 801145d664
11 changed files with 487 additions and 333 deletions

View File

@@ -453,6 +453,17 @@ class AdvancedTrading
x = 0.63 * safezoneW + safezoneX;
y = 0.77 * safezoneH + safezoneY;
w = 0.13 * safezoneW;
onButtonClick = "[[],0] call epoch_returnChange; ((ctrlParent (_this select 0)) closeDisplay 9000); localize ""STR_EPOCH_PLAYER_307"" call dayz_rollingMessages;";
colorBackground[] = {1,1,1,1};
color[] = {0,0,0,1};
text = $STR_EPOCH_PLAYER_306;
};
class ZSC_RscButtonMenu_AT29: AT_Zupa_BlueButton
{
idc = -1;
x = 0.63 * safezoneW + safezoneX;
y = 0.80 * safezoneH + safezoneY;
w = 0.13 * safezoneW;
onButtonClick = "((ctrlParent (_this select 0)) closeDisplay 9000);";
colorBackground[] = {1,1,1,1};
color[] = {0,0,0,1};

View File

@@ -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{
@@ -214,7 +216,9 @@ if(_enoughMoney) then {
if (!Z_SingleCurrency) then {
_success = [player,_priceToBuy, _moneyInfo] call Z_payDefault;
if (_success) then {
systemChat format[localize "STR_EPOCH_TRADE_SUCCESS", _priceToBuy];
_tcost = "";
_tcost = _priceToBuy call z_calcDefaultCurrencyNoImg;
systemChat format[localize "STR_EPOCH_TRADE_BUY_SUCCESS", _tcost];
} else {
systemChat localize "STR_EPOCH_TRADE_DEBUG";
};

View File

@@ -0,0 +1,118 @@
private ["_ItemTopaz","_GemTotal","_ItemTopaz_ItemTopaz","_GemTotal2","_ItemObsidian","_ItemSapphire","_ItemAmethyst","_ItemEmerald","_ItemCitrine","_ItemRuby","_gem","_value","_string","_total","_briefcase_100oz","_gold_10oz_a","_gold_10oz_b","_gold_10oz","_gold_1oz_a","_gold_1oz_b","_gold_1oz","_silver_10oz_a","_silver_10oz_b","_silver_10oz","_silver_1oz_a","_silver_1oz_b","_silver_1oz","_dname"];
_total = _this;
_string = "";
_ItemTopaz = 0;
_ItemObsidian = 0;
_ItemSapphire = 0;
_ItemAmethyst = 0;
_ItemEmerald = 0;
_ItemCitrine = 0;
_ItemRuby = 0;
_GemTotal = 0;
_GemTotal2 = _total;
{
_gem = _x;
_value = DZE_GemWorthList select _forEachIndex;
switch(_gem) do {
case 'ItemTopaz': {
_ItemTopaz = floor(_GemTotal2 / _value);
if (_ItemTopaz >= 1) then {
_GemTotal = (_value * _ItemTopaz) + _GemTotal;
_GemTotal2 = _total - _GemTotal;
};
};
case 'ItemObsidian': {
_ItemObsidian = floor(_GemTotal2 / _value);
if (_ItemObsidian >= 1) then {
_GemTotal = (_value * _ItemObsidian) + _GemTotal;
_GemTotal2 = _total - _GemTotal;
};
};
case 'ItemSapphire': {
_ItemSapphire = floor(_GemTotal2 / _value);
if (_ItemSapphire >= 1) then {
_GemTotal = (_value * _ItemSapphire) + _GemTotal;
_GemTotal2 = _total - _GemTotal;
};
};
case 'ItemAmethyst': {
_ItemAmethyst = floor(_GemTotal2 / _value);
if (_ItemAmethyst >= 1) then {
_GemTotal = (_value * _ItemAmethyst) + _GemTotal;
_GemTotal2 = _total - _GemTotal;
};
};
case 'ItemEmerald': {
_ItemEmerald = floor(_GemTotal2 / _value);
if (_ItemEmerald >= 1) then {
_GemTotal = (_value * _ItemEmerald) + _GemTotal;
_GemTotal2 = _total - _GemTotal;
};
};
case 'ItemCitrine': {
_ItemCitrine = floor(_GemTotal2 / _value);
if (_ItemCitrine >= 1) then {
_GemTotal = (_value * _ItemCitrine) + _GemTotal;
_GemTotal2 = _total - _GemTotal;
};
};
case 'ItemRuby': {
_ItemRuby = floor(_GemTotal2 / _value);
if (_ItemRuby >= 1) then {
_GemTotal = (_value * _ItemRuby) + _GemTotal;
_GemTotal2 = _total - _GemTotal;
};
};
};
} forEach DZE_GemList;
_total = _GemTotal2;
_briefcase_100oz = floor(_total / 10000);
_gold_10oz_a = floor(_total / 1000);
_gold_10oz_b = _briefcase_100oz * 10;
_gold_10oz = (_gold_10oz_a - _gold_10oz_b);
_gold_1oz_a = floor(_total / 100);
_gold_1oz_b = _gold_10oz_a * 10;
_gold_1oz = (_gold_1oz_a - _gold_1oz_b);
_silver_10oz_a = floor(_total / 10);
_silver_10oz_b = _gold_1oz_a * 10;
_silver_10oz = (_silver_10oz_a - _silver_10oz_b);
_silver_1oz_a = floor(_total);
_silver_1oz_b = _silver_10oz_a * 10;
_silver_1oz = (_silver_1oz_a - _silver_1oz_b);
{ //sort gems so they display on total price in order of descending worth
if (!isNil {call compile format["_%1",_x]} && {(call compile format["_%1",_x]) > 0}) then {
_dname = getText (configFile >> 'CfgMagazines' >> _x >> 'displayName');
_string = format["%2 %1 %3",(call compile format["_%1",_x]), _string,_dname];
};
} count DZE_GemList;
if (_briefcase_100oz >= 2) then {
_string = format["%2 %1 %3s",_briefcase_100oz,_string,localize "STR_EPOCH_BRIEFCASE"];
};
if (_briefcase_100oz == 1) then {
_string = format["%2 %1 %3",_briefcase_100oz,_string,localize "STR_EPOCH_BRIEFCASE"];
};
if (_gold_10oz > 0) then {
_string = format["%2 %1 %3",_gold_10oz,_string,localize "STR_EPOCH_10OZGOLD"];
};
if (_gold_1oz > 0) then {
_string = format["%2 %1 %3",_gold_1oz,_string,localize "STR_EPOCH_GOLD"];
};
if (_silver_10oz > 0) then {
_string = format["%2 %1 %3",_silver_10oz,_string,localize "STR_EPOCH_10OZSILVER"];
};
if (_silver_1oz > 0) then {
_string = format["%2 %1 %3",_silver_1oz, _string,localize "STR_EPOCH_SILVER"];
};
_string

View File

@@ -53,8 +53,8 @@ if (Z_SingleCurrency) then {
"<img image='%1' size='3' align='center'/><br />" +
"<t color='#33BFFF' size='0.8'>%8: </t><t color='#ffffff' size='0.8'>%2</t><br />" +
"<t color='#33BFFF' size='0.8'>%9: </t><t color='#ffffff' size='0.8'>%3</t><br />" +
"<t color='#33BFFF' size='0.8'>%10: </t><t color='#ffffff' size='0.8'>%5 %7</t><br />" +
"<t color='#33BFFF' size='0.8'>%11: </t><t color='#ffffff' size='0.8'>%6 %7</t><br />"
"<t color='#33BFFF' size='0.8'>%11: </t><t color='#ffffff' size='0.8'>%6 %7</t><br />" +
"<t color='#33BFFF' size='0.8'>%10: </t><t color='#ffffff' size='0.8'>%5 %7</t><br />"
, _picture, _display, _class, 'lazy', _sellPrice, _buyPrice, CurrencyName, localize "STR_EPOCH_NAME", localize "STR_EPOCH_CLASS", localize "STR_EPOCH_PLAYER_292", localize "STR_EPOCH_PLAYER_291"
];
} else {
@@ -66,8 +66,8 @@ if (Z_SingleCurrency) then {
"<img image='%1' size='3' align='center'/><br />" +
"<t color='#33BFFF' size='0.8'>%11: </t><t color='#ffffff' size='0.8'>%2</t><br />" +
"<t color='#33BFFF' size='0.8'>%12: </t><t color='#ffffff' size='0.8'>%3</t><br />" +
"<t color='#33BFFF' size='0.8'>%13: </t><t color='#ffffff' size='0.8'>%5 <img image='%8' /> %7</t><br />" +
"<t color='#33BFFF' size='0.8'>%14: </t><t color='#ffffff' size='0.8'>%6 <img image='%10' /> %9</t><br />"
"<t color='#33BFFF' size='0.8'>%14: </t><t color='#ffffff' size='0.8'>%6 <img image='%10' /> %9</t><br />" +
"<t color='#33BFFF' size='0.8'>%13: </t><t color='#ffffff' size='0.8'>%5 <img image='%8' /> %7</t><br />"
, _picture, _display, _class, 'lazy', _sellPrice, _buyPrice, _sellCurrency , _picSell , _buyCurrency, _picBuy, localize "STR_EPOCH_NAME", localize "STR_EPOCH_CLASS", localize "STR_EPOCH_PLAYER_292", localize "STR_EPOCH_PLAYER_291"
];
};

View File

@@ -120,8 +120,8 @@ if (Z_SingleCurrency) then {
"<img image='%1' size='3' /><br />" +
"<t color='#33BFFF' size='0.8'>%10: </t><t color='#ffffff' size='0.7'>%2</t><br />" +
"<t color='#33BFFF' size='0.8'>%11: </t><t color='#ffffff' size='0.7'>%3</t><br />" +
"<t color='#33BFFF' size='0.8'>%12: </t><t color='#ffffff' size='0.8'>%5 %7</t><br />" +
"<t color='#33BFFF' size='0.8'>%13: </t><t color='#ffffff' size='0.8'>%6 %7</t><br />" +
"<t color='#33BFFF' size='0.8'>%12: </t><t color='#ffffff' size='0.8'>%5 %7</t><br />" +
"<t color='#33BFFF' size='0.8'>%14/%15/%16: </t><t color='#ffffff' size='0.8'>%9/%8/%4</t><br />" +
"<t color='#33BFFF' size='0.8'>%17: </t><t color='#ffffff' size='0.8'>%18 </t><t color='#33BFFF' size='0.8'>%24: </t><t color='#ffffff' size='0.8'>%25</t><br />" + // Armor / Seats
"<t color='#33BFFF' size='0.8'>%21%22: </t><t color='#ffffff' size='0.8'>%23 </t><t color='#33BFFF' size='0.8'>%19: </t><t color='#ffffff' size='0.8'>%20</t><br />" + // MaxSpeed / Fuel
@@ -141,8 +141,8 @@ if (Z_SingleCurrency) then {
"<img image='%1' size='3' /><br />" +
"<t color='#33BFFF' size='0.8'>%13: </t><t color='#ffffff' size='0.7'>%2</t><br />" +
"<t color='#33BFFF' size='0.8'>%14: </t><t color='#ffffff' size='0.7'>%3</t><br />" +
"<t color='#33BFFF' size='0.8'>%15: </t><t color='#ffffff' size='0.8'>%5 <img image='%11' /> %10</t><br />" +
"<t color='#33BFFF' size='0.8'>%16: </t><t color='#ffffff' size='0.8'>%6 <img image='%12' /> %7</t><br />" +
"<t color='#33BFFF' size='0.8'>%15: </t><t color='#ffffff' size='0.8'>%5 <img image='%11' /> %10</t><br />" +
"<t color='#33BFFF' size='0.8'>%17/%18/%19: </t><t color='#ffffff' size='0.8'>%8/%9/%4</t><br />" +
"<t color='#33BFFF' size='0.8'>%20: </t><t color='#ffffff' size='0.8'>%21 </t><t color='#33BFFF' size='0.8'>%27: </t><t color='#ffffff' size='0.8'>%28</t><br />" + // Armor / Seats
"<t color='#33BFFF' size='0.8'>%24%25: </t><t color='#ffffff' size='0.8'>%26 </t><t color='#33BFFF' size='0.8'>%22: </t><t color='#ffffff' size='0.8'>%23</t><br />" + // MaxSpeed / Fuel

View File

@@ -66,8 +66,8 @@ if (Z_SingleCurrency) then {
"<img image='%1' size='3' align='center' /><br />" +
"<t color='#33BFFF' size='0.8'>%8: </t><t color='#ffffff' size='0.8'>%2</t><br />" +
"<t color='#33BFFF' size='0.8'>%9: </t><t color='#ffffff' size='0.8'>%3</t><br />" +
"<t color='#33BFFF' size='0.8'>%10: </t><t color='#ffffff' size='0.8'>%5 %7</t><br />" +
"<t color='#33BFFF' size='0.8'>%11: </t><t color='#ffffff' size='0.8'>%6 %7</t><br />"
"<t color='#33BFFF' size='0.8'>%11: </t><t color='#ffffff' size='0.8'>%6 %7</t><br />" +
"<t color='#33BFFF' size='0.8'>%10: </t><t color='#ffffff' size='0.8'>%5 %7</t><br />"
, _picture, _display, _class, _magText, _sellPrice, _buyPrice, CurrencyName, localize "STR_EPOCH_NAME", localize "STR_EPOCH_CLASS", localize "STR_EPOCH_PLAYER_292", localize "STR_EPOCH_PLAYER_291"
];
}else {
@@ -80,8 +80,8 @@ if (Z_SingleCurrency) then {
"<img image='%1' size='3' align='center' /><br />" +
"<t color='#33BFFF' size='0.8'>%11: </t><t color='#ffffff' size='0.8'>%2</t><br />" +
"<t color='#33BFFF' size='0.8'>%12: </t><t color='#ffffff' size='0.8'>%3</t><br />" +
"<t color='#33BFFF' size='0.8'>%13: </t><t color='#ffffff' size='0.8'>%5 <img image='%9' /> %7</t><br />" +
"<t color='#33BFFF' size='0.8'>%14: </t><t color='#ffffff' size='0.8'>%6 <img image='%10' /> %8</t><br />"
"<t color='#33BFFF' size='0.8'>%14: </t><t color='#ffffff' size='0.8'>%6 <img image='%10' /> %8</t><br />" +
"<t color='#33BFFF' size='0.8'>%13: </t><t color='#ffffff' size='0.8'>%5 <img image='%9' /> %7</t><br />"
, _picture, _display, _class, _magText, _sellPrice, _buyPrice, _sellCurrency, _buyCurrency, _picSell, _picBuy, localize "STR_EPOCH_NAME", localize "STR_EPOCH_CLASS", localize "STR_EPOCH_PLAYER_292", localize "STR_EPOCH_PLAYER_291"
];
};

View File

@@ -12,25 +12,40 @@ _Z_logTrade = {
case 1 : {localize "STR_EPOCH_TRADE_VEHICLE"};
case 2 : {localize "STR_UI_GEAR"};
};
_currency = if (Z_SingleCurrency) then {"Coins"} else {"Currency"};
_tcost = _price call Z_calcDefaultCurrencyNoImg;
_currency = if (Z_SingleCurrency) then {"Coins"} else {""};
if (isNil "inTraderCity") then {inTraderCity = "Unknown Trader City"};
// Log to client RPT
if (Z_SingleCurrency) then {
if (_buyOrSell == "buy") then {
diag_log format["%5: Bought %4 x %1 into %7 at %2 for %3x%6",_className,inTraderCity,_price,_quantity,localize "STR_EPOCH_PLAYER_289",_currency,_container];
} else {
diag_log format["%5: Sold %4 x %1 from %7 at %2 for %3x%6",_className,inTraderCity,_price,_quantity,localize "STR_EPOCH_PLAYER_289",_currency,_container];
};
} else {
if (_buyOrSell == "buy") then {
diag_log format["%5: Bought %4 x %1 into %7 at %2 for %3",_className,inTraderCity,_tcost,_quantity,localize "STR_EPOCH_PLAYER_289",_currency,_container];
} else {
diag_log format["%5: Sold %4 x %1 from %7 at %2 for %3",_className,inTraderCity,_tcost,_quantity,localize "STR_EPOCH_PLAYER_289",_currency,_container];
};
};
// Log to server RPT
if (DZE_serverLogTrades) then {
if (Z_SingleCurrency) then {
if (_buyOrSell == "buy") then {
PVDZE_obj_Trade = [player,0,0,_className,inTraderCity,_currency,_price,_quantity,_container,false];
} else {
PVDZE_obj_Trade = [player,0,1,_className,inTraderCity,_currency,_price,_quantity,_container,false];
};
} else {
if (_buyOrSell == "buy") then {
PVDZE_obj_Trade = [player,0,0,_className,inTraderCity,_currency,_tcost,_quantity,_container,false];
} else {
PVDZE_obj_Trade = [player,0,1,_className,inTraderCity,_currency,_tcost,_quantity,_container,false];
};
};
publicVariableServer "PVDZE_obj_Trade";
};
};

View File

@@ -1,8 +1,6 @@
private ["_index","_tempArray","_outcome","_vehCheckArray","_vehArray","_weaponsArray","_itemsArray","_bpArray","_bpCheckArray","_weaponsCheckArray","_itemsCheckArray","_VehKey","_wA","_mA","_money","_itemData","_success","_bag","_itemsToLog"];
private ["_tempArray","_outcome","_vehCheckArray","_vehArray","_weaponsArray","_itemsArray","_bpArray","_bpCheckArray","_weaponsCheckArray","_itemsCheckArray","_VehKey","_wA","_mA","_money","_itemData","_success","_bag","_itemsToLog","_tcost"];
_index = count (Z_SellArray) - 1;
_tempArray = Z_SellArray;
if(_index > -1)then{
closeDialog 2;
_outcome = [];
_weaponsArray = [];
@@ -15,6 +13,8 @@ if(_index > -1)then{
_itemsCheckArray = [];
_itemsToLog = [[],[],[],"sell"];
if (count Z_SellArray < 1) exitWith { systemChat localize "STR_EPOCH_TRADE_SELL_NO_ITEMS"; };
_deleteTradedVehicle = {
private ["_localResult2","_VehKey2"];
_VehKey2 = (_this select 0) select 0;
@@ -240,14 +240,12 @@ if(_index > -1)then{
systemChat format[localize "STR_EPOCH_TRADE_SUCCESS_CHANGE", _money , CurrencyName];
} else {
_success = [_money, 0] call Z_returnChange;
systemChat localize "STR_EPOCH_TRADE_SUCCESSFUL";
_tcost = "";
_tcost = _money call z_calcDefaultCurrencyNoImg;
systemChat format[localize "STR_EPOCH_TRADE_SELL_SUCCESS",_tcost];
};
_itemsToLog call Z_logTrade;
}else{
systemChat localize "STR_EPOCH_TRADE_DEBUG";
diag_log "Money is not a number. Something went wrong.";
};
}else{
systemChat localize "STR_EPOCH_TRADE_NO_ITEMS";
};

View File

@@ -99,6 +99,7 @@ if(isNil "Z_AdvancedTradingInit")then{
Z_returnChange = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_returnChange.sqf");
Z_payDefault = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_payDefault.sqf");
Z_calcDefaultCurrency = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_calcDefaultCurrency.sqf");
z_calcDefaultCurrencyNoImg = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_calcDefaultCurrencyNoImg.sqf");
Z_AdvancedTradingInit = true;
};

View File

@@ -15763,9 +15763,11 @@
<English>No info found</English>
<Russian>Нет информации</Russian>
</Key>
<Key ID="STR_EPOCH_TRADE_NO_ITEMS">
<English>No items to sell</English>
<Russian>Нет ничего на продажу</Russian>
<Key ID="STR_EPOCH_TRADE_BUY_NO_ITEMS">
<English>No items in buy list</English>
</Key>
<Key ID="STR_EPOCH_TRADE_SELL_NO_ITEMS">
<English>No items in sell list</English>
</Key>
<Key ID="STR_EPOCH_TRADE_DETAILS">
<English>Details</English>
@@ -15870,12 +15872,16 @@
<English>Trade successfull.</English>
<Russian>Продажа завершена.</Russian>
</Key>
<Key ID="STR_EPOCH_TRADE_SUCCESS">
<English>Trade successfull, payed %1 worth of items.</English>
<Key ID="STR_EPOCH_TRADE_BUY_SUCCESS">
<English>Trade successfull, paid:%1.</English>
<Russian>Продано! С вас %1.</Russian>
</Key>
<Key ID="STR_EPOCH_TRADE_SELL_SUCCESS">
<English>Trade successfull, received:%1.</English>
<Russian>Продажа завершена. Получено:%1</Russian>
</Key>
<Key ID="STR_EPOCH_TRADE_SUCCESS_COINS">
<English>Trade successfull, payed %1 %2.</English>
<English>Trade successfull, paid %1 %2.</English>
<Russian>Продано! С вас %1 %2.</Russian>
</Key>
<Key ID="STR_EPOCH_TRADE_SUCCESS_CHANGE">

View File

@@ -19,7 +19,8 @@ if (count _this > 7) then {
};
_clientID = owner _player;
_price = format ["%1x%2",_price,_currency];
if (typeName _price == "SCALAR") then { _price = format ["%1x%2",_price,_currency]; } else { _price = format ["%1",_price]; };
_name = if (alive _player) then { name _player; } else { "Dead Player"; };
_PUID = [_player] call FNC_GetPlayerUID;