diff --git a/dayz_code/actions/buy_db.sqf b/dayz_code/actions/buy_db.sqf index 6693848b6..0442db8c7 100644 --- a/dayz_code/actions/buy_db.sqf +++ b/dayz_code/actions/buy_db.sqf @@ -8,24 +8,15 @@ _activatingPlayer = _this select 1; _trader_id = (_this select 3) select 0; _category = (_this select 3) select 1; -diag_log format["DEBUG TRADER OBJ: %1", _trader_id]; +dayzTraderMenuResult = call compile format["tcacheBuy_%1;",_trader_id]; -//["dayzTraderMenu",[_activatingPlayer,_trader_id,_category,_action]] call callRpcProcedure; -dayzTraderMenu = [_activatingPlayer,_trader_id,_category,_action]; -publicVariableServer "dayzTraderMenu"; - -waitUntil {!isNil "dayzTraderMenuResult"}; - -/* - `id`, - `item` varchar(255) NOT NULL COMMENT '[Class Name,1 = CfgMagazines | 2 = Vehicle | 3 = Weapon]', - `qty` int(8) NOT NULL COMMENT 'amount in stock available to buy', - `buy` varchar(255) NOT NULL COMMENT '[[Qty,Class,Type],]', - `sell` varchar(255) NOT NULL COMMENT '[[Qty,Class,Type],]', - `order` int(2) NOT NULL DEFAULT '0' COMMENT '# sort order for addAction menu', - `tid` int(8) NOT NULL COMMENT 'Trader Menu ID', - `afile` varchar(64) NOT NULL DEFAULT 'trade_items', -*/ +if(isNil "dayzTraderMenuResult") then { + diag_log format["DEBUG TRADER OBJ: %1", _trader_id]; + //["dayzTraderMenu",[_activatingPlayer,_trader_id,_category,_action]] call callRpcProcedure; + dayzTraderMenu = [_activatingPlayer,_trader_id,_category,_action]; + publicVariableServer "dayzTraderMenu"; + waitUntil {!isNil "dayzTraderMenuResult"}; +}; diag_log format["DEBUG Buy: %1", dayzTraderMenuResult]; { @@ -103,24 +94,16 @@ diag_log format["DEBUG Buy: %1", dayzTraderMenuResult]; // Allways 1 for now _out = 1; - // trade_items.sqf | [part_out, part_in, qty_out, qty_in,_textPart,_textCurrency]; - if(_qty <= 0) then { - _Display = format["Buy %1 (Out of Stock: %2)", _textPart, _qty]; - _part = player addAction [_Display, "\z\addons\dayz_code\actions\trade_cancel.sqf",[], 0, true, false, "",""]; + + if (_qty > 0) then { + _Display = format["Buy %1 (%2) for %3 %4", _textPart, _name, _bqty, _textCurrency]; } else { - // if over 50 in stock lower price to that of sell price - if(_qty >= 50) then { - _Display = format["Buy %1 (%2) for %3 %4 (Available: %5)", _textPart, _name, _sqty, _textCurrencySell, _qty]; - _part = player addAction [_Display, _File,[_name,_sname,_out,_sqty,"buy",_textCurrencySell,_textPart,_header], _order, true, true, "",""]; - } else { - _Display = format["Buy %1 (%2) for %3 %4 (Available: %5)", _textPart, _name, _bqty, _textCurrency, _qty]; - _part = player addAction [_Display, _File,[_name,_bname,_out,_bqty,"buy",_textCurrency,_textPart,_header], _order, true, true, "",""]; - }; - - + _Display = format["Buy %1 (%2) for %3 %4", _textPart, _name, _bqty, _textCurrency]; }; + _part = player addAction [_Display, _File,[_name,_bname,_out,_bqty,"buy",_textCurrency,_textPart,_header], _order, true, true, "",""]; + diag_log format["DEBUG TRADER: %1", _part]; s_player_parts set [count s_player_parts,_part]; @@ -129,6 +112,9 @@ diag_log format["DEBUG Buy: %1", dayzTraderMenuResult]; _cancel = player addAction ["Cancel", "\z\addons\dayz_code\actions\trade_cancel.sqf",["medical"], 0, true, false, "",""]; s_player_parts set [count s_player_parts,_cancel]; +// Cache data in client side global variable +call compile format["tcacheBuy_%1 = %2;",_tid,dayzTraderMenuResult]; + // Clear Data maybe consider cacheing results dayzTraderMenuResult = nil; s_player_parts_crtl = 1; \ No newline at end of file diff --git a/dayz_code/actions/sell_db.sqf b/dayz_code/actions/sell_db.sqf index 0e6e9dcaa..5da766d59 100644 --- a/dayz_code/actions/sell_db.sqf +++ b/dayz_code/actions/sell_db.sqf @@ -8,23 +8,15 @@ _activatingPlayer = _this select 1; _trader_id = (_this select 3) select 0; _category = (_this select 3) select 1; -diag_log format["DEBUG TRADER OBJ: %1", _trader_id]; +dayzTraderMenuResult = call compile format["tcacheSell_%1;",_trader_id]; -//["dayzTraderMenu",[_activatingPlayer,_trader_id,_category,_action]] call callRpcProcedure; -dayzTraderMenu = [_activatingPlayer,_trader_id,_category,_action]; -publicVariableServer "dayzTraderMenu"; - -waitUntil {!isNil "dayzTraderMenuResult"}; - -/* - `item` varchar(255) NOT NULL COMMENT '[Class Name,1 = CfgMagazines | 2 = Vehicle | 3 = Weapon]', - `qty` int(8) NOT NULL COMMENT 'amount in stock available to buy', - `buy` varchar(255) NOT NULL COMMENT '[[Qty,Class,Type],]', - `sell` varchar(255) NOT NULL COMMENT '[[Qty,Class,Type],]', - `order` int(2) NOT NULL DEFAULT '0' COMMENT '# sort order for addAction menu', - `tid` int(8) NOT NULL COMMENT 'Trader Menu ID', - `afile` varchar(64) NOT NULL DEFAULT 'trade_items', -*/ +if(isNil "dayzTraderMenuResult") then { + diag_log format["DEBUG TRADER OBJ: %1", _trader_id]; + //["dayzTraderMenu",[_activatingPlayer,_trader_id,_category,_action]] call callRpcProcedure; + dayzTraderMenu = [_activatingPlayer,_trader_id,_category,_action]; + publicVariableServer "dayzTraderMenu"; + waitUntil {!isNil "dayzTraderMenuResult"}; +}; diag_log format["DEBUG Buy: %1", dayzTraderMenuResult]; { @@ -124,37 +116,17 @@ diag_log format["DEBUG Buy: %1", dayzTraderMenuResult]; }; - // if under 5 in stock raise price to that of buy price - if(_qty <= 5) then { - - if (_count > 0) then { - _Display = format["Sell %1 for %2 %3 each", _textPart, _bqty, _textCurrencyBuy]; - } else { - _Display = format["Sell %1 for %2 %3 each", _textPart, _bqty, _textCurrencyBuy]; - }; - - // trade_items.sqf | [part_out, part_in, qty_out, qty_in,_textPart,_textCurrency]; - - _part = player addAction [_Display, _File,[_sname,_name,_bqty,_in,"sell",_textPart,_textCurrencyBuy,_header], _order, true, true, "",""]; - - } else { - - if (_count > 0) then { - _Display = format["Sell %1 for %2 %3 each", _textPart, _sqty, _textCurrency]; - } else { - _Display = format["Sell %1 for %2 %3 each", _textPart, _sqty, _textCurrency]; - }; - - // trade_items.sqf | [part_out, part_in, qty_out, qty_in,_textPart,_textCurrency]; - - _part = player addAction [_Display, _File,[_sname,_name,_sqty,_in,"sell",_textPart,_textCurrency,_header], _order, true, true, "",""]; - - }; - + if (_count > 0) then { + _Display = format["Sell %1 for %2 %3 each", _textPart, _sqty, _textCurrency]; + } else { + _Display = format["Sell %1 for %2 %3 each", _textPart, _sqty, _textCurrency]; + }; + // trade_items.sqf | [part_out, part_in, qty_out, qty_in,_textPart,_textCurrency]; + _part = player addAction [_Display, _File,[_sname,_name,_sqty,_in,"sell",_textPart,_textCurrency,_header], _order, true, true, "",""]; - diag_log format["DEBUG TRADER: %1", _part]; + // diag_log format["DEBUG TRADER: %1", _part]; s_player_parts set [count s_player_parts,_part]; } forEach dayzTraderMenuResult; @@ -162,6 +134,12 @@ diag_log format["DEBUG Buy: %1", dayzTraderMenuResult]; _cancel = player addAction ["Cancel", "\z\addons\dayz_code\actions\trade_cancel.sqf",["medical"], 0, true, false, "",""]; s_player_parts set [count s_player_parts,_cancel]; -// Clear Data maybe consider cacheing results +// Cache data in client side global variable +call compile format["tcacheSell_%1 = %2;",_tid,dayzTraderMenuResult]; + + +// Clear Data dayzTraderMenuResult = nil; + + s_player_parts_crtl = 1; diff --git a/dayz_code/actions/trade_any_boat.sqf b/dayz_code/actions/trade_any_boat.sqf index 65e128439..3930ba34c 100644 --- a/dayz_code/actions/trade_any_boat.sqf +++ b/dayz_code/actions/trade_any_boat.sqf @@ -53,28 +53,13 @@ if (_qty >= _qty_in) then { _location = [(position player),0,20,1,2,2000,0] call BIS_fnc_findSafePos; - //place tent (local) - _veh = createVehicle [_part_out, _location, [], 0, "CAN_COLLIDE"]; - - _veh setVariable ["JustSpawned",true,true]; - - _veh setdir _dir; - _veh setpos _location; - - //_veh setPosATL _position; - - _location = getPosATL _veh; - - _veh setVariable ["characterID",dayz_playerUID,true]; - - clearWeaponCargoGlobal _veh; - clearMagazineCargoGlobal _veh; + //place vehicle spawn marker (local) + _veh = createVehicle ["Sign_arrow_down_large_EP1", _location, [], 0, "CAN_COLLIDE"]; //["dayzPublishVeh",[_veh,[_dir,_location],_part_out,false,dayz_playerUID]] call callRpcProcedure; - dayzPublishVeh = [_veh,[_dir,_location],_part_out,false,dayz_playerUID]; - publicVariableServer "dayzPublishVeh"; + dayzPublishVeh2 = [_veh,[_dir,_location],_part_out,false,dayz_playerUID]; + publicVariableServer "dayzPublishVeh2"; - _veh call fnc_vehicleEventHandler; player reveal _veh; @@ -99,7 +84,6 @@ if (_qty >= _qty_in) then { dayzDeleteObj = [_objectID,_objectUID]; publicVariableServer "dayzDeleteObj"; - deleteVehicle _obj; cutText [format[("Sold %1 %2 for %3 %4"),_qty_in,_textPartIn,_qty_out,_textPartOut], "PLAIN DOWN"]; @@ -118,7 +102,7 @@ if (_qty >= _qty_in) then { if(_buy_o_sell == "buy") then { cutText [format[("Need %1 More %2"),_needed,_textPartIn] , "PLAIN DOWN"]; } else { - cutText [format[("No %1 found within 20 meters."),_textPartOut] , "PLAIN DOWN"]; + cutText [format[("No %1 found within 20 meters."),_textPartIn] , "PLAIN DOWN"]; }; }; diff --git a/dayz_code/actions/trade_any_vehicle.sqf b/dayz_code/actions/trade_any_vehicle.sqf index e04b2f244..1b863890a 100644 --- a/dayz_code/actions/trade_any_vehicle.sqf +++ b/dayz_code/actions/trade_any_vehicle.sqf @@ -59,25 +59,12 @@ if (_qty >= _qty_in) then { _location = [(position player),0,20,1,0,2000,0] call BIS_fnc_findSafePos; }; - //place tent (local) - _veh = createVehicle [_part_out, _location, [], 0, "CAN_COLLIDE"]; - - _veh setVariable ["JustSpawned",true,true]; - - _veh setdir _dir; - _veh setpos _location; - - _location = getPosATL _veh; - - //_veh setVariable ["ObjectUID",dayz_playerUID,true]; - - - clearWeaponCargoGlobal _veh; - clearMagazineCargoGlobal _veh; + //place vehicle spawn marker (local) + _veh = createVehicle ["Sign_arrow_down_large_EP1", _location, [], 0, "CAN_COLLIDE"]; //["dayzPublishVeh",[_veh,[_dir,_location],_part_out,false,dayz_playerUID]] call callRpcProcedure; - dayzPublishVeh = [_veh,[_dir,_location],_part_out,false,dayz_playerUID]; - publicVariableServer "dayzPublishVeh"; + dayzPublishVeh2 = [_veh,[_dir,_location],_part_out,false,dayz_playerUID]; + publicVariableServer "dayzPublishVeh2"; // event handlers to correctly track damage client side _veh call fnc_vehicleEventHandler; @@ -123,7 +110,7 @@ if (_qty >= _qty_in) then { if(_buy_o_sell == "buy") then { cutText [format[("Need %1 More %2"),_needed,_textPartIn] , "PLAIN DOWN"]; } else { - cutText [format[("No %1 found within 20 meters."),_textPartOut] , "PLAIN DOWN"]; + cutText [format[("No %1 found within 20 meters."),_textPartIn] , "PLAIN DOWN"]; }; }; diff --git a/dayz_code/config.cpp b/dayz_code/config.cpp index 66c3fd508..572fb24b0 100644 --- a/dayz_code/config.cpp +++ b/dayz_code/config.cpp @@ -40,7 +40,7 @@ class CfgMods hidePicture = 0; hideName = 0; action = "http://www.dayzepoch.com"; - version = "0.993"; + version = "0.994"; hiveVersion = 0.96; //0.93 }; }; diff --git a/dayz_code/init/publicEH.sqf b/dayz_code/init/publicEH.sqf index da42e7a36..eb45ed77e 100644 --- a/dayz_code/init/publicEH.sqf +++ b/dayz_code/init/publicEH.sqf @@ -45,6 +45,7 @@ if (isServer) then { // Dayz epoch custom "dayzPublishVeh" addPublicVariableEventHandler {(_this select 1) spawn server_publishVeh}; + "dayzPublishVeh2" addPublicVariableEventHandler {(_this select 1) spawn server_publishVeh2}; "dayzTradeObject" addPublicVariableEventHandler {(_this select 1) spawn server_tradeObj}; "dayzTraderMenu" addPublicVariableEventHandler {(_this select 1) spawn server_traders}; "dayzPlayerDeaths" addPublicVariableEventHandler {(_this select 1) spawn server_deaths}; diff --git a/dayz_code/rscTitles.hpp b/dayz_code/rscTitles.hpp index 4adc171b2..44d7e94c8 100644 --- a/dayz_code/rscTitles.hpp +++ b/dayz_code/rscTitles.hpp @@ -137,7 +137,7 @@ class RscDisplayMain : RscStandardDisplay class DAYZ_Version : CA_Version { idc = -1; - text = "DayZ Epoch 0.993 (1.7.6.1)"; + text = "DayZ Epoch 0.994 (1.7.6.1)"; y = "(SafeZoneH + SafeZoneY) - (1 - 0.95)"; }; delete CA_TitleMainMenu; diff --git a/dayz_server/compile/server_publishVehicle.sqf b/dayz_server/compile/server_publishVehicle.sqf index 762f4cb04..64fdaf6b6 100644 --- a/dayz_server/compile/server_publishVehicle.sqf +++ b/dayz_server/compile/server_publishVehicle.sqf @@ -16,7 +16,7 @@ _location = _worldspace select 1; //Generate UID test using time // _uid = str( round (dateToNumber date)) + str(round time); -_uid = _worldspace call dayz_objectUID3; +_uid = _worldspace call dayz_objectUID2; //_uid = format["%1%2",(round time),_uid]; if (_spawnDMG) then { @@ -127,7 +127,6 @@ dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object]; if (_selection in dayZ_explosiveParts and _dam > 0.8) then {_dam = 0.8}; [_object,_selection,_dam] call object_setFixServer; } forEach _array; - _object setFuel _fuel; @@ -135,7 +134,5 @@ dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object]; _object call fnc_vehicleEventHandler; - _object setVariable ["JustSpawned",nil,true]; - diag_log ("PUBLISH: Created " + (_class) + " with ID " + str(_uid)); }; \ No newline at end of file diff --git a/dayz_server/compile/server_publishVehicle2.sqf b/dayz_server/compile/server_publishVehicle2.sqf new file mode 100644 index 000000000..348e5e790 --- /dev/null +++ b/dayz_server/compile/server_publishVehicle2.sqf @@ -0,0 +1,102 @@ +private["_object","_worldspace","_location","_dir","_character","_tent","_class","_id","_uid","_dam","_hitpoints","_selection","_array","_damage","_randFuel","_fuel","_key","_result","_outcome","_totaldam","_parts","_retry","_done","_spawnDMG"]; + +_object = _this select 0; +_worldspace = _this select 1; +_class = _this select 2; +_spawnDMG = _this select 3; +_characterID = _this select 4; + +diag_log ("PUBLISH: Attempt " + str(_object)); +_dir = _worldspace select 0; +_location = _worldspace select 1; + +//Generate UID test using time +_uid = _worldspace call dayz_objectUID3; + +// TODO: check if uid already exists and if so increment by 1 and check again as soon as we find nothing continue. + +//Send request +_key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, 0 , _characterID, _worldspace, [], [], 1,_uid]; +diag_log ("HIVE: WRITE: "+ str(_key)); +_key call server_hiveWrite; + +// Switched to spawn so we can wait a bit for the ID +[_object,_uid,_characterID,_class,_dir,_location] spawn { + private["_object","_uid","_characterID","_done","_retry","_key","_result","_outcome","_oid","_selection","_dam","_class"]; + + _object = _this select 0; + _uid = _this select 1; + _characterID = _this select 2; + _class = _this select 3; + _dir = _this select 4; + _location = _this select 5; + + _done = false; + _retry = 0; + // TODO: Needs major overhaul for 1.1 + while {_retry < 10} do { + + sleep 1; + // GET DB ID + _key = format["CHILD:388:%1:",_uid]; + diag_log ("HIVE: WRITE: "+ str(_key)); + _result = _key call server_hiveReadWrite; + _outcome = _result select 0; + if (_outcome == "PASS") then { + _oid = _result select 1; + //_object setVariable ["ObjectID", _oid, true]; + diag_log("CUSTOM: Selected " + str(_oid)); + _done = true; + _retry = 100; + + } else { + diag_log("CUSTOM: trying again to get id for: " + str(_uid)); + _done = false; + _retry = _retry + 1; + }; + }; + + // Remove marker + deleteVehicle _object; + + if(!_done) exitWith { diag_log("CUSTOM: failed to get id for : " + str(_uid)); }; + + _object_para = "ParachuteMediumWest" createVehicle [0,0,0]; + + _object_para setpos [_location select 0, _location select 1,(_location select 2) + 65]; + + _object = createVehicle [_class, [0,0,0], [], 0, "CAN_COLLIDE"]; + + _object setVariable ["ObjectID", _oid, true]; + + _object setVariable ["lastUpdate",time]; + + _object setVariable ["CharacterID", _characterID, true]; + + _object attachTo [_object_para, [0,0,-1.6]]; + + sleep 1.0; + + WaitUntil{(getpos _object select 2) < 0.1}; + + detach _object; + + deleteVehicle _object_para; + + // _object setDamage _damage; + // _object setFuel _fuel; + + clearWeaponCargoGlobal _object; + clearMagazineCargoGlobal _object; + + _veh setdir _dir; + _veh setpos _location; + + //_object setvelocity [0,0,1]; + + dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object]; + + _object call fnc_vehicleEventHandler; + + diag_log ("PUBLISH: Created " + (_class) + " with ID " + str(_uid)); +}; \ No newline at end of file diff --git a/dayz_server/compile/server_updateObject.sqf b/dayz_server/compile/server_updateObject.sqf index a8dab5c7e..7ee630bf6 100644 --- a/dayz_server/compile/server_updateObject.sqf +++ b/dayz_server/compile/server_updateObject.sqf @@ -7,12 +7,11 @@ _object = _this select 0; _type = _this select 1; _parachuteWest = typeOf _object == "ParachuteWest"; _isNotOk = false; +_firstTime = false; +_removeCounter = 0; _objectID = _object getVariable ["ObjectID","0"]; _uid = _object getVariable ["ObjectUID","0"]; -_justSpawned = _object getVariable ["JustSpawned",false]; - -if (_justSpawned) exitWith { diag_log(format["Vehicle Just Spawned do nothing: %1", typeOf _object]); }; if ((typeName _objectID != "string") || (typeName _uid != "string")) then { @@ -31,10 +30,16 @@ if (!_parachuteWest) then { _object_position select 1, _object_position select 2]); _isNotOk = true; + + // Loop to wait it out + _counter = _object getVariable ["markedForRemoval","0"]; + _removeCounter = _object setVariable ["markedForRemoval",(_counter + 1)]; }; }; -if (_isNotOk) exitWith { deleteVehicle _object; }; +if (_isNotOk and _removeCounter < 10) exitWith { diag_log(format["About to remove vehicle: %1 - %2 / 10", typeOf _object, _removeCounter]); }; +if (_isNotOk and _removeCounter >= 10) exitWith { deleteVehicle _object; }; + _lastUpdate = _object getVariable ["lastUpdate",time]; _needUpdate = _object in needUpdate_objects; diff --git a/dayz_server/init/server_functions.sqf b/dayz_server/init/server_functions.sqf index 96b73c285..0c8a8845f 100644 --- a/dayz_server/init/server_functions.sqf +++ b/dayz_server/init/server_functions.sqf @@ -15,6 +15,7 @@ server_playerDied = compile preprocessFileLineNumbers "\z\addons\dayz_server\c server_publishObj = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_publishObject.sqf"; //Creates the object in DB server_deleteObj = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_deleteObj.sqf"; //Removes the object from the DB server_publishVeh = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_publishVehicle.sqf"; // Custom to add vehicles +server_publishVeh2 = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_publishVehicle2.sqf"; // Custom to add vehicles server_tradeObj = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_tradeObject.sqf"; server_traders = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_traders.sqf"; server_playerSync = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerSync.sqf";