mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-13 19:52:38 +03:00
added PVDZE_ to player%1 variable to filter better
This commit is contained in:
120
SQF/dayz_code/compile/epoch_returnChange.sqf
Normal file
120
SQF/dayz_code/compile/epoch_returnChange.sqf
Normal file
@@ -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
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user