From b508bde202036aaa9e2a27b876584ad2ec9f8574 Mon Sep 17 00:00:00 2001 From: "[VB]AWOL" Date: Sun, 26 Jan 2014 12:16:13 -0600 Subject: [PATCH] added PVDZE_ to player%1 variable to filter better --- SQF/dayz_code/compile/epoch_returnChange.sqf | 120 ++++++++++++++++++ SQF/dayz_code/compile/player_switchModel.sqf | 2 +- SQF/dayz_code/system/player_monitor.fsm | 4 +- .../compile/server_onPlayerDisconnect.sqf | 2 +- 4 files changed, 124 insertions(+), 4 deletions(-) create mode 100644 SQF/dayz_code/compile/epoch_returnChange.sqf diff --git a/SQF/dayz_code/compile/epoch_returnChange.sqf b/SQF/dayz_code/compile/epoch_returnChange.sqf new file mode 100644 index 000000000..112d30630 --- /dev/null +++ b/SQF/dayz_code/compile/epoch_returnChange.sqf @@ -0,0 +1,120 @@ +// Made for DayZ Epoch by vbawol + +private ["_trade_total","_part_inWorth","_part_in_configClass","_total_currency","_part","_worth","_return_change","_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","_successful","_buyOrSell","_total_items"]; +_successful = false; +_canAfford = false; + +_buyOrSell = (_this select 1); + +diag_log format["DEBUG TRADER INPUT: %1", (_this select 0)]; + +// buying in currency +_trade_total = (_this select 0) call epoch_itemCost; + +diag_log format["DEBUG TRADER INPUT TOTAL: %1", _trade_total]; + +_total_currency_dry = call epoch_totalCurrency; + +if (_buyOrSell == 0) then { + //buy + _return_change_dry = _total_currency_dry - _trade_total; +} else { + //sell + _return_change_dry = _total_currency_dry + _trade_total; +}; +if (_return_change_dry >= 0) then { + _canAfford = true; +}; + +if (_canAfford) then { + + // total currency + _total_currency = 0; + { + _part = (configFile >> "CfgMagazines" >> _x); + _worth = (_part >> "worth"); + if isNumber (_worth) then { + if (([player,_part,1] call BIS_fnc_invRemove) == 1) then { + _total_currency = _total_currency + getNumber(_worth); + }; + }; + + } forEach (magazines player); + + diag_log format["DEBUG TRADER INPUT CURRENCY TOTAL: %1", _total_currency]; + + _return_change = 0; + if (_buyOrSell == 0) then { + //buy + _return_change = _total_currency - _trade_total; + } else { + //sell + _return_change = _total_currency + _trade_total; + }; + + diag_log format["DEBUG TRADER CHANGE: %1", _return_change]; + + if (_return_change >= 0) then { + + // total currency + _total = _return_change; + + _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); + + + if (_briefcase_100oz > 0) then { + for "_x" from 1 to _briefcase_100oz do { + player addMagazine "ItemBriefcase100oz"; + diag_log format["DEBUG TRADER CHANG MADE: %1 x %2", _briefcase_100oz, "ItemBriefcase100oz"]; + }; + }; + if (_gold_10oz > 0) then { + for "_x" from 1 to _gold_10oz do { + player addMagazine "ItemGoldBar10oz"; + diag_log format["DEBUG TRADER CHANG MADE: %1 x %2", _gold_10oz, "ItemGoldBar10oz"]; + }; + }; + if (_gold_1oz > 0) then { + if (_gold_1oz == 1) then { + player addMagazine "ItemGoldBar"; + diag_log format["DEBUG TRADER CHANG MADE: %1 x %2", _gold_1oz, "ItemGoldBar"]; + } else { + player addMagazine format["ItemGoldBar%1oz",_gold_1oz]; + diag_log format["DEBUG TRADER CHANG MADE: %1 x %2", _gold_1oz, "ItemGoldBar"]; + }; + }; + if (_silver_10oz > 0) then { + for "_x" from 1 to _silver_10oz do { + player addMagazine "ItemSilverBar10oz"; + diag_log format["DEBUG TRADER CHANG MADE: %1 x %2", _silver_10oz, "ItemSilverBar10z"]; + }; + }; + if (_silver_1oz > 0) then { + if (_silver_1oz == 1) then { + player addMagazine "ItemSilverBar"; + diag_log format["DEBUG TRADER CHANG MADE: %1 x %2", _silver_1oz, "ItemSilverBar"]; + } else { + player addMagazine format["ItemSilverBar%1oz",_silver_1oz]; + diag_log format["DEBUG TRADER CHANG MADE: %1 x %2", _silver_1oz, "ItemSilverBar"]; + }; + }; + _successful = true; + }; +}; +_successful \ No newline at end of file diff --git a/SQF/dayz_code/compile/player_switchModel.sqf b/SQF/dayz_code/compile/player_switchModel.sqf index 60798d984..e2f7f4335 100644 --- a/SQF/dayz_code/compile/player_switchModel.sqf +++ b/SQF/dayz_code/compile/player_switchModel.sqf @@ -128,7 +128,7 @@ if (_tagSetting) then { }; _playerUID = getPlayerUID player; -_playerObjName = format["player%1",_playerUID]; +_playerObjName = format["PVDZE_player%1",_playerUID]; call compile format["%1 = player;",_playerObjName]; publicVariableServer _playerObjName; //Outcommit in DayZ 1.8 No clue for what this is - Skaronator diff --git a/SQF/dayz_code/system/player_monitor.fsm b/SQF/dayz_code/system/player_monitor.fsm index 7946eff21..21bda5e91 100644 --- a/SQF/dayz_code/system/player_monitor.fsm +++ b/SQF/dayz_code/system/player_monitor.fsm @@ -1066,8 +1066,8 @@ class FSM "" \n "//Select Weapon" \n "// Desc: select default weapon & handle multiple muzzles" \n - "_playerObjName = format[""player%1"",_playerUID];" \n - "call compile format[""player%1 = player;"",_playerUID];" \n + "_playerObjName = format[""PVDZE_player%1"",_playerUID];" \n + "call compile format[""PVDZE_player%1 = player;"",_playerUID];" \n "////diag_log (format[""player%1 = player"",_playerUID]);" \n "publicVariableServer _playerObjName;" \n "" \n diff --git a/SQF/dayz_server/compile/server_onPlayerDisconnect.sqf b/SQF/dayz_server/compile/server_onPlayerDisconnect.sqf index 28a2039bd..58ff73d16 100644 --- a/SQF/dayz_server/compile/server_onPlayerDisconnect.sqf +++ b/SQF/dayz_server/compile/server_onPlayerDisconnect.sqf @@ -11,7 +11,7 @@ if (isNil "_playerObj") then { diag_log format["nil player object attempting PV, :%1", _this]; // fall back to using PV for now so we have a better chance at finding the player - _playerObj = call compile format["player%1",_playerUID]; + _playerObj = call compile format["PVDZE_player%1",_playerUID]; }; if (isNil "_playerObj") exitWith {