Localize and clean up trade_items_wo_db

This commit is contained in:
A Man
2019-12-03 23:54:04 +01:00
parent b7892bfc68
commit 57a1f3cfa9
2 changed files with 20 additions and 48 deletions

View File

@@ -1,24 +1,22 @@
private ["_part_out","_part_in","_qty_out","_qty_in","_textPartIn","_textPartOut","_qty","_needed","_started","_finished","_animState","_isMedic","_abort","_removed","_tradeCounter","_total_trades","_humanityGain","_humanity"];
// [part_out,part_in, qty_out, qty_in,];
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,];
_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;
// _buy_o_sell = (_this select 3) select 4;
_textPartIn = (_this select 3) select 5;
_textPartOut = (_this select 3) select 6;
//_traderID = (_this select 3) select 7;
_textPartIn = getText (configFile >> "CfgMagazines" >> _part_in >> "displayName");
_textPartOut = getText (configFile >> "CfgMagazines" >> _part_out >> "displayName");
_qty = {_x == _part_in} count magazines player;
// find total number of possible trades
_total_trades = floor (_qty / _qty_in);
if(_total_trades < 1) exitWith {
if(_total_trades < 1) exitWith {
_needed = _qty_in - _qty;
format[localize "str_epoch_player_184",_needed,_textPartIn] call dayz_rollingMessages;
dayz_actionInProgress = false;
@@ -29,7 +27,7 @@ _tradeCounter = 0;
// trade all items
for "_x" from 1 to _total_trades do {
_removed = 0;
_tradeCounter = _tradeCounter + 1;
@@ -40,46 +38,18 @@ for "_x" from 1 to _total_trades do {
format[localize "str_epoch_player_187",_tradeCounter,_total_trades] call dayz_rollingMessages;
};
player playActionNow "Medic";
_finished = ["Medic",1] call fn_loopAction;
r_interrupt = false;
_animState = animationState player;
r_doLoop = true;
_started = false;
_finished = false;
while {r_doLoop} do {
_animState = animationState player;
_isMedic = ["medic",_animState] call fnc_inString;
if (_isMedic) then {
_started = true;
};
if (_started && !_isMedic) then {
r_doLoop = false;
_finished = true;
};
if (r_interrupt) then {
r_doLoop = false;
};
uiSleep 0.1;
};
r_doLoop = false;
if (!_finished) exitWith {
r_interrupt = false;
if (vehicle player == player) then {
[objNull, player, rSwitchMove,""] call RE;
player playActionNow "stop";
};
if (!_finished) exitWith {
localize "str_epoch_player_106" call dayz_rollingMessages;
};
_qty = {_x == _part_in} count magazines player;
if (_qty >= _qty_in) then {
_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;
@@ -96,15 +66,15 @@ for "_x" from 1 to _total_trades do {
};
format[localize "str_epoch_player_186",_qty_in,_textPartIn,_qty_out,_textPartOut] call dayz_rollingMessages;
} else {
// Return items from botched trade.
// Return items from botched trade.
for "_x" from 1 to _removed do {
player addMagazine _part_in;
};
_abort = true;
};
};
} else {
_needed = _qty_in - _qty;
@@ -115,6 +85,5 @@ for "_x" from 1 to _total_trades do {
if(_abort) exitWith {};
};
dayz_actionInProgress = false;
dayz_actionInProgress = false;