From 9889c8cd760fc7446aca012d867488c972ecb027 Mon Sep 17 00:00:00 2001 From: oiad Date: Fri, 23 Dec 2016 08:16:38 +1300 Subject: [PATCH] Merge z_calcDefaultCurrency and z_calcDefaultCurrencyNoImg (#1824) * server_updateObject force update for single currency This modifies server_updateObject to force update/save to the hive if the item being saved is in the DZE_MoneyStorageClasses array. Previously if you force saved the object multiple times, the coins would not get updated until the inventory changed, which if this was for a bank object it would never update. (This applies if you are using PVDZ_veh_Save to save the object) * z_at_calcDefaultCurrencyNoImg prettyfication This fixes a long standing issue in my brain about how this text was always displayed, to me it seemed very untidy and just thrown together (since I borrowed it from the IMG version) Changes the output from this example: 7 Ruby 1 Amethyst 3 Gold 4 10oz Silver 5 Silver To this prettier and more logical example: 7 Ruby, 1 Amethyst, 3 Gold, 4 10oz Silver and 5 Silver Make texts great again! * z_at_logtrade fixes Removes hard coded "Coins" text and replaces it with configVariables version. Also removes duplicate code and simplifies it. * Merge z_calcDefaultCurrency and z_calcDefaultCurrencyNoImg This merges these two files together since they are largely the same, this also adds an optional argument to change the font size which is useful for custom scripts that use this function. Examples of use: [_number,true] call z_calcCurrency; // Return a string of text with no images [_number,false] call z_calcCurrency; // Return a string of text with images [_number,false,0.7] call z_calcCurrency; // Return a string of text with the currency in it and sets the font size to 0.7 --- .../actions/AdvancedTrading/defaultInit.sqf | 2 +- .../functions/z_at_buyItems.sqf | 2 +- .../functions/z_at_calcCurrency.sqf | 168 ++++++++++++++++++ .../functions/z_at_calcDefaultCurrency.sqf | 119 ------------- .../z_at_calcDefaultCurrencyNoImg.sqf | 151 ---------------- .../functions/z_at_calcPrice.sqf | 6 +- .../functions/z_at_logTrade.sqf | 18 +- .../functions/z_at_sellItems.sqf | 2 +- .../actions/AdvancedTrading/init.sqf | 1 - SQF/dayz_code/actions/maintain_area.sqf | 2 +- 10 files changed, 178 insertions(+), 293 deletions(-) create mode 100644 SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcCurrency.sqf delete mode 100644 SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcDefaultCurrency.sqf delete mode 100644 SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcDefaultCurrencyNoImg.sqf diff --git a/SQF/dayz_code/actions/AdvancedTrading/defaultInit.sqf b/SQF/dayz_code/actions/AdvancedTrading/defaultInit.sqf index 482a74be3..3452c0b08 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/defaultInit.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/defaultInit.sqf @@ -35,5 +35,5 @@ Z_canAfford = CPP PATH(z_at_canAfford.sqf); Z_calcFreeSpace = CPP PATH(z_at_calcFreeSpace.sqf); Z_returnChange = CPP PATH(z_at_returnChange.sqf); Z_payDefault = CPP PATH(z_at_payDefault.sqf); -z_calcDefaultCurrencyNoImg = CPP PATH(z_at_calcDefaultCurrencyNoImg.sqf); +z_calcCurrency = CPP PATH(z_at_calcCurrency.sqf); ZUPA_fnc_removeWeaponsAndMagazinesCargo = CPP PATH(zupa_fnc_removeWeaponsAndMagazinesCargo.sqf); diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_buyItems.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_buyItems.sqf index 57b5c5681..d958d2d8a 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_buyItems.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_buyItems.sqf @@ -254,7 +254,7 @@ if (_enoughMoney) then { systemChat format[localize "STR_EPOCH_TRADE_SUCCESS_COINS",[_priceToBuy] call BIS_fnc_numberText,CurrencyName]; } else { _tCost = ""; - _tCost = _priceToBuy call z_calcDefaultCurrencyNoImg; + _tCost = [_priceToBuy,true] call z_calcCurrency; if (_tCost != "") then { systemChat format[localize "STR_EPOCH_TRADE_BUY_SUCCESS",_tCost]; }; }; } else { diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcCurrency.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcCurrency.sqf new file mode 100644 index 000000000..3475f164d --- /dev/null +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcCurrency.sqf @@ -0,0 +1,168 @@ +private ["_GemTotal","_GemTotal2","_ItemAmethyst","_ItemCitrine","_ItemEmerald","_ItemObsidian","_ItemRuby","_ItemSapphire","_ItemTopaz","_array","_briefcase_100oz","_fontSize","_gem","_gold_10oz","_gold_10oz_a","_gold_10oz_b","_gold_1oz","_gold_1oz_a","_gold_1oz_b","_noIMG","_pic","_silver_10oz","_silver_10oz_a","_silver_10oz_b","_silver_1oz","_silver_1oz_a","_silver_1oz_b","_string","_total","_value"]; + +_total = _this select 0; +_noIMG = _this select 1; +_fontSize = if (count _this > 2) then {_this select 2} else {1}; +_array = []; +_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 { + if (_noIMG) then { + _pic = getText (configFile >> 'CfgMagazines' >> _x >> 'displayName'); + _array set [count _array, format["%1 %2",(call compile format["_%1",_x]),_pic]]; + } else { + _pic = getText (configFile >> 'CfgMagazines' >> _x >> 'picture'); + _string = format["%3%1x",(call compile format["_%1",_x]),_pic, _string,_fontSize]; + }; + }; +} count DZE_GemList; + +if (_noIMG) then { + if (_briefcase_100oz >= 2) then { + _array set [count _array, format["%1 %2s",_briefcase_100oz,localize "STR_EPOCH_BRIEFCASE"]]; + }; + + if (_briefcase_100oz == 1) then { + _array set [count _array, format["%1 %2",_briefcase_100oz,localize "STR_EPOCH_BRIEFCASE"]]; + }; +} else { + if (_briefcase_100oz > 0) then { + _pic = getText (configFile >> 'CfgMagazines' >> 'ItemBriefcase100oz' >> 'picture'); + _string = format["%3%1x",_briefcase_100oz,_pic, _string,_fontSize]; + }; +}; + +if (_gold_10oz > 0) then { + if (_noIMG) then { + _array set [count _array, format["%1 %2",_gold_10oz,localize "STR_EPOCH_10OZGOLD"]]; + } else { + _pic = getText (configFile >> 'CfgMagazines' >> 'ItemGoldBar10oz' >> 'picture'); + _string = format["%3%1x",_gold_10oz,_pic, _string,_fontSize]; + }; +}; +if (_gold_1oz > 0) then { + if (_noIMG) then { + _array set [count _array, format["%1 %2",_gold_1oz,localize "STR_EPOCH_GOLD"]]; + } else { + _pic = getText (configFile >> 'CfgMagazines' >> 'ItemGoldBar' >> 'picture'); + _string = format["%3%1x",_gold_1oz,_pic, _string,_fontSize]; + }; +}; +if (_silver_10oz > 0) then { + if (_noIMG) then { + _array set [count _array, format["%1 %2",_silver_10oz,localize "STR_EPOCH_10OZSILVER"]]; + } else { + _pic = getText (configFile >> 'CfgMagazines' >> 'ItemSilverBar10oz' >> 'picture'); + _string = format["%3%1x",_silver_10oz,_pic, _string,_fontSize]; + }; +}; +if (_silver_1oz > 0) then { + if (_noIMG) then { + _array set [count _array, format["%1 %2",_silver_1oz,localize "STR_EPOCH_SILVER"]]; + } else { + _pic = getText (configFile >> 'CfgMagazines' >> 'ItemSilverBar' >> 'picture'); + _string = format["%3%1x",_silver_1oz,_pic, _string,_fontSize]; + }; +}; + +if (_noIMG) then { + { + if (_forEachIndex == 0) then { + _string = _x; + } else { + if (_forEachIndex == ((count _array) - 1)) then { + _string = _string + " and " + _x; + } else { + _string = _string + ", " + _x; + }; + }; + } forEach _array; +}; + +_string \ No newline at end of file diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcDefaultCurrency.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcDefaultCurrency.sqf deleted file mode 100644 index c96e5854c..000000000 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcDefaultCurrency.sqf +++ /dev/null @@ -1,119 +0,0 @@ -private ["_ItemTopaz","_GemTotal","_ItemTopaz_ItemTopaz","_GemTotal2","_ItemObsidian","_ItemSapphire","_ItemAmethyst","_ItemEmerald","_ItemCitrine","_ItemRuby","_gem","_value","_pic","_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"]; - -_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 { - _pic = getText (configFile >> 'CfgMagazines' >> _x >> 'picture'); - _string = format["%3%1x",(call compile format["_%1",_x]),_pic, _string]; - }; -} count DZE_GemList; - -if (_briefcase_100oz > 0) then { - _pic = getText (configFile >> 'CfgMagazines' >> 'ItemBriefcase100oz' >> 'picture'); - _string = format["%3%1x",_briefcase_100oz,_pic, _string]; -}; -if (_gold_10oz > 0) then { - _pic = getText (configFile >> 'CfgMagazines' >> 'ItemGoldBar10oz' >> 'picture'); - _string = format["%3%1x",_gold_10oz,_pic, _string]; -}; -if (_gold_1oz > 0) then { - _pic = getText (configFile >> 'CfgMagazines' >> 'ItemGoldBar' >> 'picture'); - _string = format["%3%1x",_gold_1oz,_pic, _string]; -}; -if (_silver_10oz > 0) then { - _pic = getText (configFile >> 'CfgMagazines' >> 'ItemSilverBar10oz' >> 'picture'); - _string = format["%3%1x",_silver_10oz,_pic, _string]; -}; -if (_silver_1oz > 0) then { - _pic = getText (configFile >> 'CfgMagazines' >> 'ItemSilverBar' >> 'picture'); - _string = format["%3%1x",_silver_1oz,_pic, _string]; -}; - -_string diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcDefaultCurrencyNoImg.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcDefaultCurrencyNoImg.sqf deleted file mode 100644 index 292a5e391..000000000 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcDefaultCurrencyNoImg.sqf +++ /dev/null @@ -1,151 +0,0 @@ -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'); - if (_string == "") then { - _string = format["%1 %2",(call compile format["_%1",_x]),_dname]; - } else { - _string = format["%2 %1 %3",(call compile format["_%1",_x]),_string,_dname]; - }; - }; -} count DZE_GemList; - -if (_briefcase_100oz >= 2) then { - if (_string == "") then { - _string = format["%1 %2s",_briefcase_100oz,localize "STR_EPOCH_BRIEFCASE"]; - } else { - _string = format["%2 %1 %3s",_briefcase_100oz,_string,localize "STR_EPOCH_BRIEFCASE"]; - }; -}; - -if (_briefcase_100oz == 1) then { - if (_string == "") then { - _string = format["%1 %2",_briefcase_100oz,localize "STR_EPOCH_BRIEFCASE"]; - } else { - _string = format["%2 %1 %3",_briefcase_100oz,_string,localize "STR_EPOCH_BRIEFCASE"]; - }; -}; - -if (_gold_10oz > 0) then { - if (_string == "") then { - _string = format["%1 %2",_gold_10oz,localize "STR_EPOCH_10OZGOLD"]; - } else { - _string = format["%2 %1 %3",_gold_10oz,_string,localize "STR_EPOCH_10OZGOLD"]; - }; -}; - -if (_gold_1oz > 0) then { - if (_string == "") then { - _string = format["%1 %2",_gold_1oz,localize "STR_EPOCH_GOLD"]; - } else { - _string = format["%2 %1 %3",_gold_1oz,_string,localize "STR_EPOCH_GOLD"]; - }; -}; - -if (_silver_10oz > 0) then { - if (_string == "") then { - _string = format["%1 %2",_silver_10oz,localize "STR_EPOCH_10OZSILVER"]; - } else { - _string = format["%2 %1 %3",_silver_10oz,_string,localize "STR_EPOCH_10OZSILVER"]; - }; -}; - -if (_silver_1oz > 0) then { - if (_string == "") then { - _string = format["%1 %2",_silver_1oz,localize "STR_EPOCH_SILVER"]; - } else { - _string = format["%2 %1 %3",_silver_1oz,_string,localize "STR_EPOCH_SILVER"]; - }; -}; - -_string diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcPrice.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcPrice.sqf index d997a2bd3..10bfdb0de 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcPrice.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcPrice.sqf @@ -33,15 +33,15 @@ if (Z_SingleCurrency) then { { _sellPrice = _sellPrice + ((_x select 2) * (_x select 11)); } count Z_SellArray; - _ctrlText = _sellPrice call Z_calcDefaultCurrency; + _ctrlText = [_sellPrice,false] call Z_calcCurrency; (findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_RIGHTLISTTITLE) ctrlSetText format ["%1 (%2 items)", localize "STR_EPOCH_TRADE_SELLING", count Z_SellArray]; } else { { _sellPrice = _sellPrice + ((_x select 2) * (_x select 11) * (_x select 9)); _bTotal = _bTotal + (_x select 9); } count Z_BuyingArray; - _ctrlText = _sellPrice call Z_calcDefaultCurrency; - (findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_RIGHTLISTTITLE) ctrlSetText format ["%1 (%2 items)", localize "STR_EPOCH_TRADE_BUYING", _bTotal]; + _ctrlText = [_sellPrice,false] call Z_calcCurrency; + (findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_RIGHTLISTTITLE) ctrlSetText format ["%1 (%2 items)", localize "STR_EPOCH_TRADE_BUYING", _bTotal]; }; ctrlSetText [Z_AT_PRICEDISPLAY, '']; (findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_PRICEINFO) ctrlSetStructuredText parseText _ctrlText; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_logTrade.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_logTrade.sqf index 44203e61c..3a1cade5b 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_logTrade.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_logTrade.sqf @@ -12,8 +12,8 @@ _Z_logTrade = { case 1 : {localize "STR_EPOCH_TRADE_VEHICLE"}; case 2 : {localize "STR_UI_GEAR"}; }; - _tCost = _price call Z_calcDefaultCurrencyNoImg; - _currency = if (Z_SingleCurrency) then {"Coins"} else {""}; + _tCost = [_price,true] call Z_calcCurrency; + _currency = if (Z_SingleCurrency) then {CurrencyName} else {""}; // Log to client RPT if (Z_SingleCurrency) then { @@ -32,19 +32,7 @@ _Z_logTrade = { // 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]; - }; - }; + PVDZE_obj_Trade = [player,0,if (_buyOrSell == "buy") then {0} else {1},_className,inTraderCity,_currency,if (Z_singleCurrency) then {_price} else {_tCost},_quantity,_container,false]; publicVariableServer "PVDZE_obj_Trade"; }; }; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_sellItems.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_sellItems.sqf index f7657a78c..dafa1c042 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_sellItems.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_sellItems.sqf @@ -227,7 +227,7 @@ if (typeName _money == "SCALAR") then { } else { _success = [_money,0,false,0,[],[],false] call Z_returnChange; _tCost = ""; - _tCost = _money call z_calcDefaultCurrencyNoImg; + _tCost = [_money,true] call z_calcCurrency; if (_tCost != "") then { systemChat format[localize "STR_EPOCH_TRADE_SELL_SUCCESS",_tCost]; }; }; _itemsToLog call Z_logTrade; diff --git a/SQF/dayz_code/actions/AdvancedTrading/init.sqf b/SQF/dayz_code/actions/AdvancedTrading/init.sqf index ea04bb5d0..a6374fab1 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/init.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/init.sqf @@ -66,7 +66,6 @@ if (isNil "Z_AdvancedTradingInit") then { Z_fillBuyingList = CPP PATH(z_at_fillBuyingList.sqf); Z_displayFreeSpace = CPP PATH(z_at_displayFreeSpace.sqf); Z_allowBuying = CPP PATH(z_at_allowBuying.sqf); - Z_calcDefaultCurrency = CPP PATH(z_at_calcDefaultCurrency.sqf); DZE_deleteTradedVehicle = CPP PATH(DZE_deleteTradedVehicle.sqf); Z_AdvancedTradingInit = true; diff --git a/SQF/dayz_code/actions/maintain_area.sqf b/SQF/dayz_code/actions/maintain_area.sqf index 442af0506..c5457b3bc 100644 --- a/SQF/dayz_code/actions/maintain_area.sqf +++ b/SQF/dayz_code/actions/maintain_area.sqf @@ -45,7 +45,7 @@ _req = { _count = _this; _amount = _count * DZE_maintainCurrencyRate; - _itemText = if (Z_SingleCurrency) then { CurrencyName } else { _amount call z_calcDefaultCurrencyNoImg }; + _itemText = if (Z_SingleCurrency) then { CurrencyName } else { [_amount,true] call z_calcCurrency }; [_amount,_itemText] };