mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-15 13:26:39 +03:00
Add server RPT logging to Advanced Trading
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"
|
||||
,"_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";
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
};
|
||||
@@ -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.";
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user