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 6d32acb70..410fdd8bc 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_buyItems.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_buyItems.sqf @@ -1,5 +1,5 @@ private ["_magazinesToBuy", "_weaponsToBuy", "_backpacksToBuy", "_toolsToBuy", "_sidearmToBuy", "_primaryToBuy", "_priceToBuy" -,"_enoughMoney", "_myMoney", "_canBuy", "_moneyInfo","_count","_success","_backpack","_toolClasses" +,"_enoughMoney", "_myMoney", "_canBuy", "_moneyInfo","_count","_success","_backpack","_toolClasses","_itemsToLog" ]; _magazinesToBuy = 0; @@ -12,6 +12,7 @@ _vehiclesToBuy = 0; _priceToBuy = 0; _toolClasses = []; +_itemsToLog = [[],[],[],"buy"]; if (Z_SingleCurrency) then { { @@ -42,6 +43,9 @@ if (Z_SingleCurrency) then { _vehiclesToBuy = _vehiclesToBuy + (_x select 9) ; _priceToBuy = _priceToBuy + ((_x select 9)*(_x select 2)); // _price * _amount }; + _itemsToLog set [0, (_itemsToLog select 0) + [_x select 0]]; + _itemsToLog set [1, (_itemsToLog select 1) + [_x select 9]]; + _itemsToLog set [2, (_itemsToLog select 2) + [((_x select 9)*(_x select 2))]]; } count Z_BuyingArray; } else { { @@ -72,6 +76,9 @@ if (Z_SingleCurrency) then { _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]]; + _itemsToLog set [1, (_itemsToLog select 1) + [_x select 9]]; + _itemsToLog set [2, (_itemsToLog select 2) + [((_x select 11)*(_x select 2)*(_x select 9))]]; } count Z_BuyingArray; }; @@ -126,7 +133,6 @@ if(_enoughMoney) then { 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]; - diag_log format ["Purchased vehicle %1 without a key", _x select 0]; } else { PVDZE_veh_Publish2 = [_veh,[_dir,_location],_part_out,false,_keySelected,_activatingPlayer]; }; @@ -143,17 +149,14 @@ if(_enoughMoney) then { { if( _x select 1 == "trade_weapons")then{ _backpack addWeaponCargoGlobal [_x select 0, _x select 9]; - diag_log format [localize "STR_EPOCH_TRADE_ADDED_QTY", _x select 0, _x select 9, localize "STR_EPOCH_PLAYER_289"]; }; if( _x select 1 == "trade_items")then{ _backpack addMagazineCargoGlobal [_x select 0, _x select 9]; - diag_log format [localize "STR_EPOCH_TRADE_ADDED_QTY", _x select 0, _x select 9, localize "STR_EPOCH_PLAYER_289"]; }; 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; if (_item2Add != "0") then { _backpack addWeaponCargoGlobal [_item2Add, 1]; - diag_log format ["Key %1 added for vehicle %2", _item2Add, _x select 0]; }; }; } count Z_BuyingArray; @@ -164,21 +167,17 @@ if(_enoughMoney) then { systemChat format["Adding %1 items in %2",count (Z_BuyingArray), typeOf Z_vehicle]; if( _x select 1 == "trade_weapons")then{ Z_vehicle addWeaponCargoGlobal [_x select 0, _x select 9]; - diag_log format [localize "STR_EPOCH_TRADE_ADDED_QTY", _x select 0, _x select 9, localize "STR_EPOCH_PLAYER_289"]; }; if( _x select 1 == "trade_items")then{ Z_vehicle addMagazineCargoGlobal [_x select 0, _x select 9]; - diag_log format [localize "STR_EPOCH_TRADE_ADDED_QTY", _x select 0, _x select 9, localize "STR_EPOCH_PLAYER_289"]; }; if( _x select 1 == "trade_backpacks")then{ Z_vehicle addBackpackCargoGlobal [_x select 0, _x select 9]; - diag_log format [localize "STR_EPOCH_TRADE_ADDED_QTY", _x select 0, _x select 9, localize "STR_EPOCH_PLAYER_289"]; }; 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; if (_item2Add != "0") then { Z_vehicle addWeaponCargoGlobal [_item2Add, 1]; - diag_log format ["Key %1 added for vehicle %2", _item2Add, _x select 0]; }; }; } count Z_BuyingArray; @@ -190,8 +189,7 @@ if(_enoughMoney) then { if( _x select 1 == "trade_weapons") then { _count = 0; while{ _count < (_x select 9)}do{ - player addWeapon (_x select 0); - diag_log format [localize "STR_EPOCH_TRADE_ADDED", _x select 0, localize "STR_EPOCH_PLAYER_289"]; + player addWeapon (_x select 0); _count = _count + 1; }; }; @@ -199,7 +197,6 @@ if(_enoughMoney) then { _count = 0; while{ _count < (_x select 9)} do { player addMagazine (_x select 0); - diag_log format [localize "STR_EPOCH_TRADE_ADDED", _x select 0, localize "STR_EPOCH_PLAYER_289"]; _count = _count + 1; }; }; @@ -210,7 +207,6 @@ if(_enoughMoney) then { _item2Add = [(_x select 0), (_x select 1)] call _buyVehicle; if (_item2Add != "0") then { player addWeapon _item2Add; - diag_log format ["Key %1 added for vehicle %2", _item2Add, _x select 0]; }; }; } count Z_BuyingArray; @@ -230,6 +226,7 @@ if(_enoughMoney) then { systemChat localize "STR_EPOCH_TRADE_DEBUG"; }; }; + _itemsToLog call Z_logTrade; } else { systemChat localize "STR_EPOCH_TRADE_CONTAINER_FULL"; }; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_logTrade.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_logTrade.sqf new file mode 100644 index 000000000..a7078e034 --- /dev/null +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_logTrade.sqf @@ -0,0 +1,73 @@ +private ["_Z_logTrade","_classNames","_className","_amounts","_amount","_prices","_price","_quantity","_queueAmounts","_queueNames","_queuePrices","_index","_buyOrSell"]; + +_Z_logTrade = { + private ["_buyOrSell","_className","_container","_currency","_price","_quantity"]; + + _className = _this select 0; + _quantity = _this select 1; + _buyOrSell = _this select 2; + _price = _this select 3; + _container = switch (Z_SellingFrom) do { + case 0 : {localize "STR_EPOCH_TRADE_BACKPACK"}; + case 1 : {localize "STR_EPOCH_TRADE_VEHICLE"}; + case 2 : {localize "STR_UI_GEAR"}; + }; + _currency = if (Z_SingleCurrency) then {"Coins"} else {"Currency"}; + if (isNil "inTraderCity") then {inTraderCity = "Unknown Trader City"}; + + // Log to client RPT + 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]; + }; + + // Log to server RPT + if (DZE_serverLogTrades) 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]; + }; + + publicVariableServer "PVDZE_obj_Trade"; + }; +}; + +_classNames = _this select 0; +_amounts = _this select 1; +_amounts = _amounts - [0]; +_prices = _this select 2; +_buyOrSell = _this select 3; +_queueNames = []; +_queueAmounts = []; +_queuePrices = []; +{ + _queueAmounts set [_forEachIndex,0]; + _queuePrices set [_forEachIndex,0]; +} forEach _classNames; + +if (count _prices < 1) exitWith {}; + +for "_i" from 0 to (count _prices)-1 do { + _className = _classNames select _i; + _amount = _amounts select _i; + _price = _prices select _i; + _quantity = {(_className == _x)} count _classNames; + + if (_quantity > 1) then { + if !(_className in _queueNames) then {_queueNames set [count _queueNames,_className];}; + _index = _queueNames find _className; + _queueAmounts set [_index, (_queueAmounts select _index) + _amount]; + _queuePrices set [_index, (_queuePrices select _index) + _price]; + } else { + [_className, _amount, _buyOrSell, _price] call _Z_logTrade; + }; +}; + +if (count _queueNames > 0) then { + for "_i" from 0 to (count _queueNames)-1 do { + [_queueNames select _i, _queueAmounts select _i, _buyOrSell, _queuePrices select _i] call _Z_logTrade; + }; +}; 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 5ec3786b2..181e1efe5 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_sellItems.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_sellItems.sqf @@ -1,4 +1,4 @@ -private ["_index","_tempArray","_outcome","_vehCheckArray","_vehArray","_weaponsArray","_itemsArray","_bpArray","_bpCheckArray","_weaponsCheckArray","_itemsCheckArray","_VehKey","_wA","_mA","_money","_itemData","_success","_bag"]; +private ["_index","_tempArray","_outcome","_vehCheckArray","_vehArray","_weaponsArray","_itemsArray","_bpArray","_bpCheckArray","_weaponsCheckArray","_itemsCheckArray","_VehKey","_wA","_mA","_money","_itemData","_success","_bag","_itemsToLog"]; _index = count (Z_SellArray) - 1; _tempArray = Z_SellArray; @@ -13,6 +13,7 @@ if(_index > -1)then{ _vehCheckArray = []; _weaponsCheckArray = []; _itemsCheckArray = []; + _itemsToLog = [[],[],[],"sell"]; _deleteTradedVehicle = { private ["_localResult2","_VehKey2"]; @@ -133,6 +134,8 @@ if(_index > -1)then{ if(Z_SellingFrom == 1)then{ _outcome = [Z_vehicle,_itemsArray,_weaponsArray,_bpArray, _vehArray] call ZUPA_fnc_removeWeaponsAndMagazinesCargo; }; + + _itemsToLog set [0,(_itemsArray + _weaponsArray + _bpArray + [typeOf Z_vehicle])]; //gear if(Z_SellingFrom == 2)then{ @@ -187,39 +190,48 @@ if(_index > -1)then{ _outcome set [2,[1]]; }; }; - + + { _itemsToLog set [1, (_itemsToLog select 1) + _x] } forEach _outcome; _money = 0; if (Z_SingleCurrency) then { { _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) ; + _itemsToLog set [2, (_itemsToLog select 2) + [( (((_weaponsCheckArray select _forEachIndex) select 0)) * _x)]]; }forEach (_outcome select 1); { _money = _money + ( ( ((_bpCheckArray select _forEachIndex) select 0) ) * _x) ; + _itemsToLog set [2, (_itemsToLog select 2) + [( (((_bpCheckArray select _forEachIndex) select 0)) * _x)]]; }forEach (_outcome select 2); if (count _outcome > 3) then { _money = _money + ((_vehCheckArray select 0) select 0); + _itemsToLog set [2, (_itemsToLog select 2) + [((_vehCheckArray select 0) select 0)]]; }; } else { { _itemData = _itemsCheckArray select _forEachIndex; _money = _money + ( (_itemData select 0) * (_itemData select 1) * _x); + _itemsToLog set [2, (_itemsToLog select 2) + [( (_itemData select 0) * (_itemData select 1) * _x)]]; }forEach (_outcome select 0); { _itemData = _weaponsCheckArray select _forEachIndex; _money = _money + ( (_itemData select 0) * (_itemData select 1) * _x); + _itemsToLog set [2, (_itemsToLog select 2) + [( (_itemData select 0) * (_itemData select 1) * _x)]]; }forEach (_outcome select 1); { _itemData = _bpCheckArray select _forEachIndex; _money = _money + ( (_itemData select 0) * (_itemData select 1) * _x); + _itemsToLog set [2, (_itemsToLog select 2) + [( (_itemData select 0) * (_itemData select 1) * _x)]]; }forEach (_outcome select 2); if ((count _outcome) > 3) then { _itemData = _vehCheckArray select 0; _money = _money + ((_itemData select 0) * (_itemData select 1)); + _itemsToLog set [2, (_itemsToLog select 2) + [((_itemData select 0) * (_itemData select 1))]]; }; }; if(typeName _money == "SCALAR") then { @@ -230,6 +242,8 @@ if(_index > -1)then{ _success = [_money, 0] call Z_returnChange; systemChat localize "STR_EPOCH_TRADE_SUCCESSFUL"; }; + + _itemsToLog call Z_logTrade; }else{ systemChat localize "STR_EPOCH_TRADE_DEBUG"; diag_log "Money is not a number. Something went wrong."; diff --git a/SQF/dayz_code/actions/AdvancedTrading/init.sqf b/SQF/dayz_code/actions/AdvancedTrading/init.sqf index 4b01e6f39..0c3e181af 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/init.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/init.sqf @@ -71,6 +71,7 @@ if(isNil "Z_AdvancedTradingInit")then{ Z_getBackpackItems = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_getBackpackItems.sqf"); Z_getVehicleItems = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_getVehicleItems.sqf"); Z_getGearItems = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_getGearItems.sqf"); + Z_logTrade = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_logTrade.sqf"); Z_filterList = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_filterList.sqf"); Z_checkArrayInConfig = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_checkArrayInConfig.sqf"); Z_calcPrice = compile preprocessFileLineNumbers (Z_AT_FolderLocation + "\functions\z_at_calcPrice.sqf"); diff --git a/SQF/dayz_code/compile/player_death.sqf b/SQF/dayz_code/compile/player_death.sqf index 7b64b145d..7879f47b0 100644 --- a/SQF/dayz_code/compile/player_death.sqf +++ b/SQF/dayz_code/compile/player_death.sqf @@ -42,7 +42,7 @@ if (count _this > 0) then { _killerVehicle = vehicle _killerObj; _killerWeapon = if (_killerVehicle != _killerObj) then {typeOf _killerVehicle} else {currentWeapon _killerObj}; if (alive _killerObj) then { - _killerName = if (isPlayer _killerObj) then {name _killerObj} else {"AI"}; + _killerName = if (isPlayer _killerObj) then {name _killerObj} else {localize "STR_EPOCH_AI"}; }; }; if (count _this > 2) then {_killerMethod = "zombie";}; diff --git a/SQF/dayz_code/configVariables.sqf b/SQF/dayz_code/configVariables.sqf index 746d597bc..d2d1aca55 100644 --- a/SQF/dayz_code/configVariables.sqf +++ b/SQF/dayz_code/configVariables.sqf @@ -49,6 +49,7 @@ DZE_GemOccurance = [["ItemTopaz",10], ["ItemObsidian",8], ["ItemSapphire",6], [" /****** Advanced Trading Variables ***********/ DZE_advancedTrading = true; //Use advanced trading system. WARNING: set to false if you use database traders, you should use config-traders anyway! +DZE_serverLogTrades = true; // Log trades to server RPT (sent with publicVariableServer on every trade) DZE_GemWorthArray = [["ItemTopaz",15000], ["ItemObsidian",20000], ["ItemSapphire",25000], ["ItemAmethyst",30000], ["ItemEmerald",35000], ["ItemCitrine",40000], ["ItemRuby",45000]]; //array of gem prices, works only in advanced trading Z_AT_FolderLocation = '\z\addons\dayz_code\actions\AdvancedTrading'; Z_VehicleDistance = 40; // Distance that a vehicle needs to be to see it's content or to sell it. diff --git a/SQF/dayz_code/stringtable.xml b/SQF/dayz_code/stringtable.xml index 08c17f5aa..b406bd6da 100644 --- a/SQF/dayz_code/stringtable.xml +++ b/SQF/dayz_code/stringtable.xml @@ -15752,14 +15752,6 @@ Adding %1 items in backpack Добавлено: %1 предметов в рюкзак - - %3: %1 x %2 added - %3: %1 x %2 добавлено - - - %2: %1 added - %2: %1 добавлено - Trade successfull. Продажа завершена. @@ -17341,5 +17333,28 @@ Compatible Kompatibilní + + Player + Joueur + Jugador + Giocatore + Játékos + Gracz + Игрок + Spieler + Hráč + プレイヤー + + + AI + IA + IA + IA + MI + SI + ИИ + KI + AI + diff --git a/SQF/dayz_server/compile/server_tradeObject.sqf b/SQF/dayz_server/compile/server_tradeObject.sqf index b0e760391..50296aa59 100644 --- a/SQF/dayz_server/compile/server_tradeObject.sqf +++ b/SQF/dayz_server/compile/server_tradeObject.sqf @@ -1,4 +1,4 @@ -private ["_player","_PUID","_name","_traderid","_buyorsell","_data","_result","_key","_outcome","_clientID"]; +private ["_player","_PUID","_name","_traderid","_buyorsell","_data","_result","_key","_outcome","_clientID","_price","_quantity","_container","_return"]; _player = _this select 0; _traderID = _this select 1; @@ -6,16 +6,27 @@ _buyorsell = _this select 2; //0 > Buy // 1 > Sell _classname = _this select 3; _traderCity = _this select 4; _currency = _this select 5; -_qty = _this select 6; +_price = _this select 6; + +if (count _this > 7) then { + _quantity = _this select 7; + _container = _this select 8; + _return = false; +} else { + _quantity = 1; + _container = "gear"; + _return = true; +}; + _clientID = owner _player; -_price = format ["%2x %1",_currency,_qty]; +_price = format ["%1x%2",_price,_currency]; _name = if (alive _player) then { name _player; } else { "Dead Player"; }; _PUID = [_player] call FNC_GetPlayerUID; if (_buyorsell == 0) then { //Buy -diag_log format["EPOCH SERVERTRADE: Player: %1 (%2) bought a %3 in/at %4 for %5", _name, _PUID, _classname, _traderCity, _price]; +diag_log format["%8: %9: %1 (%2) bought %6 x %3 into %7 at %4 for %5", _name, _PUID, _classname, _traderCity, _price, _quantity,_container,localize "STR_EPOCH_PLAYER_289",localize "STR_EPOCH_PLAYER"]; } else { //SELL -diag_log format["EPOCH SERVERTRADE: Player: %1 (%2) sold a %3 in/at %4 for %5",_name, _PUID, _classname, _traderCity, _price]; +diag_log format["%8: %9: %1 (%2) sold %6 x %3 from %7 at %4 for %5",_name, _PUID, _classname, _traderCity, _price, _quantity,_container,localize "STR_EPOCH_PLAYER_289",localize "STR_EPOCH_PLAYER"]; }; if (DZE_ConfigTrader) then { @@ -30,7 +41,9 @@ if (DZE_ConfigTrader) then { _outcome = _result select 0; }; -dayzTradeResult = _outcome; -if(!isNull _player) then { - _clientID publicVariableClient "dayzTradeResult"; -}; +if (_return) then { + dayzTradeResult = _outcome; + if(!isNull _player) then { + _clientID publicVariableClient "dayzTradeResult"; + }; +}; \ No newline at end of file