mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-24 09:29:21 +03:00
Move old trading files
This commit is contained in:
@@ -1,216 +0,0 @@
|
||||
private ["_sign","_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"];
|
||||
|
||||
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;};
|
||||
dayz_actionInProgress = true;
|
||||
|
||||
// [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;
|
||||
};
|
||||
|
||||
localize "str_epoch_player_105" call dayz_rollingMessages;
|
||||
|
||||
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 && !_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";
|
||||
};
|
||||
localize "str_epoch_player_106" call dayz_rollingMessages;
|
||||
dayz_actionInProgress = false;
|
||||
};
|
||||
|
||||
if (_finished) then {
|
||||
|
||||
_canAfford = false;
|
||||
if(_bos == 1) then {
|
||||
_count = {(typeOf _x) == _part_in} count (nearestObjects [(getPosATL player), [_part_in], Z_VehicleDistance]);
|
||||
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(_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);
|
||||
|
||||
// Note server now uses createVehicle "NONE" so next closest safePos is found automatically if location is blocked
|
||||
_helipad = nearestObjects [player, ["HeliHCivil","HeliHempty"], 100];
|
||||
if(count _helipad > 0) then {
|
||||
_location = getPosATL (_helipad select 0);
|
||||
} else {
|
||||
_location = [player] call FNC_GetPos;
|
||||
};
|
||||
|
||||
//place vehicle spawn marker (local)
|
||||
_sign = "Sign_arrow_down_large_EP1" createVehicleLocal [0,0,0];
|
||||
_sign setPos _location;
|
||||
_location = [_sign] call FNC_GetPos;
|
||||
[_part_out,_sign] call fn_waitForObject;
|
||||
|
||||
PVDZE_veh_Publish2 = [[_dir,_location],_part_out,true,dayz_characterID,_activatingPlayer,dayz_authKey];
|
||||
publicVariableServer "PVDZE_veh_Publish2";
|
||||
|
||||
format[localize "STR_EPOCH_PLAYER_180",_qty_in,_textPartIn,_textPartOut] call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
} else {
|
||||
format[localize "str_epoch_player_183",_textPartOut] call dayz_rollingMessages;
|
||||
};
|
||||
} else {
|
||||
//sell
|
||||
_objects = nearestObjects [(getPosATL player), [_part_in], Z_VehicleDistance];
|
||||
|
||||
//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;
|
||||
|
||||
{
|
||||
if(["Wheel",_x,false] call fnc_inString) then {
|
||||
_damage = [_obj,_x] call object_getHit;
|
||||
_tireDmg = _tireDmg + (_damage select 0);
|
||||
_tires = _tires + 1;
|
||||
};
|
||||
} count _hitpoints;
|
||||
|
||||
// find average tire damage
|
||||
if(_tireDmg > 0 && _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 && !isNull _obj && alive _obj && !_notSetup) then {
|
||||
|
||||
if(_okToSell) then {
|
||||
|
||||
|
||||
|
||||
//if(_objectID != "0" && _objectUID != "0") then {
|
||||
|
||||
PVDZ_obj_Destroy = [_objectID,_objectUID,_activatingPlayer,_obj,dayz_authKey];
|
||||
publicVariableServer "PVDZ_obj_Destroy";
|
||||
|
||||
//deleteVehicle _obj;
|
||||
|
||||
// payout
|
||||
_canAfford = [[[_part_out,_qty_out]],1] call epoch_returnChange;
|
||||
|
||||
format[localize "str_epoch_player_181",_qty_in,_textPartIn,_qty_out,_textPartOut] call dayz_rollingMessages;
|
||||
|
||||
|
||||
} else {
|
||||
format[localize "str_epoch_player_182",_textPartIn] call dayz_rollingMessages;
|
||||
};
|
||||
} else {
|
||||
localize "str_epoch_player_245" call dayz_rollingMessages;
|
||||
};
|
||||
};
|
||||
};
|
||||
dayzTradeResult = nil;
|
||||
} else {
|
||||
|
||||
if(_buy_o_sell == "buy") then {
|
||||
_qty = {_x == _part_in} count magazines player;
|
||||
_needed = _qty_in - _qty;
|
||||
format[localize "str_epoch_player_184",_needed,_textPartIn] call dayz_rollingMessages;
|
||||
} else {
|
||||
format[localize "str_epoch_player_185",_textPartIn] call dayz_rollingMessages;
|
||||
};
|
||||
};
|
||||
};
|
||||
dayz_actionInProgress = false;
|
||||
@@ -1,192 +0,0 @@
|
||||
private ["_sign","_location","_part_out","_part_in","_qty_out","_qty_in","_qty","_buy_o_sell","_obj","_objectID","_objectUID","_bos","_started","_finished","_animState","_isMedic","_dir","_helipad","_removed","_damage","_tireDmg","_tires","_okToSell","_hitpoints","_needed","_activatingPlayer","_textPartIn","_textPartOut","_traderID","_playerNear"];
|
||||
|
||||
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;};
|
||||
dayz_actionInProgress = true;
|
||||
|
||||
// [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 == "buy") then {
|
||||
_qty = {_x == _part_in} count magazines player;
|
||||
} else {
|
||||
_obj = nearestObjects [(getPosATL player), [_part_in], Z_VehicleDistance];
|
||||
_qty = count _obj;
|
||||
_bos = 1;
|
||||
};
|
||||
|
||||
if (_qty >= _qty_in) then {
|
||||
|
||||
localize "str_epoch_player_105" call dayz_rollingMessages;
|
||||
|
||||
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 && !_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";
|
||||
};
|
||||
localize "str_epoch_player_106" call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
if (_finished) then {
|
||||
|
||||
// Double check for items
|
||||
if(_buy_o_sell == "buy") then {
|
||||
_qty = {_x == _part_in} count magazines player;
|
||||
} else {
|
||||
_obj = nearestObjects [(getPosATL player), [_part_in], Z_VehicleDistance];
|
||||
_qty = count _obj;
|
||||
};
|
||||
|
||||
if (_qty >= _qty_in) then {
|
||||
|
||||
//["PVDZE_obj_Trade",[_activatingPlayer,_traderID,_bos]] call callRpcProcedure;
|
||||
if (isNil "_obj") then { _obj = "Unknown Vehicle" };
|
||||
PVDZE_obj_Trade = [_activatingPlayer,_traderID,_bos,_obj,inTraderCity];
|
||||
publicVariableServer "PVDZE_obj_Trade";
|
||||
|
||||
//diag_log format["DEBUG Starting to wait for answer: %1", PVDZE_obj_Trade];
|
||||
|
||||
waitUntil {!isNil "dayzTradeResult"};
|
||||
|
||||
//diag_log format["DEBUG Complete Trade: %1", dayzTradeResult];
|
||||
|
||||
if(dayzTradeResult == "PASS") then {
|
||||
|
||||
if(_buy_o_sell == "buy") then {
|
||||
|
||||
_removed = ([player,_part_in,_qty_in] call BIS_fnc_invRemove);
|
||||
if(_removed == _qty_in) then {
|
||||
_dir = round(random 360);
|
||||
|
||||
// Note server now uses createVehicle "NONE" so next closest safePos is found automatically if location is blocked
|
||||
_helipad = nearestObjects [player, ["HeliHCivil","HeliHempty"], 100];
|
||||
if(count _helipad > 0) then {
|
||||
_location = getPosATL (_helipad select 0);
|
||||
} else {
|
||||
_location = [player] call FNC_GetPos;
|
||||
};
|
||||
|
||||
//place vehicle spawn marker (local)
|
||||
_sign = "Sign_arrow_down_large_EP1" createVehicleLocal [0,0,0];
|
||||
_sign setPos _location;
|
||||
_location = [_sign] call FNC_GetPos;
|
||||
[_part_out,_sign] call fn_waitForObject;
|
||||
|
||||
PVDZE_veh_Publish2 = [[_dir,_location],_part_out,true,dayz_characterID,_activatingPlayer,dayz_authKey];
|
||||
publicVariableServer "PVDZE_veh_Publish2";
|
||||
|
||||
format[localize "str_epoch_player_180",_qty_in,_textPartIn,_textPartOut] call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
} else {
|
||||
|
||||
_obj = _obj 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;
|
||||
|
||||
{
|
||||
if(["Wheel",_x,false] call fnc_inString) then {
|
||||
_damage = [_obj,_x] call object_getHit;
|
||||
_tireDmg = _tireDmg + (_damage select 0);
|
||||
_tires = _tires + 1;
|
||||
};
|
||||
} count _hitpoints;
|
||||
|
||||
// find average tire damage
|
||||
if(_tireDmg > 0 && _tires > 0) then {
|
||||
if((_tireDmg / _tires) > 0.75) then {
|
||||
_okToSell = false;
|
||||
};
|
||||
};
|
||||
if(local _obj) then {
|
||||
|
||||
if(_okToSell) then {
|
||||
|
||||
if(!isNull _obj && alive _obj) then {
|
||||
|
||||
for "_x" from 1 to _qty_out do {
|
||||
player addMagazine _part_out;
|
||||
};
|
||||
|
||||
_objectID = _obj getVariable ["ObjectID","0"];
|
||||
_objectUID = _obj getVariable ["ObjectUID","0"];
|
||||
|
||||
PVDZ_obj_Destroy = [_objectID,_objectUID,_activatingPlayer,_obj,dayz_authKey];
|
||||
publicVariableServer "PVDZ_obj_Destroy";
|
||||
|
||||
//deleteVehicle _obj;
|
||||
|
||||
format[localize "str_epoch_player_181",_qty_in,_textPartIn,_qty_out,_textPartOut] call dayz_rollingMessages;
|
||||
};
|
||||
} else {
|
||||
format[localize "str_epoch_player_182",_textPartIn] call dayz_rollingMessages;
|
||||
};
|
||||
} else {
|
||||
localize "str_epoch_player_245" call dayz_rollingMessages;
|
||||
};
|
||||
};
|
||||
|
||||
{player removeAction _x} count s_player_parts;s_player_parts = [];
|
||||
s_player_parts_crtl = -1;
|
||||
|
||||
} else {
|
||||
format[localize "str_epoch_player_183",_textPartOut] call dayz_rollingMessages;
|
||||
};
|
||||
dayzTradeResult = nil;
|
||||
};
|
||||
};
|
||||
|
||||
} else {
|
||||
_needed = _qty_in - _qty;
|
||||
if(_buy_o_sell == "buy") then {
|
||||
format[localize "str_epoch_player_184",_needed,_textPartIn] call dayz_rollingMessages;
|
||||
} else {
|
||||
format[localize "str_epoch_player_185",_textPartIn] call dayz_rollingMessages;
|
||||
};
|
||||
};
|
||||
|
||||
dayz_actionInProgress = false;
|
||||
@@ -1,189 +0,0 @@
|
||||
private ["_sign","_location","_result","_part_out","_part_in","_qty_out","_qty_in","_qty","_buy_o_sell","_obj","_objectID","_objectUID","_bos","_started","_finished","_animState","_isMedic","_dir","_helipad","_damage","_tireDmg","_tires","_okToSell","_hitpoints","_needed","_activatingPlayer","_textPartIn","_textPartOut","_traderID","_canAfford","_trade_total","_total_currency","_return_change","_done"];
|
||||
|
||||
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;};
|
||||
dayz_actionInProgress = true;
|
||||
|
||||
// Test cannot lock while another player is nearby
|
||||
//_playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 12]) > 1;
|
||||
//if(_playerNear) exitWith {dayz_actionInProgress = false; localize "str_epoch_player_104" call dayz_rollingMessages;};
|
||||
|
||||
// [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;
|
||||
};
|
||||
|
||||
localize "str_epoch_player_105" call dayz_rollingMessages;
|
||||
|
||||
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 && !_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";
|
||||
};
|
||||
localize "str_epoch_player_106" call dayz_rollingMessages;
|
||||
dayz_actionInProgress = false;
|
||||
};
|
||||
|
||||
if (_finished) then {
|
||||
|
||||
_canAfford = false;
|
||||
if(_bos == 1) then {
|
||||
_count = {(typeOf _x) == _part_in} count (nearestObjects [(getPosATL player), [_part_in], Z_VehicleDistance]);
|
||||
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(_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 {
|
||||
_result = call epoch_generateKey;
|
||||
if (_result select 0) then {
|
||||
_done = [[[_part_in,_qty_in]],0] call epoch_returnChange;
|
||||
if (_done) then {
|
||||
|
||||
// spawn vehicle
|
||||
_dir = round(random 360);
|
||||
|
||||
// Note server now uses createVehicle "NONE" so next closest safePos is found automatically if location is blocked
|
||||
_helipad = nearestObjects [player, ["HeliHCivil","HeliHempty"], 100];
|
||||
if(count _helipad > 0) then {
|
||||
_location = getPosATL (_helipad select 0);
|
||||
} else {
|
||||
_location = [player] call FNC_GetPos;
|
||||
};
|
||||
|
||||
//place vehicle spawn marker (local)
|
||||
_sign = "Sign_arrow_down_large_EP1" createVehicleLocal [0,0,0];
|
||||
_sign setPos _location;
|
||||
_location = [_sign] call FNC_GetPos;
|
||||
[_part_out,_sign] call fn_waitForObject;
|
||||
|
||||
PVDZE_veh_Publish2 = [[_dir,_location],_part_out,false,_result select 1,_activatingPlayer,dayz_authKey];
|
||||
publicVariableServer "PVDZE_veh_Publish2";
|
||||
|
||||
format[localize "STR_EPOCH_ACTIONS_11",_qty_in,_textPartIn,_textPartOut] call dayz_rollingMessages;
|
||||
};
|
||||
} else {
|
||||
localize "str_epoch_player_107" call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
} else {
|
||||
format[localize "str_epoch_player_183",_textPartOut] call dayz_rollingMessages;
|
||||
};
|
||||
} else {
|
||||
//sell
|
||||
_objects = nearestObjects [(getPosATL player), [_part_in], Z_VehicleDistance];
|
||||
|
||||
//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 && !isNull _obj && alive _obj && !_notSetup) then {
|
||||
|
||||
PVDZ_obj_Destroy = [_objectID,_objectUID,_activatingPlayer,_obj,dayz_authKey];
|
||||
publicVariableServer "PVDZ_obj_Destroy";
|
||||
|
||||
//deleteVehicle _obj;
|
||||
|
||||
// payout
|
||||
_canAfford = [[[_part_out,_qty_out]],1] call epoch_returnChange;
|
||||
|
||||
format[localize "str_epoch_player_181",_qty_in,_textPartIn,_qty_out,_textPartOut] call dayz_rollingMessages;
|
||||
|
||||
} else {
|
||||
localize "str_epoch_player_245" call dayz_rollingMessages;
|
||||
};
|
||||
};
|
||||
};
|
||||
dayzTradeResult = nil;
|
||||
} else {
|
||||
|
||||
if(_buy_o_sell == "buy") then {
|
||||
_qty = {_x == _part_in} count magazines player;
|
||||
_needed = _qty_in - _qty;
|
||||
format[localize "str_epoch_player_184",_needed,_textPartIn] call dayz_rollingMessages;
|
||||
} else {
|
||||
format[localize "str_epoch_player_185",_textPartIn] call dayz_rollingMessages;
|
||||
};
|
||||
};
|
||||
};
|
||||
dayz_actionInProgress = false;
|
||||
@@ -1,175 +0,0 @@
|
||||
private ["_sign","_location","_result","_part_out","_part_in","_qty_out","_qty_in","_qty","_buy_o_sell","_obj","_objectID","_objectUID","_bos","_started","_finished","_animState","_isMedic","_dir","_helipad","_removed","_okToSell","_needed","_activatingPlayer","_textPartIn","_textPartOut","_traderID","_playerNear"];
|
||||
|
||||
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;};
|
||||
dayz_actionInProgress = true;
|
||||
|
||||
// Test cannot lock while another player is nearby
|
||||
//_playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 12]) > 1;
|
||||
//if(_playerNear) exitWith {dayz_actionInProgress = false; localize "str_epoch_player_104" call dayz_rollingMessages;};
|
||||
|
||||
// [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 == "buy") then {
|
||||
_qty = {_x == _part_in} count magazines player;
|
||||
} else {
|
||||
_obj = nearestObjects [(getPosATL player), [_part_in], Z_VehicleDistance];
|
||||
_qty = count _obj;
|
||||
_bos = 1;
|
||||
};
|
||||
|
||||
|
||||
if (_qty >= _qty_in) then {
|
||||
|
||||
localize "str_epoch_player_105" call dayz_rollingMessages;
|
||||
|
||||
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 && !_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";
|
||||
};
|
||||
localize "str_epoch_player_106" call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
if (_finished) then {
|
||||
|
||||
// Double check for items
|
||||
if(_buy_o_sell == "buy") then {
|
||||
_qty = {_x == _part_in} count magazines player;
|
||||
} else {
|
||||
_obj = nearestObjects [(getPosATL player), [_part_in], Z_VehicleDistance];
|
||||
_qty = count _obj;
|
||||
};
|
||||
|
||||
if (_qty >= _qty_in) then {
|
||||
|
||||
//["PVDZE_obj_Trade",[_activatingPlayer,_traderID,_bos]] call callRpcProcedure;
|
||||
if (isNil "_obj") then { _obj = "Unknown Vehicle" };
|
||||
PVDZE_obj_Trade = [_activatingPlayer,_traderID,_bos,_obj,inTraderCity];
|
||||
publicVariableServer "PVDZE_obj_Trade";
|
||||
|
||||
//diag_log format["DEBUG Starting to wait for answer: %1", PVDZE_obj_Trade];
|
||||
|
||||
waitUntil {!isNil "dayzTradeResult"};
|
||||
|
||||
//diag_log format["DEBUG Complete Trade: %1", dayzTradeResult];
|
||||
|
||||
if(dayzTradeResult == "PASS") then {
|
||||
|
||||
if(_buy_o_sell == "buy") then {
|
||||
_result = call epoch_generateKey;
|
||||
if (_result select 0) then {
|
||||
_removed = ([player,_part_in,_qty_in] call BIS_fnc_invRemove);
|
||||
if(_removed == _qty_in) then {
|
||||
_dir = round(random 360);
|
||||
|
||||
// Note server now uses createVehicle "NONE" so next closest safePos is found automatically if location is blocked
|
||||
_helipad = nearestObjects [player, ["HeliHCivil","HeliHempty"], 100];
|
||||
if(count _helipad > 0) then {
|
||||
_location = getPosATL (_helipad select 0);
|
||||
} else {
|
||||
_location = [player] call FNC_GetPos;
|
||||
};
|
||||
|
||||
//place vehicle spawn marker (local)
|
||||
_sign = "Sign_arrow_down_large_EP1" createVehicleLocal [0,0,0];
|
||||
_sign setPos _location;
|
||||
_location = [_sign] call FNC_GetPos;
|
||||
[_part_out,_sign] call fn_waitForObject;
|
||||
|
||||
PVDZE_veh_Publish2 = [[_dir,_location],_part_out,false,_result select 1,_activatingPlayer,dayz_authKey];
|
||||
publicVariableServer "PVDZE_veh_Publish2";
|
||||
|
||||
format["Bought %3 for %1 %2, key added to toolbelt.",_qty_in,_textPartIn,_textPartOut] call dayz_rollingMessages;
|
||||
} else {
|
||||
player removeMagazine (_result select 1);
|
||||
};
|
||||
} else {
|
||||
localize "str_epoch_player_107" call dayz_rollingMessages;
|
||||
};
|
||||
} else {
|
||||
|
||||
_obj = _obj select 0;
|
||||
|
||||
_okToSell = true;
|
||||
if(!local _obj) then {
|
||||
_okToSell = false;
|
||||
};
|
||||
|
||||
if(_okToSell && !isNull _obj && alive _obj) then {
|
||||
|
||||
for "_x" from 1 to _qty_out do {
|
||||
player addMagazine _part_out;
|
||||
};
|
||||
|
||||
_objectID = _obj getVariable ["ObjectID","0"];
|
||||
_objectUID = _obj getVariable ["ObjectUID","0"];
|
||||
|
||||
PVDZ_obj_Destroy = [_objectID,_objectUID,_activatingPlayer,_obj,dayz_authKey];
|
||||
publicVariableServer "PVDZ_obj_Destroy";
|
||||
|
||||
//deleteVehicle _obj;
|
||||
|
||||
format[localize "str_epoch_player_181",_qty_in,_textPartIn,_qty_out,_textPartOut] call dayz_rollingMessages;
|
||||
} else {
|
||||
localize "str_epoch_player_245" call dayz_rollingMessages;
|
||||
};
|
||||
};
|
||||
|
||||
{player removeAction _x} count s_player_parts;s_player_parts = [];
|
||||
s_player_parts_crtl = -1;
|
||||
|
||||
} else {
|
||||
format[localize "str_epoch_player_183",_textPartOut] call dayz_rollingMessages;
|
||||
};
|
||||
dayzTradeResult = nil;
|
||||
};
|
||||
};
|
||||
|
||||
} else {
|
||||
_needed = _qty_in - _qty;
|
||||
if(_buy_o_sell == "buy") then {
|
||||
format[localize "str_epoch_player_184",_needed,_textPartIn] call dayz_rollingMessages;
|
||||
} else {
|
||||
format[localize "str_epoch_player_185",_textPartIn] call dayz_rollingMessages;
|
||||
};
|
||||
};
|
||||
|
||||
dayz_actionInProgress = false;
|
||||
@@ -1,231 +0,0 @@
|
||||
private ["_sign","_location","_result","_part_out","_part_in","_qty_out","_qty_in","_qty","_buy_o_sell","_obj","_objectID","_objectUID","_bos","_started","_finished","_animState","_isMedic","_dir","_helipad","_damage","_tireDmg","_tires","_okToSell","_temp_keys","_hitpoints","_needed","_activatingPlayer","_textPartIn","_textPartOut","_traderID","_canAfford","_trade_total","_total_currency","_return_change","_done"];
|
||||
|
||||
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;};
|
||||
dayz_actionInProgress = true;
|
||||
|
||||
// Test cannot lock while another player is nearby
|
||||
//_playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 12]) > 1;
|
||||
//if(_playerNear) exitWith {dayz_actionInProgress = false; localize "str_epoch_player_104" call dayz_rollingMessages;};
|
||||
|
||||
// [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;
|
||||
};
|
||||
|
||||
localize "str_epoch_player_105" call dayz_rollingMessages;
|
||||
|
||||
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 && !_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";
|
||||
};
|
||||
localize "str_epoch_player_106" call dayz_rollingMessages;
|
||||
dayz_actionInProgress = false;
|
||||
};
|
||||
|
||||
if (_finished) then {
|
||||
|
||||
_canAfford = false;
|
||||
if(_bos == 1) then {
|
||||
_count = {(typeOf _x) == _part_in} count (nearestObjects [(getPosATL player), [_part_in], Z_VehicleDistance]);
|
||||
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 {
|
||||
|
||||
// if (isNil "_obj") then { _obj = "Unknown Vehicle" };
|
||||
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 {
|
||||
_result = call epoch_generateKey;
|
||||
if (_result select 0) then {
|
||||
_done = [[[_part_in,_qty_in]],0] call epoch_returnChange;
|
||||
if (_done) then {
|
||||
|
||||
// spawn vehicle
|
||||
_dir = round(random 360);
|
||||
|
||||
// Note server now uses createVehicle "NONE" so next closest safePos is found automatically if location is blocked
|
||||
_helipad = nearestObjects [player, ["HeliHCivil","HeliHempty"], 100];
|
||||
if(count _helipad > 0) then {
|
||||
_location = getPosATL (_helipad select 0);
|
||||
} else {
|
||||
_location = [player] call FNC_GetPos;
|
||||
};
|
||||
|
||||
//place vehicle spawn marker (local)
|
||||
_sign = "Sign_arrow_down_large_EP1" createVehicleLocal [0,0,0];
|
||||
_sign setPos _location;
|
||||
_location = [_sign] call FNC_GetPos;
|
||||
[_part_out,_sign] call fn_waitForObject;
|
||||
|
||||
PVDZE_veh_Publish2 = [[_dir,_location],_part_out,false,_result select 1,_activatingPlayer,dayz_authKey];
|
||||
publicVariableServer "PVDZE_veh_Publish2";
|
||||
|
||||
format[localize "STR_EPOCH_ACTIONS_11",_qty_in,_textPartIn,_textPartOut] call dayz_rollingMessages;
|
||||
};
|
||||
} else {
|
||||
localize "str_epoch_player_107" call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
} else {
|
||||
format[localize "str_epoch_player_183",_textPartOut] call dayz_rollingMessages;
|
||||
};
|
||||
} else {
|
||||
//sell
|
||||
_objects = nearestObjects [(getPosATL player), [_part_in], Z_VehicleDistance];
|
||||
|
||||
//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;
|
||||
|
||||
{
|
||||
if(["Wheel",_x,false] call fnc_inString) then {
|
||||
_damage = [_obj,_x] call object_getHit;
|
||||
_tireDmg = _tireDmg + (_damage select 0);
|
||||
_tires = _tires + 1;
|
||||
};
|
||||
} count _hitpoints;
|
||||
|
||||
// find average tire damage
|
||||
if(_tireDmg > 0 && _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 && !isNull _obj && alive _obj && !_notSetup) then {
|
||||
|
||||
if(_okToSell) then {
|
||||
|
||||
//if(_objectID != "0" && _objectUID != "0") then {
|
||||
|
||||
PVDZ_obj_Destroy = [_objectID,_objectUID,_activatingPlayer,_obj,dayz_authKey];
|
||||
publicVariableServer "PVDZ_obj_Destroy";
|
||||
|
||||
//deleteVehicle _obj;
|
||||
|
||||
// remove Key
|
||||
_temp_keys = [];
|
||||
{
|
||||
if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in DZE_itemKeys) then {
|
||||
if (str(getNumber(configFile >> "CfgWeapons" >> _x >> "keyid")) == _objectCharacterId) then {
|
||||
[_activatingPlayer,_x] call BIS_fnc_invRemove;
|
||||
};
|
||||
};
|
||||
} count (items _activatingPlayer);
|
||||
|
||||
// payout
|
||||
_canAfford = [[[_part_out,_qty_out]],1] call epoch_returnChange;
|
||||
|
||||
format[localize "str_epoch_player_181",_qty_in,_textPartIn,_qty_out,_textPartOut] call dayz_rollingMessages;
|
||||
|
||||
|
||||
} else {
|
||||
format[localize "str_epoch_player_182",_textPartIn] call dayz_rollingMessages;
|
||||
};
|
||||
} else {
|
||||
localize "str_epoch_player_245" call dayz_rollingMessages;
|
||||
};
|
||||
};
|
||||
};
|
||||
dayzTradeResult = nil;
|
||||
} else {
|
||||
if(_buy_o_sell == "buy") then {
|
||||
_qty = {_x == _part_in} count magazines player;
|
||||
_needed = _qty_in - _qty;
|
||||
format[localize "str_epoch_player_184",_needed,_textPartIn] call dayz_rollingMessages;
|
||||
} else {
|
||||
format[localize "str_epoch_player_185",_textPartIn] call dayz_rollingMessages;
|
||||
};
|
||||
};
|
||||
};
|
||||
dayz_actionInProgress = false;
|
||||
@@ -1,217 +0,0 @@
|
||||
private ["_sign","_location","_part_out","_part_in","_qty_out","_qty_in","_qty","_buy_o_sell","_obj","_objectID","_objectUID","_bos","_started","_finished","_animState","_isMedic","_dir","_helipad","_damage","_tireDmg","_tires","_okToSell","_hitpoints","_needed","_activatingPlayer","_textPartIn","_textPartOut","_traderID","_canAfford","_trade_total","_total_currency","_return_change","_done"];
|
||||
|
||||
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;};
|
||||
dayz_actionInProgress = true;
|
||||
|
||||
// Test cannot lock while another player is nearby
|
||||
//_playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 12]) > 1;
|
||||
//if(_playerNear) exitWith {dayz_actionInProgress = false; localize "str_epoch_player_104" call dayz_rollingMessages;};
|
||||
|
||||
// [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;
|
||||
};
|
||||
|
||||
localize "str_epoch_player_105" call dayz_rollingMessages;
|
||||
|
||||
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 && !_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";
|
||||
};
|
||||
localize "str_epoch_player_106" call dayz_rollingMessages;
|
||||
dayz_actionInProgress = false;
|
||||
};
|
||||
|
||||
if (_finished) then {
|
||||
|
||||
_canAfford = false;
|
||||
if(_bos == 1) then {
|
||||
_count = {(typeOf _x) == _part_in} count (nearestObjects [(getPosATL player), [_part_in], Z_VehicleDistance]);
|
||||
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 {
|
||||
|
||||
// if (isNil "_obj") then { _obj = "Unknown Vehicle" };
|
||||
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);
|
||||
|
||||
// Note server now uses createVehicle "NONE" so next closest safePos is found automatically if location is blocked
|
||||
_helipad = nearestObjects [player, ["HeliHCivil","HeliHempty"], 100];
|
||||
if(count _helipad > 0) then {
|
||||
_location = getPosATL (_helipad select 0);
|
||||
} else {
|
||||
_location = [player] call FNC_GetPos;
|
||||
};
|
||||
|
||||
//place vehicle spawn marker (local)
|
||||
_sign = "Sign_arrow_down_large_EP1" createVehicleLocal [0,0,0];
|
||||
_sign setPos _location;
|
||||
_location = [_sign] call FNC_GetPos;
|
||||
[_part_out,_sign] call fn_waitForObject;
|
||||
|
||||
PVDZE_veh_Publish2 = [[_dir,_location],_part_out,true,0,_activatingPlayer,dayz_authKey];
|
||||
publicVariableServer "PVDZE_veh_Publish2";
|
||||
};
|
||||
|
||||
} else {
|
||||
format[localize "str_epoch_player_183",_textPartOut] call dayz_rollingMessages;
|
||||
};
|
||||
} else {
|
||||
|
||||
//sell
|
||||
_objects = nearestObjects [(getPosATL player), [_part_in], Z_VehicleDistance];
|
||||
|
||||
//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;
|
||||
|
||||
{
|
||||
if(["Wheel",_x,false] call fnc_inString) then {
|
||||
_damage = [_obj,_x] call object_getHit;
|
||||
_tireDmg = _tireDmg + (_damage select 0);
|
||||
_tires = _tires + 1;
|
||||
};
|
||||
} count _hitpoints;
|
||||
|
||||
// find average tire damage
|
||||
if(_tireDmg > 0 && _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 && !isNull _obj && alive _obj && !_notSetup) then {
|
||||
|
||||
if(_okToSell) then {
|
||||
|
||||
|
||||
|
||||
//if(_objectID != "0" && _objectUID != "0") then {
|
||||
|
||||
PVDZ_obj_Destroy = [_objectID,_objectUID,_activatingPlayer,_obj,dayz_authKey];
|
||||
publicVariableServer "PVDZ_obj_Destroy";
|
||||
|
||||
//deleteVehicle _obj;
|
||||
|
||||
// payout
|
||||
_canAfford = [[[_part_out,_qty_out]],1] call epoch_returnChange;
|
||||
|
||||
format[localize "str_epoch_player_181",_qty_in,_textPartIn,_qty_out,_textPartOut] call dayz_rollingMessages;
|
||||
|
||||
|
||||
} else {
|
||||
format[localize "str_epoch_player_182",_textPartIn] call dayz_rollingMessages;
|
||||
};
|
||||
} else {
|
||||
localize "str_epoch_player_245" call dayz_rollingMessages;
|
||||
};
|
||||
};
|
||||
};
|
||||
dayzTradeResult = nil;
|
||||
} else {
|
||||
if(_buy_o_sell == "buy") then {
|
||||
_qty = {_x == _part_in} count magazines player;
|
||||
_needed = _qty_in - _qty;
|
||||
format[localize "str_epoch_player_184",_needed,_textPartIn] call dayz_rollingMessages;
|
||||
} else {
|
||||
format[localize "str_epoch_player_185",_textPartIn] call dayz_rollingMessages;
|
||||
};
|
||||
};
|
||||
};
|
||||
dayz_actionInProgress = false;
|
||||
@@ -1,200 +0,0 @@
|
||||
private ["_sign","_location","_result","_part_out","_part_in","_qty_out","_qty_in","_qty","_buy_o_sell","_obj","_objectID","_objectUID","_bos","_started","_finished","_animState","_isMedic","_dir","_helipad","_removed","_damage","_tireDmg","_tires","_okToSell","_hitpoints","_needed","_activatingPlayer","_textPartIn","_textPartOut","_traderID","_playerNear"];
|
||||
|
||||
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;};
|
||||
dayz_actionInProgress = true;
|
||||
|
||||
// Test cannot lock while another player is nearby
|
||||
//_playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 12]) > 1;
|
||||
//if(_playerNear) exitWith {dayz_actionInProgress = false; localize "str_epoch_player_104" call dayz_rollingMessages;};
|
||||
|
||||
// [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 == "buy") then {
|
||||
_qty = {_x == _part_in} count magazines player;
|
||||
} else {
|
||||
_obj = nearestObjects [(getPosATL player), [_part_in], Z_VehicleDistance];
|
||||
_qty = count _obj;
|
||||
_bos = 1;
|
||||
};
|
||||
|
||||
if (_qty >= _qty_in) then {
|
||||
|
||||
localize "str_epoch_player_105" call dayz_rollingMessages;
|
||||
|
||||
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 && !_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";
|
||||
};
|
||||
localize "str_epoch_player_106" call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
if (_finished) then {
|
||||
|
||||
// Double check for items
|
||||
if(_buy_o_sell == "buy") then {
|
||||
_qty = {_x == _part_in} count magazines player;
|
||||
} else {
|
||||
_obj = nearestObjects [(getPosATL player), [_part_in], Z_VehicleDistance];
|
||||
_qty = count _obj;
|
||||
};
|
||||
|
||||
if (_qty >= _qty_in) then {
|
||||
|
||||
if (isNil "_obj") then { _obj = "Unknown Vehicle" };
|
||||
PVDZE_obj_Trade = [_activatingPlayer,_traderID,_bos,_obj,inTraderCity];
|
||||
publicVariableServer "PVDZE_obj_Trade";
|
||||
|
||||
//diag_log format["DEBUG Starting to wait for answer: %1", PVDZE_obj_Trade];
|
||||
|
||||
waitUntil {!isNil "dayzTradeResult"};
|
||||
|
||||
//diag_log format["DEBUG Complete Trade: %1", dayzTradeResult];
|
||||
|
||||
if(dayzTradeResult == "PASS") then {
|
||||
|
||||
if(_buy_o_sell == "buy") then {
|
||||
_result = call epoch_generateKey;
|
||||
if (_result select 0) then {
|
||||
_removed = ([player,_part_in,_qty_in] call BIS_fnc_invRemove);
|
||||
if(_removed == _qty_in) then {
|
||||
_dir = round(random 360);
|
||||
|
||||
// Note server now uses createVehicle "NONE" so next closest safePos is found automatically if location is blocked
|
||||
_helipad = nearestObjects [player, ["HeliHCivil","HeliHempty"], 100];
|
||||
if(count _helipad > 0) then {
|
||||
_location = getPosATL (_helipad select 0);
|
||||
} else {
|
||||
_location = [player] call FNC_GetPos;
|
||||
};
|
||||
|
||||
//place vehicle spawn marker (local)
|
||||
_sign = "Sign_arrow_down_large_EP1" createVehicleLocal [0,0,0];
|
||||
_sign setPos _location;
|
||||
_location = [_sign] call FNC_GetPos;
|
||||
[_part_out,_sign] call fn_waitForObject;
|
||||
|
||||
PVDZE_veh_Publish2 = [[_dir,_location],_part_out,false,_result select 1,_activatingPlayer,dayz_authKey];
|
||||
publicVariableServer "PVDZE_veh_Publish2";
|
||||
|
||||
format["Bought %3 for %1 %2, key added to toolbelt.",_qty_in,_textPartIn,_textPartOut] call dayz_rollingMessages;
|
||||
} else {
|
||||
player removeMagazine (_result select 1);
|
||||
};
|
||||
} else {
|
||||
localize "str_epoch_player_107" call dayz_rollingMessages;
|
||||
};
|
||||
} else {
|
||||
|
||||
_obj = _obj 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;
|
||||
|
||||
{
|
||||
if(["Wheel",_x,false] call fnc_inString) then {
|
||||
_damage = [_obj,_x] call object_getHit;
|
||||
_tireDmg = _tireDmg + (_damage select 0);
|
||||
_tires = _tires + 1;
|
||||
};
|
||||
} count _hitpoints;
|
||||
|
||||
// find average tire damage
|
||||
if(_tireDmg > 0 && _tires > 0) then {
|
||||
if((_tireDmg / _tires) > 0.75) then {
|
||||
_okToSell = false;
|
||||
};
|
||||
};
|
||||
|
||||
if(local _obj && !isNull _obj && alive _obj) then {
|
||||
|
||||
if(_okToSell) then {
|
||||
|
||||
for "_x" from 1 to _qty_out do {
|
||||
player addMagazine _part_out;
|
||||
};
|
||||
|
||||
_objectID = _obj getVariable ["ObjectID","0"];
|
||||
_objectUID = _obj getVariable ["ObjectUID","0"];
|
||||
|
||||
PVDZ_obj_Destroy = [_objectID,_objectUID,_activatingPlayer,_obj,dayz_authKey];
|
||||
publicVariableServer "PVDZ_obj_Destroy";
|
||||
|
||||
//deleteVehicle _obj;
|
||||
|
||||
format[localize "str_epoch_player_181",_qty_in,_textPartIn,_qty_out,_textPartOut] call dayz_rollingMessages;
|
||||
|
||||
} else {
|
||||
format[localize "str_epoch_player_182",_textPartIn] call dayz_rollingMessages;
|
||||
};
|
||||
} else {
|
||||
localize "str_epoch_player_245" call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
{player removeAction _x} count s_player_parts;s_player_parts = [];
|
||||
s_player_parts_crtl = -1;
|
||||
|
||||
} else {
|
||||
format[localize "str_epoch_player_183",_textPartOut] call dayz_rollingMessages;
|
||||
};
|
||||
dayzTradeResult = nil;
|
||||
};
|
||||
};
|
||||
|
||||
} else {
|
||||
_needed = _qty_in - _qty;
|
||||
if(_buy_o_sell == "buy") then {
|
||||
format[localize "str_epoch_player_184",_needed,_textPartIn] call dayz_rollingMessages;
|
||||
} else {
|
||||
format[localize "str_epoch_player_185",_textPartIn] call dayz_rollingMessages;
|
||||
};
|
||||
};
|
||||
|
||||
dayz_actionInProgress = false;
|
||||
@@ -1,133 +0,0 @@
|
||||
private ["_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,];
|
||||
|
||||
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;};
|
||||
dayz_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;
|
||||
};
|
||||
|
||||
localize "str_epoch_player_105" call dayz_rollingMessages;
|
||||
|
||||
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 && !_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";
|
||||
};
|
||||
dayz_actionInProgress = false;
|
||||
localize "str_epoch_player_106" call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
if (_finished) then {
|
||||
|
||||
_canAfford = false;
|
||||
_qty = 0;
|
||||
if(_bos == 1) then {
|
||||
|
||||
//sell
|
||||
_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 {
|
||||
|
||||
if (isNil "_bag") then { _bag = "Unknown Backpack" };
|
||||
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;
|
||||
format[localize "str_epoch_player_186",_qty_in,_textPartIn,_qty_out,_textPartOut] call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
} else {
|
||||
format[localize "str_epoch_player_183",_textPartOut] call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
} else {
|
||||
format[localize "str_epoch_player_186",_qty_in,_textPartIn,_qty_out,_textPartOut] call dayz_rollingMessages;
|
||||
};
|
||||
dayzTradeResult = nil;
|
||||
} else {
|
||||
_needed = _qty_in - _qty;
|
||||
format[localize "str_epoch_player_184",_needed,_textPartIn] call dayz_rollingMessages;
|
||||
};
|
||||
};
|
||||
|
||||
dayz_actionInProgress = false;
|
||||
@@ -1,131 +0,0 @@
|
||||
private ["_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,];
|
||||
|
||||
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;};
|
||||
dayz_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 == "buy") then {
|
||||
_qty = {_x == _part_in} count magazines player;
|
||||
} else {
|
||||
_bos = 1;
|
||||
_qty = 0;
|
||||
_bag = unitBackpack player;
|
||||
_class = typeOf _bag;
|
||||
if(_class == _part_in) then {
|
||||
_qty = 1;
|
||||
};
|
||||
};
|
||||
|
||||
if (_qty >= _qty_in) then {
|
||||
|
||||
localize "str_epoch_player_105" call dayz_rollingMessages;
|
||||
|
||||
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 && !_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";
|
||||
};
|
||||
localize "str_epoch_player_106" call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
if (_finished) then {
|
||||
|
||||
// Double check we still have parts
|
||||
if(_buy_o_sell == "buy") then {
|
||||
_qty = {_x == _part_in} count magazines player;
|
||||
} else {
|
||||
_qty = 0;
|
||||
_bag = unitBackpack player;
|
||||
_class = typeOf _bag;
|
||||
if(_class == _part_in) then {
|
||||
_qty = 1;
|
||||
};
|
||||
};
|
||||
|
||||
if (_qty >= _qty_in) then {
|
||||
|
||||
if (isNil "_bag") then { _bag = "Unknown Backpack" };
|
||||
PVDZE_obj_Trade = [_activatingPlayer,_traderID,_bos,_bag,inTraderCity];
|
||||
publicVariableServer "PVDZE_obj_Trade";
|
||||
|
||||
//diag_log format["DEBUG Starting to wait for answer: %1", PVDZE_obj_Trade];
|
||||
|
||||
waitUntil {!isNil "dayzTradeResult"};
|
||||
|
||||
//diag_log format["DEBUG Complete Trade: %1", dayzTradeResult];
|
||||
|
||||
if(dayzTradeResult == "PASS") then {
|
||||
|
||||
if(_buy_o_sell == "buy") then {
|
||||
|
||||
_num_removed = ([player,_part_in,_qty_in] call BIS_fnc_invRemove);
|
||||
if(_num_removed == _qty_in) then {
|
||||
removeBackpack player;
|
||||
player addBackpack _part_out;
|
||||
};
|
||||
} else {
|
||||
// Sell
|
||||
if((typeOf (unitBackpack player)) == _part_in) then {
|
||||
removeBackpack player;
|
||||
for "_x" from 1 to _qty_out do {
|
||||
player addMagazine _part_out;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
format[localize "str_epoch_player_186",_qty_in,_textPartIn,_qty_out,_textPartOut] call dayz_rollingMessages;
|
||||
|
||||
{player removeAction _x} count s_player_parts;s_player_parts = [];
|
||||
s_player_parts_crtl = -1;
|
||||
|
||||
} else {
|
||||
format[localize "str_epoch_player_183",_textPartOut] call dayz_rollingMessages;
|
||||
};
|
||||
dayzTradeResult = nil;
|
||||
};
|
||||
};
|
||||
|
||||
} else {
|
||||
_needed = _qty_in - _qty;
|
||||
format[localize "str_epoch_player_184",_needed,_textPartIn] call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
dayz_actionInProgress = false;
|
||||
@@ -1,3 +0,0 @@
|
||||
private [];
|
||||
{player removeAction _x} count s_player_parts;s_player_parts = [];
|
||||
s_player_parts_crtl = -1;
|
||||
@@ -1,148 +0,0 @@
|
||||
private ["_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","_actualMags"];
|
||||
// [part_out,part_in, qty_out, qty_in,];
|
||||
|
||||
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;};
|
||||
dayz_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;
|
||||
|
||||
// check if current magazine count is greater than 20
|
||||
_actualMags = {!(_x in MeleeMagazines)} count (magazines player);
|
||||
if (_actualMags > 20) exitWith {localize "str_player_24" call dayz_rollingMessages; r_autoTrade = false};
|
||||
|
||||
_canAfford = false;
|
||||
if(_bos == 1) then {
|
||||
|
||||
//sell
|
||||
_qty = {_x == _part_in} count magazines player;
|
||||
if (_qty >= _qty_in) then {
|
||||
_canAfford = true;
|
||||
};
|
||||
|
||||
} 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) exitWith {
|
||||
_qty = {_x == _part_in} count magazines player;
|
||||
_needed = _qty_in - _qty;
|
||||
format[localize "str_epoch_player_184",_needed,_textPartIn] call dayz_rollingMessages;
|
||||
r_autoTrade = false
|
||||
};
|
||||
|
||||
localize "str_epoch_player_105" call dayz_rollingMessages;
|
||||
|
||||
player playActionNow "Medic";
|
||||
|
||||
//_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;
|
||||
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";
|
||||
};
|
||||
localize "str_epoch_player_106" call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
if (_finished) then {
|
||||
|
||||
//diag_log format["DEBUG TRADER DONE?: %1", _canAfford];
|
||||
|
||||
// Continue with trade.
|
||||
if (isNil "_part_in") then { _part_in = "Unknown Item" };
|
||||
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;
|
||||
};
|
||||
format[localize "str_epoch_player_186",_qty_in,_textPartIn,_qty_out,_textPartOut] call dayz_rollingMessages;
|
||||
};
|
||||
} else {
|
||||
_abort = true;
|
||||
format[localize "str_epoch_player_183",_textPartOut] call dayz_rollingMessages;
|
||||
};
|
||||
} else {
|
||||
_part_inClass = configFile >> "CfgMagazines" >> _part_in;
|
||||
_removed = _removed + ([player,_part_inClass,_qty_in] call BIS_fnc_invRemove);
|
||||
if (_removed == _qty_in) then {
|
||||
[[[_part_out,_qty_out]],1] call epoch_returnChange;
|
||||
};
|
||||
format[localize "str_epoch_player_186",_qty_in,_textPartIn,_qty_out,_textPartOut] call dayz_rollingMessages;
|
||||
};
|
||||
dayzTradeResult = nil;
|
||||
};
|
||||
if(_abort) exitWith {r_autoTrade = false};
|
||||
|
||||
uiSleep 1;
|
||||
};
|
||||
|
||||
dayz_actionInProgress = false;
|
||||
@@ -1,272 +0,0 @@
|
||||
private ["_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","_tradeCounter","_next_highest_bar","_third_highest_bar","_next_highest_conv","_third_highest_conv","_third_parts_out_raw","_third_parts_out","_remainder","_next_parts_out_raw","_next_parts_out","_activatingPlayer","_traderID","_total_trades"];
|
||||
// [part_out,part_in, qty_out, qty_in,];
|
||||
|
||||
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;};
|
||||
dayz_actionInProgress = true;
|
||||
|
||||
_total_parts_out = 0;
|
||||
|
||||
_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;
|
||||
|
||||
_removed = 0;
|
||||
_tradeCounter = 0;
|
||||
|
||||
_bos = 0;
|
||||
if(_buy_o_sell == "sell") then {
|
||||
_bos = 1;
|
||||
};
|
||||
|
||||
// Get total parts in
|
||||
_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;
|
||||
format[localize "str_epoch_player_184",_needed,_textPartIn] call dayz_rollingMessages;
|
||||
dayz_actionInProgress = false;
|
||||
};
|
||||
|
||||
// perform number of total trades
|
||||
for "_x" from 1 to _total_trades do {
|
||||
|
||||
_removed = 0;
|
||||
_tradeCounter = _tradeCounter + 1;
|
||||
|
||||
// "Starting trade, stand still to complete." call dayz_rollingMessages;
|
||||
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;
|
||||
};
|
||||
|
||||
player playActionNow "Medic";
|
||||
|
||||
//_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;
|
||||
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";
|
||||
};
|
||||
localize "str_epoch_player_106" call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
if (_finished) then {
|
||||
|
||||
_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 {
|
||||
|
||||
// Continue with trade.
|
||||
if (isNil "_part_in") then { _part_in = "Unknown Item" };
|
||||
PVDZE_obj_Trade = [_activatingPlayer,_traderID,_bos,_part_in,inTraderCity];
|
||||
publicVariableServer "PVDZE_obj_Trade";
|
||||
|
||||
waitUntil {!isNil "dayzTradeResult"};
|
||||
|
||||
if(dayzTradeResult == "PASS") then {
|
||||
|
||||
// total of all parts
|
||||
_total_parts_out = _total_parts_out + _qty_out;
|
||||
|
||||
format[localize "str_epoch_player_186",_qty_in,_textPartIn,_qty_out,_textPartOut] call dayz_rollingMessages;
|
||||
|
||||
} else {
|
||||
format[localize "str_epoch_player_183",_textPartOut] call dayz_rollingMessages;
|
||||
_abort = true;
|
||||
|
||||
// Return items taken
|
||||
for "_x" from 1 to _removed do {
|
||||
player addMagazine _part_in;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
dayzTradeResult = nil;
|
||||
|
||||
} 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;
|
||||
};
|
||||
};
|
||||
|
||||
uiSleep 1;
|
||||
|
||||
if(_abort) exitWith {};
|
||||
};
|
||||
|
||||
// pay out
|
||||
if(_total_parts_out >= 1) then {
|
||||
|
||||
//diag_log format["DEBUG TRADE #: %1", _total_parts_out];
|
||||
|
||||
if(_bos == 1) then {
|
||||
//convert currency trades into next bar
|
||||
// 10 ItemCopperBar > ItemCopperBar10oz
|
||||
// 3 ItemCopperBar10oz > ItemSilverBar
|
||||
// 10 ItemSilverBar > ItemSilverBar10oz
|
||||
// 3 ItemSilverBar10oz > ItemGoldBar
|
||||
// 10 ItemGoldBar > ItemGoldBar10oz
|
||||
|
||||
_next_highest_bar = "NA";
|
||||
_third_highest_bar = "NA";
|
||||
_next_highest_conv = 10000;
|
||||
_third_highest_conv = 10000;
|
||||
|
||||
switch(true)do{
|
||||
case (_part_out == "ItemCopperBar"): {
|
||||
_next_highest_bar = "ItemCopperBar10oz";
|
||||
_third_highest_bar = "ItemSilverBar";
|
||||
_next_highest_conv = 10;
|
||||
_third_highest_conv = 3;
|
||||
};
|
||||
case (_part_out == "ItemCopperBar10oz"): {
|
||||
_next_highest_bar = "ItemSilverBar";
|
||||
_third_highest_bar = "ItemSilverBar10oz";
|
||||
_next_highest_conv = 3;
|
||||
_third_highest_conv = 10;
|
||||
};
|
||||
case (_part_out == "ItemSilverBar"): {
|
||||
_next_highest_bar = "ItemSilverBar10oz";
|
||||
_third_highest_bar = "ItemGoldBar";
|
||||
_next_highest_conv = 10;
|
||||
_third_highest_conv = 3;
|
||||
};
|
||||
case (_part_out == "ItemSilverBar10oz"): {
|
||||
_next_highest_bar = "ItemGoldBar";
|
||||
_third_highest_bar = "ItemGoldBar10oz";
|
||||
_next_highest_conv = 3;
|
||||
_third_highest_conv = 10;
|
||||
};
|
||||
case (_part_out == "ItemGoldBar"): {
|
||||
_next_highest_bar = "ItemGoldBar10oz";
|
||||
_third_highest_bar = "NA";
|
||||
_next_highest_conv = 10;
|
||||
_third_highest_conv = 10000;
|
||||
};
|
||||
};
|
||||
|
||||
//diag_log format["DEBUG TRADE part: %1 next: %2", _part_out,_next_highest_bar];
|
||||
|
||||
if(_total_parts_out >= _next_highest_conv) then {
|
||||
_next_parts_out_raw = _total_parts_out / _next_highest_conv;
|
||||
|
||||
// whole parts
|
||||
_next_parts_out = floor(_next_parts_out_raw);
|
||||
|
||||
//diag_log format["DEBUG TRADE next whole parts: %1 part: %2", _next_parts_out,_next_highest_bar];
|
||||
|
||||
// find any whole remains
|
||||
_remainder = floor((_next_parts_out_raw - _next_parts_out) * _next_highest_conv);
|
||||
|
||||
//diag_log format["DEBUG TRADE remainder parts: %1 part: %2", _remainder,_part_out];
|
||||
|
||||
for "_x" from 1 to _remainder do {
|
||||
player addMagazine _part_out;
|
||||
};
|
||||
|
||||
// Find if needs further conversion
|
||||
if (_next_parts_out >= _third_highest_conv) then {
|
||||
|
||||
_third_parts_out_raw = _next_parts_out / _third_highest_conv;
|
||||
|
||||
// whole parts
|
||||
_third_parts_out = floor(_third_parts_out_raw);
|
||||
|
||||
//diag_log format["DEBUG TRADE third whole parts: %1 part: %2", _third_parts_out,_third_highest_bar];
|
||||
|
||||
for "_x" from 1 to _third_parts_out do {
|
||||
player addMagazine _third_highest_bar;
|
||||
};
|
||||
|
||||
// find any whole remains
|
||||
_remainder = floor((_third_parts_out_raw - _third_parts_out) * _third_highest_conv);
|
||||
|
||||
//diag_log format["DEBUG TRADE remainder parts: %1 part: %2", _remainder,_next_highest_bar];
|
||||
|
||||
for "_x" from 1 to _remainder do {
|
||||
player addMagazine _next_highest_bar;
|
||||
};
|
||||
|
||||
} else {
|
||||
|
||||
//diag_log format["DEBUG TRADE next parts: %1 part: %2", _next_parts_out,_next_highest_bar];
|
||||
|
||||
for "_x" from 1 to _next_parts_out do {
|
||||
player addMagazine _next_highest_bar;
|
||||
};
|
||||
};
|
||||
|
||||
} else {
|
||||
|
||||
//diag_log "DEBUG TRADE SELLING NORMALLY";
|
||||
|
||||
for "_x" from 1 to _total_parts_out do {
|
||||
player addMagazine _part_out;
|
||||
};
|
||||
};
|
||||
|
||||
} else {
|
||||
|
||||
//diag_log "DEBUG TRADE BUYING";
|
||||
|
||||
for "_x" from 1 to _total_parts_out do {
|
||||
player addMagazine _part_out;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
dayz_actionInProgress = false;
|
||||
@@ -1,26 +0,0 @@
|
||||
private ["_buy","_metals_conversion","_cancel"];
|
||||
|
||||
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;};
|
||||
dayz_actionInProgress = true;
|
||||
|
||||
{player removeAction _x} count 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];
|
||||
|
||||
} count _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];
|
||||
|
||||
dayz_actionInProgress = false;
|
||||
@@ -1,185 +0,0 @@
|
||||
private ["_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"];
|
||||
|
||||
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;};
|
||||
dayz_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);
|
||||
_wepType = getNumber(_config >> "Type");
|
||||
|
||||
_isToolBelt = (_wepType == 131072);
|
||||
_isBinocs = (_wepType == 4096);
|
||||
|
||||
_abort = (!(_configName in (weapons player)));
|
||||
|
||||
if(_isToolBelt || _isBinocs) then {
|
||||
_msg = "Need the item on your toolbelt before you can sell it.";
|
||||
};
|
||||
|
||||
} else {
|
||||
|
||||
// buying item type must NOT exist if rifle || 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;
|
||||
};
|
||||
} count (weapons player);
|
||||
_abort = (_secondaryWeapon != "");
|
||||
};
|
||||
if(_isToolBelt || _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 {
|
||||
_msg call dayz_rollingMessages;
|
||||
dayz_actionInProgress = false;
|
||||
};
|
||||
|
||||
localize "str_epoch_player_105" call dayz_rollingMessages;
|
||||
|
||||
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 && !_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";
|
||||
};
|
||||
dayz_actionInProgress = false;
|
||||
localize "str_epoch_player_106" call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
if (_finished) then {
|
||||
|
||||
_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 {
|
||||
|
||||
if (isNil "_part_out") then { _part_out = "Unknown Weapon/Magazine" };
|
||||
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;
|
||||
format[localize "str_epoch_player_186",_qty_in,_textPartIn,_qty_out,_textPartOut] call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
} else {
|
||||
format[localize "str_epoch_player_183",_textPartOut] call dayz_rollingMessages;
|
||||
};
|
||||
} else {
|
||||
// selling
|
||||
format[localize "str_epoch_player_186",_qty_in,_textPartIn,_qty_out,_textPartOut] call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
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;
|
||||
format[localize "str_epoch_player_184",_needed,_textPartIn] call dayz_rollingMessages;
|
||||
};
|
||||
};
|
||||
|
||||
dayz_actionInProgress = false;
|
||||
@@ -1,121 +0,0 @@
|
||||
private ["_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"];
|
||||
|
||||
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;};
|
||||
dayz_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 == "buy") then {
|
||||
_qty = {_x == _part_in} count magazines player;
|
||||
|
||||
} else {
|
||||
_qty = {_x == _part_in} count weapons player;
|
||||
_bos = 1;
|
||||
};
|
||||
|
||||
if (_qty >= _qty_in) then {
|
||||
|
||||
localize "str_epoch_player_105" call dayz_rollingMessages;
|
||||
|
||||
player playActionNow "Medic";
|
||||
|
||||
//_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;
|
||||
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";
|
||||
};
|
||||
localize "str_epoch_player_106" call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
if (_finished) then {
|
||||
|
||||
// double check for all parts
|
||||
if(_buy_o_sell == "buy") then {
|
||||
_qty = {_x == _part_in} count magazines player;
|
||||
} else {
|
||||
_qty = {_x == _part_in} count weapons player;
|
||||
};
|
||||
|
||||
if (_qty >= _qty_in) then {
|
||||
|
||||
if (isNil "_part_out") then { _part_out = "Unknown Weapon/Magazine" };
|
||||
PVDZE_obj_Trade = [_activatingPlayer,_traderID,_bos,_part_out,inTraderCity];
|
||||
publicVariableServer "PVDZE_obj_Trade";
|
||||
|
||||
waitUntil {!isNil "dayzTradeResult"};
|
||||
|
||||
//diag_log format["DEBUG Complete Trade: %1", dayzTradeResult];
|
||||
|
||||
if(dayzTradeResult == "PASS") then {
|
||||
|
||||
_removed = ([player,_part_in,_qty_in] call BIS_fnc_invRemove);
|
||||
|
||||
if(_removed == _qty_in) then {
|
||||
for "_x" from 1 to _qty_out do {
|
||||
if(_buy_o_sell == "buy") then {
|
||||
player addWeapon _part_out;
|
||||
} else {
|
||||
player addMagazine _part_out;
|
||||
};
|
||||
};
|
||||
format[localize "str_epoch_player_186",_qty_in,_textPartIn,_qty_out,_textPartOut] call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
|
||||
|
||||
{player removeAction _x} count s_player_parts;s_player_parts = [];
|
||||
s_player_parts_crtl = -1;
|
||||
|
||||
} else {
|
||||
format[localize "str_epoch_player_183",_textPartOut] call dayz_rollingMessages;
|
||||
};
|
||||
dayzTradeResult = nil;
|
||||
};
|
||||
};
|
||||
|
||||
} else {
|
||||
_needed = _qty_in - _qty;
|
||||
format[localize "str_epoch_player_184",_needed,_textPartIn] call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
dayz_actionInProgress = false;
|
||||
Reference in New Issue
Block a user