init.sqfDZE_ConfigTrader = true; //добавить
compiles.sqf call compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_traderMenuConfig.sqf"; //найти
call compile preprocessFileLineNumbers "fixes\player_traderMenuConfig.sqf"; //заменить
call compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_traderMenuHive.sqf"; //найти
call compile preprocessFileLineNumbers "fixes\player_traderMenuHive.sqf"; //заменить
player_traderMenuConfig.sqf _File = "\z\addons\dayz_code\actions\" + _afile + ".sqf"; //найти
_File = "fixes\trade\" + _afile + ".sqf"; //заменить
player_traderMenuHive.sqf _File = "\z\addons\dayz_code\actions\" + _afile + ".sqf"; //найти
_File = "fixes\trade\" + _afile + ".sqf"; //заменить
fixes\trade\trade_any_bicycle.sqfprivate ["_veh","_location","_isOk","_part_out","_part_in","_qty_out","_qty_in","_qty","_buy_o_sell","_obj","_objectID","_objectUID","_bos","_started","_finished","_animState","_isMedic","_dir","_helipad","_keyColor","_keyNumber","_keySelected","_isKeyOK","_config","_damage","_tireDmg","_tires","_okToSell","_hitpoints","_needed","_activatingPlayer","_textPartIn","_textPartOut","_traderID","_canAfford","_trade_total","_total_currency","_return_change","_done"];
DZE_ActionInProgress = true;
// Test cannot lock while another player is nearby
//_playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 12]) > 1;
//if(_playerNear) exitWith { DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_104") , "PLAIN DOWN"]; };
// [part_out,part_in, qty_out, qty_in, loc];
_activatingPlayer = player;
_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;
_bos = 0;
if(_buy_o_sell == "sell") then {
_bos = 1;
};
cutText [(localize "str_epoch_player_105"), "PLAIN DOWN"];
//player playActionNow "PutDown"; //Анимация отключена
_canAfford = false;
if(_bos == 1) then {
_distance = dayz_sellDistance_vehicle;
if (_part_in isKindOf "Air") then {
_distance = dayz_sellDistance_air;
};
if (_part_in isKindOf "Ship") then {
_distance = dayz_sellDistance_boat;
};
_count = {(typeOf _x) == _part_in} count (nearestObjects [(getPosATL player), [_part_in], _distance]);
if (_count >= _qty_in) then {
_canAfford = true;
};
diag_log format["DEBUG vehicle sell count: %1", _count];
} else {
//buy
_trade_total = [[_part_in,_qty_in]] call epoch_itemCost;
_total_currency = call epoch_totalCurrency;
_return_change = _total_currency - _trade_total;
if (_return_change >= 0) then {
_canAfford = true;
};
};
if (_canAfford) then {
//["PVDZE_obj_Trade",[_activatingPlayer,_traderID,_bos]] call callRpcProcedure;
// if (isNil "_obj") then { _obj = "Unknown Vehicle" };
if (isNil "inTraderCity") then { inTraderCity = "Unknown Trader City" };
if(_bos == 1) then {
// Selling
PVDZE_obj_Trade = [_activatingPlayer,_traderID,_bos,_part_in,inTraderCity,_part_out,_qty_out];
} else {
// Buying
PVDZE_obj_Trade = [_activatingPlayer,_traderID,_bos,_part_out,inTraderCity,_part_in,_qty_in];
};
publicVariableServer "PVDZE_obj_Trade";
//diag_log format["DEBUG Starting to wait for answer: %1", PVDZE_obj_Trade];
if(_buy_o_sell == "buy") then {
waitUntil {!isNil "dayzTradeResult"};
//diag_log format["DEBUG Complete Trade: %1", dayzTradeResult];
if(dayzTradeResult == "PASS") then {
_done = [[[_part_in,_qty_in]],0] call epoch_returnChange;
if (_done) then {
// spawn vehicle
_dir = round(random 360);
_helipad = nearestObjects [player, ["HeliHCivil","HeliHempty"], 100];
if(count _helipad > 0) then {
_location = (getPosATL (_helipad select 0));
} else {
_location = [(position player),0,20,1,0,2000,0] call BIS_fnc_findSafePos;
};
//place vehicle spawn marker (local)
_veh = createVehicle ["Sign_arrow_down_large_EP1", _location, [], 0, "CAN_COLLIDE"];
_location = (getPosATL _veh);
//["PVDZE_veh_Publish",[_veh,[_dir,_location],_part_out,false,_keySelected]] call callRpcProcedure;
PVDZE_veh_Publish2 = [_veh,[_dir,_location],_part_out,true,dayz_characterID,_activatingPlayer];
publicVariableServer "PVDZE_veh_Publish2";
cutText [format[(localize "STR_EPOCH_PLAYER_180"),_qty_in,_textPartIn,_textPartOut], "PLAIN DOWN"];
};
} else {
cutText [format[(localize "str_epoch_player_183"),_textPartOut] , "PLAIN DOWN"];
};
} else {
//sell
_distance = dayz_sellDistance_vehicle;
if (_part_in isKindOf "Air") then {
_distance = dayz_sellDistance_air;
};
if (_part_in isKindOf "Ship") then {
_distance = dayz_sellDistance_boat;
};
_objects = nearestObjects [(getPosATL player), [_part_in], _distance];
diag_log format["DEBUG vehicle sell objects: %1", _objects];
_qty = ({(typeOf _x) == _part_in} count _objects);
if (_qty >= _qty_in) then {
_obj = (_objects select 0);
//check to make sure vehicle has no more than 75% average tire damage
_hitpoints = _obj call vehicle_getHitpoints;
_okToSell = true;
// count parts
_tires = 0;
// total damage
_tireDmg = 0;
_damage = 0;
{
if(["Wheel",_x,false] call fnc_inString) then {
_damage = [_obj,_x] call object_getHit;
_tireDmg = _tireDmg + _damage;
_tires = _tires + 1;
};
} forEach _hitpoints;
// find average tire damage
if(_tireDmg > 0 and _tires > 0) then {
if((_tireDmg / _tires) > 0.75) then {
_okToSell = false;
};
};
_objectID = _obj getVariable ["ObjectID","0"];
_objectUID = _obj getVariable ["ObjectUID","0"];
_notSetup = (_objectID == "0" && _objectUID == "0");
if(local _obj and !isNull _obj and alive _obj and !_notSetup) then {
if(_okToSell) then {
//if(_objectID != "0" && _objectUID != "0") then {
PVDZE_obj_Delete = [_objectID,_objectUID,_activatingPlayer];
publicVariableServer "PVDZE_obj_Delete";
deleteVehicle _obj;
// payout
_canAfford = [[[_part_out,_qty_out]],1] call epoch_returnChange;
cutText [format[(localize "str_epoch_player_181"),_qty_in,_textPartIn,_qty_out,_textPartOut], "PLAIN DOWN"];
} else {
cutText [format[(localize "str_epoch_player_182"),_textPartIn] , "PLAIN DOWN"];
};
} else {
cutText [(localize "str_epoch_player_245"), "PLAIN DOWN"];
};
};
};
dayzTradeResult = nil;
} else {
if(_buy_o_sell == "buy") then {
_qty = {_x == _part_in} count magazines player;
_needed = _qty_in - _qty;
cutText [format[(localize "str_epoch_player_184"),_needed,_textPartIn] , "PLAIN DOWN"];
} else {
cutText [format[(localize "str_epoch_player_185"),_textPartIn] , "PLAIN DOWN"];
};
};
DZE_ActionInProgress = false;
fixes\trade\trade_any_boat.sqfprivate ["_veh","_location","_isOk","_part_out","_part_in","_qty_out","_qty_in","_qty","_buy_o_sell","_obj","_objectID","_objectUID","_bos","_started","_finished","_animState","_isMedic","_dir","_helipad","_keyColor","_keyNumber","_keySelected","_isKeyOK","_config","_damage","_tireDmg","_tires","_okToSell","_hitpoints","_needed","_activatingPlayer","_textPartIn","_textPartOut","_traderID","_canAfford","_trade_total","_total_currency","_return_change","_done"];
DZE_ActionInProgress = true;
// Test cannot lock while another player is nearby
//_playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 12]) > 1;
//if(_playerNear) exitWith { DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_104") , "PLAIN DOWN"]; };
// [part_out,part_in, qty_out, qty_in, loc];
_activatingPlayer = player;
_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;
_bos = 0;
if(_buy_o_sell == "sell") then {
_bos = 1;
};
cutText [(localize "str_epoch_player_105"), "PLAIN DOWN"];
//player playActionNow "PutDown"; //Анимация отключена
_canAfford = false;
if(_bos == 1) then {
_distance = dayz_sellDistance_vehicle;
if (_part_in isKindOf "Air") then {
_distance = dayz_sellDistance_air;
};
if (_part_in isKindOf "Ship") then {
_distance = dayz_sellDistance_boat;
};
_count = {(typeOf _x) == _part_in} count (nearestObjects [(getPosATL player), [_part_in], _distance]);
if (_count >= _qty_in) then {
_canAfford = true;
};
diag_log format["DEBUG vehicle sell count: %1", _count];
} else {
//buy
_trade_total = [[_part_in,_qty_in]] call epoch_itemCost;
_total_currency = call epoch_totalCurrency;
_return_change = _total_currency - _trade_total;
if (_return_change >= 0) then {
_canAfford = true;
};
};
if (_canAfford) then {
//["PVDZE_obj_Trade",[_activatingPlayer,_traderID,_bos]] call callRpcProcedure;
// if (isNil "_obj") then { _obj = "Unknown Vehicle" };
if (isNil "inTraderCity") then { inTraderCity = "Unknown Trader City" };
if(_bos == 1) then {
// Selling
PVDZE_obj_Trade = [_activatingPlayer,_traderID,_bos,_part_in,inTraderCity,_part_out,_qty_out];
} else {
// Buying
PVDZE_obj_Trade = [_activatingPlayer,_traderID,_bos,_part_out,inTraderCity,_part_in,_qty_in];
};
publicVariableServer "PVDZE_obj_Trade";
//diag_log format["DEBUG Starting to wait for answer: %1", PVDZE_obj_Trade];
if(_buy_o_sell == "buy") then {
waitUntil {!isNil "dayzTradeResult"};
//diag_log format["DEBUG Complete Trade: %1", dayzTradeResult];
if(dayzTradeResult == "PASS") then {
// First select key color
_keyColor = ["Green","Red","Blue","Yellow","Black"] call BIS_fnc_selectRandom;
// then select number from 1 - 2500
_keyNumber = (floor(random 2500)) + 1;
// Combine to key (eg.ItemKeyYellow2494) classname
_keySelected = format[("ItemKey%1%2"),_keyColor,_keyNumber];
_isKeyOK = isClass(configFile >> "CfgWeapons" >> _keySelected);
_config = _keySelected;
_isOk = [player,_config] call BIS_fnc_invAdd;
waitUntil {!isNil "_isOk"};
if (_isOk and _isKeyOK) then {
_done = [[[_part_in,_qty_in]],0] call epoch_returnChange;
if (_done) then {
// spawn vehicle
_dir = round(random 360);
_helipad = nearestObjects [player, ["HeliHCivil","HeliHempty"], 100];
if(count _helipad > 0) then {
_location = (getPosATL (_helipad select 0));
} else {
_location = [(position player),0,20,1,2,2000,0] call BIS_fnc_findSafePos;
};
//place vehicle spawn marker (local)
_veh = createVehicle ["Sign_arrow_down_large_EP1", _location, [], 0, "CAN_COLLIDE"];
_location = (getPosATL _veh);
//["PVDZE_veh_Publish",[_veh,[_dir,_location],_part_out,false,_keySelected]] call callRpcProcedure;
PVDZE_veh_Publish2 = [_veh,[_dir,_location],_part_out,false,_keySelected,_activatingPlayer];
publicVariableServer "PVDZE_veh_Publish2";
cutText [format[(localize "STR_EPOCH_ACTIONS_11"),_qty_in,_textPartIn,_textPartOut], "PLAIN DOWN"];
};
} else {
cutText [(localize "str_epoch_player_107"), "PLAIN DOWN"];
};
} else {
cutText [format[(localize "str_epoch_player_183"),_textPartOut] , "PLAIN DOWN"];
};
} else {
//sell
_distance = dayz_sellDistance_vehicle;
if (_part_in isKindOf "Air") then {
_distance = dayz_sellDistance_air;
};
if (_part_in isKindOf "Ship") then {
_distance = dayz_sellDistance_boat;
};
_objects = nearestObjects [(getPosATL player), [_part_in], _distance];
diag_log format["DEBUG vehicle sell objects: %1", _objects];
_qty = ({(typeOf _x) == _part_in} count _objects);
if (_qty >= _qty_in) then {
_obj = (_objects select 0);
_objectID = _obj getVariable ["ObjectID","0"];
_objectUID = _obj getVariable ["ObjectUID","0"];
_notSetup = (_objectID == "0" && _objectUID == "0");
if(local _obj and !isNull _obj and alive _obj and !_notSetup) then {
PVDZE_obj_Delete = [_objectID,_objectUID,_activatingPlayer];
publicVariableServer "PVDZE_obj_Delete";
deleteVehicle _obj;
// payout
_canAfford = [[[_part_out,_qty_out]],1] call epoch_returnChange;
cutText [format[(localize "str_epoch_player_181"),_qty_in,_textPartIn,_qty_out,_textPartOut], "PLAIN DOWN"];
} else {
cutText [(localize "str_epoch_player_245"), "PLAIN DOWN"];
};
};
};
dayzTradeResult = nil;
} else {
if(_buy_o_sell == "buy") then {
_qty = {_x == _part_in} count magazines player;
_needed = _qty_in - _qty;
cutText [format[(localize "str_epoch_player_184"),_needed,_textPartIn] , "PLAIN DOWN"];
} else {
cutText [format[(localize "str_epoch_player_185"),_textPartIn] , "PLAIN DOWN"];
};
};
DZE_ActionInProgress = false;
fixes\trade\trade_any_vehicle.sqfprivate ["_veh","_location","_isOk","_part_out","_part_in","_qty_out","_qty_in","_qty","_buy_o_sell","_obj","_objectID","_objectUID","_bos","_started","_finished","_animState","_isMedic","_dir","_helipad","_keyColor","_keyNumber","_keySelected","_isKeyOK","_config","_damage","_tireDmg","_tires","_okToSell","_temp_keys","_hitpoints","_needed","_activatingPlayer","_textPartIn","_textPartOut","_traderID","_canAfford","_trade_total","_total_currency","_return_change","_done"];
DZE_ActionInProgress = true;
// Test cannot lock while another player is nearby
//_playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 12]) > 1;
//if(_playerNear) exitWith { DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_104") , "PLAIN DOWN"]; };
// [part_out,part_in, qty_out, qty_in, loc];
_activatingPlayer = player;
_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;
_bos = 0;
if(_buy_o_sell == "sell") then {
_bos = 1;
};
cutText [(localize "str_epoch_player_105"), "PLAIN DOWN"];
//player playActionNow "PutDown"; //Анимация отключена
_canAfford = false;
if(_bos == 1) then {
_distance = dayz_sellDistance_vehicle;
if (_part_in isKindOf "Air") then {
_distance = dayz_sellDistance_air;
};
if (_part_in isKindOf "Ship") then {
_distance = dayz_sellDistance_boat;
};
_count = {(typeOf _x) == _part_in} count (nearestObjects [(getPosATL player), [_part_in], _distance]);
if (_count >= _qty_in) then {
_canAfford = true;
};
diag_log format["DEBUG vehicle sell count: %1", _count];
} else {
//buy
_trade_total = [[_part_in,_qty_in]] call epoch_itemCost;
_total_currency = call epoch_totalCurrency;
_return_change = _total_currency - _trade_total;
if (_return_change >= 0) then {
_canAfford = true;
};
};
if (_canAfford) then {
//["PVDZE_obj_Trade",[_activatingPlayer,_traderID,_bos]] call callRpcProcedure;
// if (isNil "_obj") then { _obj = "Unknown Vehicle" };
if (isNil "inTraderCity") then { inTraderCity = "Unknown Trader City" };
if(_bos == 1) then {
// Selling
PVDZE_obj_Trade = [_activatingPlayer,_traderID,_bos,_part_in,inTraderCity,_part_out,_qty_out];
} else {
// Buying
PVDZE_obj_Trade = [_activatingPlayer,_traderID,_bos,_part_out,inTraderCity,_part_in,_qty_in];
};
publicVariableServer "PVDZE_obj_Trade";
//diag_log format["DEBUG Starting to wait for answer: %1", PVDZE_obj_Trade];
if(_buy_o_sell == "buy") then {
waitUntil {!isNil "dayzTradeResult"};
//diag_log format["DEBUG Complete Trade: %1", dayzTradeResult];
if(dayzTradeResult == "PASS") then {
// First select key color
_keyColor = ["Green","Red","Blue","Yellow","Black"] call BIS_fnc_selectRandom;
// then select number from 1 - 2500
_keyNumber = (floor(random 2500)) + 1;
// Combine to key (eg.ItemKeyYellow2494) classname
_keySelected = format[("ItemKey%1%2"),_keyColor,_keyNumber];
_isKeyOK = isClass(configFile >> "CfgWeapons" >> _keySelected);
_config = _keySelected;
_isOk = [player,_config] call BIS_fnc_invAdd;
waitUntil {!isNil "_isOk"};
if (_isOk and _isKeyOK) then {
_done = [[[_part_in,_qty_in]],0] call epoch_returnChange;
if (_done) then {
// spawn vehicle
_dir = round(random 360);
_helipad = nearestObjects [player, ["HeliHCivil","HeliHempty"], 100];
if(count _helipad > 0) then {
_location = (getPosATL (_helipad select 0));
} else {
_location = [(position player),0,20,1,0,2000,0] call BIS_fnc_findSafePos;
};
//place vehicle spawn marker (local)
_veh = createVehicle ["Sign_arrow_down_large_EP1", _location, [], 0, "CAN_COLLIDE"];
_location = (getPosATL _veh);
//["PVDZE_veh_Publish",[_veh,[_dir,_location],_part_out,false,_keySelected]] call callRpcProcedure;
PVDZE_veh_Publish2 = [_veh,[_dir,_location],_part_out,false,_keySelected,_activatingPlayer];
publicVariableServer "PVDZE_veh_Publish2";
cutText [format[(localize "STR_EPOCH_ACTIONS_11"),_qty_in,_textPartIn,_textPartOut], "PLAIN DOWN"];
};
} else {
cutText [(localize "str_epoch_player_107"), "PLAIN DOWN"];
};
} else {
cutText [format[(localize "str_epoch_player_183"),_textPartOut] , "PLAIN DOWN"];
};
} else {
//sell
_distance = dayz_sellDistance_vehicle;
if (_part_in isKindOf "Air") then {
_distance = dayz_sellDistance_air;
};
if (_part_in isKindOf "Ship") then {
_distance = dayz_sellDistance_boat;
};
_objects = nearestObjects [(getPosATL player), [_part_in], _distance];
diag_log format["DEBUG vehicle sell objects: %1", _objects];
_qty = ({(typeOf _x) == _part_in} count _objects);
if (_qty >= _qty_in) then {
_obj = (_objects select 0);
//check to make sure vehicle has no more than 75% average tire damage
_hitpoints = _obj call vehicle_getHitpoints;
_okToSell = true;
// count parts
_tires = 0;
// total damage
_tireDmg = 0;
_damage = 0;
{
if(["Wheel",_x,false] call fnc_inString) then {
_damage = [_obj,_x] call object_getHit;
_tireDmg = _tireDmg + _damage;
_tires = _tires + 1;
};
} forEach _hitpoints;
// find average tire damage
if(_tireDmg > 0 and _tires > 0) then {
if((_tireDmg / _tires) > 0.75) then {
_okToSell = false;
};
};
_objectID = _obj getVariable ["ObjectID","0"];
_objectUID = _obj getVariable ["ObjectUID","0"];
_objectCharacterId = _obj getVariable ["CharacterID","0"];
_notSetup = (_objectID == "0" && _objectUID == "0");
if(local _obj and !isNull _obj and alive _obj and !_notSetup) then {
if(_okToSell) then {
//if(_objectID != "0" && _objectUID != "0") then {
PVDZE_obj_Delete = [_objectID,_objectUID,_activatingPlayer];
publicVariableServer "PVDZE_obj_Delete";
deleteVehicle _obj;
// remove Key
_temp_keys = [];
_keyColor = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"];
{
if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in _key_colors) then {
if (getNumber(configFile >> "CfgWeapons" >> _x >> "keyid") == _objectCharacterId) then {
[_activatingPlayer,_x] call BIS_fnc_invRemove;
};
};
} forEach (items _activatingPlayer);
// payout
_canAfford = [[[_part_out,_qty_out]],1] call epoch_returnChange;
cutText [format[(localize "str_epoch_player_181"),_qty_in,_textPartIn,_qty_out,_textPartOut], "PLAIN DOWN"];
} else {
cutText [format[(localize "str_epoch_player_182"),_textPartIn] , "PLAIN DOWN"];
};
} else {
cutText [(localize "str_epoch_player_245"), "PLAIN DOWN"];
};
};
};
dayzTradeResult = nil;
} else {
if(_buy_o_sell == "buy") then {
_qty = {_x == _part_in} count magazines player;
_needed = _qty_in - _qty;
cutText [format[(localize "str_epoch_player_184"),_needed,_textPartIn] , "PLAIN DOWN"];
} else {
cutText [format[(localize "str_epoch_player_185"),_textPartIn] , "PLAIN DOWN"];
};
};
DZE_ActionInProgress = false;
fixes\trade\trade_backpacks.sqfprivate ["_part_out","_part_in","_qty_out","_qty_in","_qty","_bos","_bag","_class","_started","_finished","_animState","_isMedic","_num_removed","_needed","_activatingPlayer","_buy_o_sell","_textPartIn","_textPartOut","_traderID"];
// [part_out,part_in, qty_out, qty_in,];
DZE_ActionInProgress = true;
_activatingPlayer = player;
diag_log format["DEBUG BACKPACK: %1", _this];
_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;
_bos = 0;
if(_buy_o_sell == "sell") then {
_bos = 1;
};
cutText [(localize "str_epoch_player_105"), "PLAIN DOWN"];
//player playActionNow "PutDown"; //Анимация отключена
_canAfford = false;
if(_bos == 1) then {
//sell
_qty = 0;
_bag = unitBackpack player;
_class = typeOf _bag;
if(_class == _part_in) then {
_qty = 1;
};
if (_qty >= _qty_in) then {
if((typeOf (unitBackpack player)) == _part_in) then {
removeBackpack player;
_canAfford = [[[_part_out,_qty_out]],1] call epoch_returnChange;
};
};
} else {
//buy
_trade_total = [[_part_in,_qty_in]] call epoch_itemCost;
_total_currency = call epoch_totalCurrency;
_return_change = _total_currency - _trade_total;
if (_return_change >= 0) then {
_canAfford = true;
};
};
if (_canAfford) then {
//["PVDZE_obj_Trade",[_activatingPlayer,_traderID,_bos]] call callRpcProcedure;
if (isNil "_bag") then { _bag = "Unknown Backpack" };
if (isNil "inTraderCity") then { inTraderCity = "Unknown Trader City" };
if(_bos == 1) then {
// Selling
PVDZE_obj_Trade = [_activatingPlayer,_traderID,_bos,_part_in,inTraderCity,_part_out,_qty_out];
} else {
// Buying
PVDZE_obj_Trade = [_activatingPlayer,_traderID,_bos,_part_out,inTraderCity,_part_in,_qty_in];
};
publicVariableServer "PVDZE_obj_Trade";
if(_bos == 0) then {
waitUntil {!isNil "dayzTradeResult"};
//diag_log format["DEBUG Complete Trade: %1", dayzTradeResult];
if(dayzTradeResult == "PASS") then {
_done = [[[_part_in,_qty_in]],0] call epoch_returnChange;
if (_done) then {
removeBackpack player;
player addBackpack _part_out;
cutText [format[(localize "str_epoch_player_186"),_qty_in,_textPartIn,_qty_out,_textPartOut], "PLAIN DOWN"];
};
} else {
cutText [format[(localize "str_epoch_player_183"),_textPartOut] , "PLAIN DOWN"];
};
} else {
cutText [format[(localize "str_epoch_player_186"),_qty_in,_textPartIn,_qty_out,_textPartOut], "PLAIN DOWN"];
};
dayzTradeResult = nil;
} else {
_needed = _qty_in - _qty;
cutText [format[(localize "str_epoch_player_184"),_needed,_textPartIn] , "PLAIN DOWN"];
};
DZE_ActionInProgress = false;
fixes\trade\trade_cancel.sqfprivate [];
{player removeAction _x} forEach s_player_parts;s_player_parts = [];
s_player_parts_crtl = -1;
fixes\trade\trade_items.sqfprivate ["_part_out","_part_in","_qty_out","_qty_in","_qty","_buy_o_sell","_textPartIn","_textPartOut","_bos","_needed","_started","_finished","_animState","_isMedic","_total_parts_out","_abort","_removed","_activatingPlayer","_traderID","_done"];
// [part_out,part_in, qty_out, qty_in,];
if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_103") , "PLAIN DOWN"] };
DZE_ActionInProgress = true;
_activatingPlayer = player;
_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;
_bos = 0;
if(_buy_o_sell == "sell") then {
_bos = 1;
};
_abort = false;
// perform number of total trades
r_autoTrade = true;
while {r_autoTrade} do {
_removed = 0;
cutText [(localize "str_epoch_player_105"), "PLAIN DOWN"];
r_interrupt = false;
r_doLoop = true;
_started = false;
_finished = false;
//////////////
_position = getPos player; // gets the position [x,y,z]
_posX = _position select 0; // 1th element -> x
_posY = _position select 1; // 2nd element -> y
_counter = 0.0; // animation duration checker
while {r_doLoop} do {
_positionCheck = getPos player;
_newX = _positionCheck select 0; // 1th element -> x
_newY = _positionCheck select 1; // 2nd element -> y
_counter = _counter + 0.1; // same as the sleep timer: 0.1 sec
if (_counter > 1.5) then { // amount of secs the animation takes estimated ? 2 secs?
r_doLoop = false;
_counter = 0.0;
_finished = true;
};
if (_newX != _posX || _newY != _posY) then {
r_doLoop = false;
};
sleep 0.1;
};
r_doLoop = false;
if (!_finished) exitWith {
r_interrupt = false;
if (vehicle player == player) then {
[objNull, player, rSwitchMove,""] call RE;
player playActionNow "stop";
};
cutText [(localize "str_epoch_player_106") , "PLAIN DOWN"];
};
if (_finished) then {
_canAfford = false;
if(_bos == 1) then {
//sell
_qty = {_x == _part_in} count magazines player;
if (_qty >= _qty_in) then {
_part_inClass = configFile >> "CfgMagazines" >> _part_in;
_removed = _removed + ([player,_part_inClass,_qty_in] call BIS_fnc_invRemove);
if (_removed == _qty_in) then {
_canAfford = [[[_part_out,_qty_out]],1] call epoch_returnChange;
};
};
} else {
//buy
_trade_total = [[_part_in,_qty_in]] call epoch_itemCost;
_total_currency = call epoch_totalCurrency;
_return_change = _total_currency - _trade_total;
if (_return_change >= 0) then {
_canAfford = true;
};
};
diag_log format["DEBUG TRADER DONE?: %1", _canAfford];
if (_canAfford) then {
// Continue with trade.
if (isNil "_part_in") then { _part_in = "Unknown Item" };
if (isNil "inTraderCity") then { inTraderCity = "Unknown Trader City" };
if(_bos == 1) then {
// Selling
PVDZE_obj_Trade = [_activatingPlayer,_traderID,_bos,_part_in,inTraderCity,_part_out,_qty_out];
} else {
// Buying
PVDZE_obj_Trade = [_activatingPlayer,_traderID,_bos,_part_out,inTraderCity,_part_in,_qty_in];
};
publicVariableServer "PVDZE_obj_Trade";
if(_bos == 0) then {
// only wait for result when buying
waitUntil {!isNil "dayzTradeResult"};
if(dayzTradeResult == "PASS") then {
_done = [[[_part_in,_qty_in]],0] call epoch_returnChange;
if (_done) then {
for "_x" from 1 to _qty_out do {
player addMagazine _part_out;
};
cutText [format[(localize "str_epoch_player_186"),_qty_in,_textPartIn,_qty_out,_textPartOut], "PLAIN DOWN"];
};
} else {
_abort = true;
cutText [format[(localize "str_epoch_player_183"),_textPartOut] , "PLAIN DOWN"];
};
} else {
cutText [format[(localize "str_epoch_player_186"),_qty_in,_textPartIn,_qty_out,_textPartOut], "PLAIN DOWN"];
};
dayzTradeResult = nil;
} else {
_qty = {_x == _part_in} count magazines player;
_needed = _qty_in - _qty;
cutText [format[(localize "str_epoch_player_184"),_needed,_textPartIn] , "PLAIN DOWN"];
_abort = true;
};
};
if(_abort) exitWith {r_autoTrade = false};
sleep 1;
};
DZE_ActionInProgress = false;
fixes\trade\trade_items_wo_db.sqfprivate ["_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(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_103") , "PLAIN DOWN"]; };
DZE_ActionInProgress = true;
//_activatingPlayer = getPlayerUID player;
_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;
_qty = {_x == _part_in} count magazines player;
// find total number of possible trades
_total_trades = floor (_qty / _qty_in);
if(_total_trades < 1) exitWith {
_needed = _qty_in - _qty;
cutText [format[(localize "str_epoch_player_184"),_needed,_textPartIn] , "PLAIN DOWN"];
DZE_ActionInProgress = false;
};
_abort = false;
_tradeCounter = 0;
// trade all items
for "_x" from 1 to _total_trades do {
_removed = 0;
_tradeCounter = _tradeCounter + 1;
if(_total_trades == 1) then {
cutText [format[(localize "str_epoch_player_105"),_tradeCounter,_total_trades] , "PLAIN DOWN"];
} else {
cutText [format[(localize "str_epoch_player_187"),_tradeCounter,_total_trades] , "PLAIN DOWN"];
};
[1,1] call dayz_HungerThirst;
// player playActionNow "PutDown"; //Анимация отключена
// sleep 2;
_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;
if(_part_out == "FoodBioMeat") then {
_humanityGain = _humanityGain + 20;
};
};
if(_humanityGain > 0) then {
// Increase humanity for turning in bio meat
_humanity = player getVariable["humanity",0];
_humanity = _humanity + _humanityGain;
player setVariable["humanity",_humanity,true];
};
cutText [format[(localize "str_epoch_player_186"),_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[(localize "str_epoch_player_184"),_needed,_textPartIn] , "PLAIN DOWN"];
};
sleep 1;
if(_abort) exitWith {};
};
DZE_ActionInProgress = false;
fixes\trade\trade_metals.sqfprivate ["_buy","_metals_conversion","_cancel"];
if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_103") , "PLAIN DOWN"]; };
DZE_ActionInProgress = true;
{player removeAction _x} forEach s_player_parts;s_player_parts = [];
s_player_parts_crtl = 1;
_metals_conversion = [
["ItemGoldBar","ItemSilverBar10oz",1,10,"buy","10oz Silver","Gold",102],
["ItemSilverBar10oz","ItemGoldBar",10,1,"buy","Gold","10oz Silver",101],
["ItemBriefcase100oz","ItemGoldBar10oz",1,12,"buy","10oz Gold","Full Briefcase",99]
];
// Static Menu
{
//diag_log format["DEBUG TRADER: %1", _x];
_buy = player addAction [format["Trade %1 %2 for %3 %4",(_x select 3),(_x select 5),(_x select 2),(_x select 6)], "\z\addons\dayz_code\actions\trade_items_wo_db.sqf",[(_x select 0),(_x select 1),(_x select 2),(_x select 3),(_x select 4),(_x select 5),(_x select 6)], (_x select 7), true, true, "",""];
s_player_parts set [count s_player_parts,_buy];
} forEach _metals_conversion;
_cancel = player addAction ["Cancel", "\z\addons\dayz_code\actions\trade_cancel.sqf",["na"], 0, true, false, "",""];
s_player_parts set [count s_player_parts,_cancel];
DZE_ActionInProgress = false;
fixes\trade\trade_weapons.sqfprivate ["_part_out","_part_in","_qty_out","_qty_in","_qty","_buy_o_sell","_traderID","_bos","_needed","_activatingPlayer","_textPartIn","_textPartOut","_started","_finished","_animState","_isMedic","_removed"];
// [part_out,part_in, qty_out, qty_in,"buy"];
DZE_ActionInProgress = true;
_activatingPlayer = player;
diag_log format["DEBUG WEAPONS: %1", _this];
_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;
_bos = 0;
_abort = false;
_msg = "";
if(_buy_o_sell == "sell") then {
_bos = 1;
_msg = "Need the weapon in your hands before you can sell it.";
_config = (configFile >> "CfgWeapons" >> _part_in);
_configName = configName(_config);
_abort = (!(_configName in (weapons player)));
if(_isToolBelt or _isBinocs) then {
_msg = "Need the item on your toolbelt before you can sell it.";
};
} else {
// buying item type must NOT exist if rifle or pistol
_msg = "Drop or sell your current weapon before you can buy a new one.";
_config = (configFile >> "CfgWeapons" >> _part_out);
_configName = configName(_config);
_wepType = getNumber(_config >> "Type");
_isPistol = (_wepType == 2);
_isRifle = (_wepType == 1);
_isToolBelt = (_wepType == 131072);
_isBinocs = (_wepType == 4096);
if (_isRifle) then {
_abort = ((primaryWeapon player) != "");
};
if (_isPistol) then {
_secondaryWeapon = "";
{
if ((getNumber (configFile >> "CfgWeapons" >> _x >> "Type")) == 2) exitWith {
_secondaryWeapon = _x;
};
} forEach (weapons player);
_abort = (_secondaryWeapon != "");
};
if(_isToolBelt or _isBinocs) then {
_abort = (_configName in (weapons player));
_msg = "Drop or sell your current toolbelt item before you can buy a new one.";
};
};
if (_abort) exitWith {
cutText [_msg, "PLAIN DOWN"];
DZE_ActionInProgress = false;
};
cutText [(localize "str_epoch_player_105"), "PLAIN DOWN"];
//player playActionNow "PutDown"; //Анимация отключена
_canAfford = false;
if(_bos == 1) then {
//sell
_qty = {_x == _part_in} count weapons player;
if (_qty >= _qty_in) then {
_part_inClass = configFile >> "CfgWeapons" >> _part_in;
_removed = ([player,_part_inClass,_qty_in] call BIS_fnc_invRemove);
if (_removed == _qty_in) then {
_canAfford = [[[_part_out,_qty_out]],1] call epoch_returnChange;
};
};
} else {
//buy
_trade_total = [[_part_in,_qty_in]] call epoch_itemCost;
_total_currency = call epoch_totalCurrency;
_return_change = _total_currency - _trade_total;
if (_return_change >= 0) then {
_canAfford = true;
};
};
if (_canAfford) then {
//["PVDZE_obj_Trade",[_activatingPlayer,_traderID,_bos]] call callRpcProcedure;
if (isNil "_part_out") then { _part_out = "Unknown Weapon/Magazine" };
if (isNil "inTraderCity") then { inTraderCity = "Unknown Trader City" };
if(_bos == 1) then {
// Selling
PVDZE_obj_Trade = [_activatingPlayer,_traderID,_bos,_part_in,inTraderCity,_part_out,_qty_out];
} else {
// Buying
PVDZE_obj_Trade = [_activatingPlayer,_traderID,_bos,_part_out,inTraderCity,_part_in,_qty_in];
};
publicVariableServer "PVDZE_obj_Trade";
if(_bos == 0) then {
waitUntil {!isNil "dayzTradeResult"};
//diag_log format["DEBUG Complete Trade: %1", dayzTradeResult];
if(dayzTradeResult == "PASS") then {
_done = [[[_part_in,_qty_in]],0] call epoch_returnChange;
if (_done) then {
player addWeapon _part_out;
cutText [format[(localize "str_epoch_player_186"),_qty_in,_textPartIn,_qty_out,_textPartOut], "PLAIN DOWN"];
};
} else {
cutText [format[(localize "str_epoch_player_183"),_textPartOut] , "PLAIN DOWN"];
};
} else {
// selling
cutText [format[(localize "str_epoch_player_186"),_qty_in,_textPartIn,_qty_out,_textPartOut], "PLAIN DOWN"];
};
dayzTradeResult = nil;
} else {
if(_bos == 0) then {
_qty = {_x == _part_in} count magazines player;
} else {
_qty = {_x == _part_in} count weapons player;
};
_needed = _qty_in - _qty;
cutText [format[(localize "str_epoch_player_184"),_needed,_textPartIn] , "PLAIN DOWN"];
};
DZE_ActionInProgress = false;