mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-22 20:12:20 +03:00
0.997b
+ Minor fixes to trade_items + Added animation requirement to trade_items_wo_db
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
private["_iarray","_part_out","_part_in","_qty_out","_qty_in","_qty","_buy_o_sell","_textPartIn","_textPartOut","_bos","_isOk"];
|
||||
// [part_out,part_in, qty_out, qty_in,];
|
||||
|
||||
if(TradeInprogress) exitWith { cutText ["Trade already in progress." , "PLAIN DOWN"]; };
|
||||
if(TradeInprogress) exitWith { cutText ["Trade already in progress." , "PLAIN DOWN"] };
|
||||
TradeInprogress = true;
|
||||
|
||||
_activatingPlayer = _this select 1;
|
||||
@@ -16,6 +16,7 @@ _textPartOut = (_this select 3) select 6;
|
||||
_traderID = (_this select 3) select 7;
|
||||
|
||||
_removed = 0;
|
||||
_tradeCounter = 0;
|
||||
|
||||
_bos = 0;
|
||||
if(_buy_o_sell == "sell") then {
|
||||
@@ -28,17 +29,32 @@ _qty = {_x == _part_in} count magazines player;
|
||||
// Find number of possible trades
|
||||
_total_trades = floor(_qty / _qty_in);
|
||||
|
||||
_abort = false;
|
||||
|
||||
if(_total_trades < 1) exitWith {
|
||||
_needed = _qty_in - _qty;
|
||||
cutText [format[("Need %1 More %2"),_needed,_textPartIn] , "PLAIN DOWN"];
|
||||
TradeInprogress = false;
|
||||
};
|
||||
|
||||
// perform number of total trades
|
||||
for "_x" from 1 to _total_trades do {
|
||||
|
||||
cutText ["Starting trade, stand still to complete.", "PLAIN DOWN"];
|
||||
_removed = 0;
|
||||
_tradeCounter = _tradeCounter + 1;
|
||||
|
||||
// cutText ["Starting trade, stand still to complete.", "PLAIN DOWN"];
|
||||
if(_total_trades == 1) then {
|
||||
cutText [format[("Starting trade, stand still to complete trade."),_tradeCounter,_total_trades] , "PLAIN DOWN"];
|
||||
} else {
|
||||
cutText [format[("Starting trade, stand still to complete trade %1 of %2."),_tradeCounter,_total_trades] , "PLAIN DOWN"];
|
||||
};
|
||||
player playActionNow "Medic";
|
||||
|
||||
_dis=20;
|
||||
_sfx = "repair";
|
||||
[player,_sfx,0,false,_dis] call dayz_zombieSpeak;
|
||||
[player,_dis,true,(getPosATL player)] spawn player_alertZombies;
|
||||
//_dis=20;
|
||||
//_sfx = "repair";
|
||||
//[player,_sfx,0,false,_dis] call dayz_zombieSpeak;
|
||||
//[player,_dis,true,(getPosATL player)] spawn player_alertZombies;
|
||||
|
||||
r_interrupt = false;
|
||||
_animState = animationState player;
|
||||
@@ -67,6 +83,7 @@ for "_x" from 1 to _total_trades do {
|
||||
r_interrupt = false;
|
||||
[objNull, player, rSwitchMove,""] call RE;
|
||||
player playActionNow "stop";
|
||||
cutText ["Canceled Trade." , "PLAIN DOWN"];
|
||||
};
|
||||
|
||||
if (_finished) then {
|
||||
@@ -90,9 +107,13 @@ for "_x" from 1 to _total_trades do {
|
||||
};
|
||||
|
||||
cutText [format[("Traded %1 %2 for %3 %4"),_qty_in,_textPartIn,_qty_out,_textPartOut], "PLAIN DOWN"];
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
cutText [format[("Insufficient Stock %1"),_textPartOut] , "PLAIN DOWN"];
|
||||
_abort = true;
|
||||
|
||||
};
|
||||
|
||||
dayzTradeResult = nil;
|
||||
@@ -104,14 +125,18 @@ for "_x" from 1 to _total_trades do {
|
||||
for "_x" from 1 to _removed do {
|
||||
player addMagazine _part_in;
|
||||
};
|
||||
_abort = true;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
_needed = _qty_in - _qty;
|
||||
cutText [format[("Need %1 More %2"),_needed,_textPartIn] , "PLAIN DOWN"];
|
||||
};
|
||||
};
|
||||
|
||||
sleep 1;
|
||||
|
||||
if(_abort) exitWith {};
|
||||
};
|
||||
|
||||
TradeInprogress = false;
|
||||
@@ -15,70 +15,91 @@ _textPartIn = (_this select 3) select 5;
|
||||
_textPartOut = (_this select 3) select 6;
|
||||
//_traderID = (_this select 3) select 7;
|
||||
|
||||
|
||||
_success = false;
|
||||
_failed = false;
|
||||
|
||||
_total_in = 0;
|
||||
_total_out = 0;
|
||||
|
||||
_qty = {_x == _part_in} count magazines player;
|
||||
|
||||
// find total number of possible trades
|
||||
_total_trades = floor (_qty / _qty_in);
|
||||
|
||||
if (_qty >= _qty_in) then {
|
||||
|
||||
|
||||
|
||||
// trade all items
|
||||
for "_x" from 1 to _total_trades do {
|
||||
|
||||
// Take currency
|
||||
for "_x" from 1 to _qty_in do {
|
||||
player removeMagazine _part_in;
|
||||
};
|
||||
|
||||
_counter = 0;
|
||||
|
||||
// check for space if buying and do not check if selling
|
||||
for "_x" from 1 to _qty_out do {
|
||||
|
||||
if(_buy_o_sell == "buy") then {
|
||||
_isOk = [player,_part_out] call BIS_fnc_invAdd;
|
||||
if (_isOk) then {
|
||||
_counter = _counter + 1;
|
||||
};
|
||||
if (!_isOk) exitWith { _failed = true; };
|
||||
} else {
|
||||
player addMagazine _part_out;
|
||||
};
|
||||
};
|
||||
|
||||
// revert trade since it failed
|
||||
if(!_failed) then {
|
||||
_total_in = _total_in + _qty_in;
|
||||
_total_out = _total_out + _qty_out;
|
||||
} else {
|
||||
// Return currency
|
||||
for "_x" from 1 to _qty_in do {
|
||||
player addMagazine _part_in;
|
||||
};
|
||||
for "_x" from 1 to _counter do {
|
||||
player removeMagazine _part_out;
|
||||
};
|
||||
};
|
||||
if (_failed) exitWith {};
|
||||
};
|
||||
if(_total_out > 0) then {
|
||||
cutText [format[("Traded %1 %2 for %3 %4"),_total_in,_textPartIn,_total_out,_textPartOut], "PLAIN DOWN"];
|
||||
//disableSerialization;
|
||||
//call dayz_forceSave;
|
||||
};
|
||||
|
||||
} else {
|
||||
if(_total_trades < 1) exitWith {
|
||||
_needed = _qty_in - _qty;
|
||||
cutText [format[("Need %1 More %2"),_needed,_textPartIn] , "PLAIN DOWN"];
|
||||
TradeInprogress = false;
|
||||
};
|
||||
|
||||
_abort = false;
|
||||
|
||||
// trade all items
|
||||
for "_x" from 1 to _total_trades do {
|
||||
|
||||
_removed = 0;
|
||||
|
||||
if(_total_trades == 1) then {
|
||||
cutText [format[("Starting trade, stand still to complete trade."),_tradeCounter,_total_trades] , "PLAIN DOWN"];
|
||||
} else {
|
||||
cutText [format[("Starting trade, stand still to complete trade %1 of %2."),_tradeCounter,_total_trades] , "PLAIN DOWN"];
|
||||
};
|
||||
|
||||
player playActionNow "Medic";
|
||||
|
||||
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 and !_isMedic) then {
|
||||
r_doLoop = false;
|
||||
_finished = true;
|
||||
};
|
||||
if (r_interrupt) then {
|
||||
r_doLoop = false;
|
||||
};
|
||||
sleep 0.1;
|
||||
};
|
||||
r_doLoop = false;
|
||||
|
||||
if (!_finished) exitWith {
|
||||
r_interrupt = false;
|
||||
[objNull, player, rSwitchMove,""] call RE;
|
||||
player playActionNow "stop";
|
||||
cutText ["Canceled Trade." , "PLAIN DOWN"];
|
||||
};
|
||||
|
||||
_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 {
|
||||
|
||||
for "_x" from 1 to _qty_out do {
|
||||
player addMagazine _part_out;
|
||||
};
|
||||
cutText [format[("Traded %1 %2 for %3 %4"),_qty_in,_textPartIn,_qty_out,_textPartOut], "PLAIN DOWN"];
|
||||
|
||||
} else {
|
||||
|
||||
// Return items from botched trade.
|
||||
for "_x" from 1 to _removed do {
|
||||
player addMagazine _part_in;
|
||||
};
|
||||
_abort = true;
|
||||
};
|
||||
|
||||
} else {
|
||||
_needed = _qty_in - _qty;
|
||||
cutText [format[("Need %1 More %2"),_needed,_textPartIn] , "PLAIN DOWN"];
|
||||
};
|
||||
|
||||
sleep 1;
|
||||
|
||||
if(_abort) exitWith {};
|
||||
};
|
||||
|
||||
|
||||
TradeInprogress = false;
|
||||
Reference in New Issue
Block a user