Update the trade item system

The trading system to trade zombies parts and get in return bio meat got updated.
Server admins can add a humanity value as 5th value in the array. Also heros and bandits trade dogs tags now and players get humanity from them. This can be edited by server admins too.
This commit is contained in:
AirwavesMan
2020-09-09 17:43:57 +02:00
parent 272a74060c
commit 4f106220b2
15 changed files with 122 additions and 126 deletions

View File

@@ -1,13 +1,14 @@
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;};
dayz_actionInProgress = true;
private ["_part_out","_part_in","_qty_out","_qty_in","_textPartIn","_textPartOut","_qty","_needed","_finished","_abort","_removed","_tradeCounter","_total_trades","_humanityGain","_humanity"];
// [part_out,part_in, qty_out, qty_in,];
private ["_vars","_part_out","_part_in","_qty_out","_qty_in","_textPartIn","_textPartOut","_qty","_needed","_finished","_abort","_removed","_tradeCounter","_total_trades","_humanityGain"];
_part_out = (_this select 3) select 0;
_part_in = (_this select 3) select 1;
_qty_out = (_this select 3) select 2;
_qty_in = (_this select 3) select 3;
_vars = _this select 3;
_part_out = _vars select 0;
_part_in = _vars select 1;
_qty_out = _vars select 2;
_qty_in = _vars select 3;
_humanityGain = [0,_vars select 4] select (count _this > 4);
_textPartIn = getText (configFile >> "CfgMagazines" >> _part_in >> "displayName");
_textPartOut = getText (configFile >> "CfgMagazines" >> _part_out >> "displayName");
@@ -29,10 +30,9 @@ _tradeCounter = 0;
for "_x" from 1 to _total_trades do {
_removed = 0;
_tradeCounter = _tradeCounter + 1;
if(_total_trades == 1) then {
if (_total_trades == 1) then {
format[localize "str_epoch_player_105",_tradeCounter,_total_trades] call dayz_rollingMessages;
} else {
format[localize "str_epoch_player_187",_tradeCounter,_total_trades] call dayz_rollingMessages;
@@ -49,33 +49,29 @@ for "_x" from 1 to _total_trades do {
_removed = _removed + ([player,_part_in,_qty_in] call BIS_fnc_invRemove);
if (_removed == _qty_in) then {
_humanityGain = 0;
for "_x" from 1 to _qty_out do {
player addMagazine _part_out;
if(_part_out == "FoodBioMeat") then {
_humanityGain = _humanityGain + 20;
if (_part_out != "") exitwith {
for "_x" from 1 to _qty_out do {
player addMagazine _part_out;
};
if (_humanityGain != 0) exitwith {
_humanityGain call player_humanityChange;
format[localize "STR_EPOCH_PLAYER_186_HUMANITY",_qty_in,_textPartIn,_qty_out,_textPartOut,_humanityGain,localize "str_actions_stats_hm"] call dayz_rollingMessages;
};
format[localize "str_epoch_player_186",_qty_in,_textPartIn,_qty_out,_textPartOut] call dayz_rollingMessages;
};
if(_humanityGain > 0) then {
// Increase humanity for turning in bio meat
_humanity = player getVariable["humanity",0];
_humanity = _humanity + _humanityGain;
player setVariable["humanity",_humanity,true];
if (_humanityGain != 0) exitwith {
_humanityGain call player_humanityChange;
format[localize "STR_EPOCH_PLAYER_186_2_HUMANITY",_qty_in,_textPartIn,_humanityGain,localize "str_actions_stats_hm"] call dayz_rollingMessages;
};
format[localize "str_epoch_player_186",_qty_in,_textPartIn,_qty_out,_textPartOut] call dayz_rollingMessages;
format[localize "STR_EPOCH_PLAYER_186_2",_qty_in,_textPartIn] call dayz_rollingMessages;
} else {
// Return items from botched trade.
for "_x" from 1 to _removed do {
player addMagazine _part_in;
};
_abort = true;
};
} else {
_needed = _qty_in - _qty;
format[localize "str_epoch_player_184",_needed,_textPartIn] call dayz_rollingMessages;