Write objects to object_data in database

Meowzors

New Member
So, I made some updates to what is craftable on my server. They craft fine but I cannot figure out how to get them to write to the database so they persist through a restart. Any help would be appreciated.

I tried:

_object = "Land_Ind_TankSmall2" createVehicle (position player);
_object setVariable ["ObjectID", "1", true];
_object setVariable ["ObjectUID", "1", true];
_object attachto [player,[0.0,3.0,1.5]];
detach _object;
_object setVariable ["characterID",dayz_characterID,true];
dayzPublishObj = [dayz_characterID,_object,[_dir,_location],_classname];

However, this does not create a new item in the object_data table
 
If you are using Epoch, the line you are looking for is this:
Code:
PVDZE_obj_Publish = [_combination,_tmpbuilt,[_dir,_location],_classname];
publicVariableServer "PVDZE_obj_Publish";

_combination is the combo of the item. If it is not a combination item this is 0.
_tmpbuilt references the createVehicle of the item.
_dir is the degree out of 360 it is facing.
_location is a worldspace.
_classname is the classname of the building.
 
If you are using Epoch, the line you are looking for is this:
Code:
PVDZE_obj_Publish = [_combination,_tmpbuilt,[_dir,_location],_classname];
publicVariableServer "PVDZE_obj_Publish";

_combination is the combo of the item. If it is not a combination item this is 0.
_tmpbuilt references the createVehicle of the item.
_dir is the degree out of 360 it is facing.
_location is a worldspace.
_classname is the classname of the building.

so... this should work then?

Code:
// Send to database
_dir = getDir _object;
_pos = getPos _object;
PVDZE_obj_Publish = [0,_object,[_dir,_location],"Land_Ind_TankSmall2"];
publicVariableServer "PVDZE_obj_Publish";
 
That should work.

You should take a look through player_build.sqf though. If you implemented the object to use the Epoch building system that already exists, I think you would like the overall result better.
 
So, i have this and now it creates but dissapears as soon as it is created. Nothing showing in the RPT when this occurs

Code:
  _object = "Land_Ind_TankSmall2" createVehicle (position player);
   _object setVariable ["ObjectID", "1", true];
   _object setVariable ["ObjectUID", "1", true];   
   _object attachto [player,[0.0,3.0,1.5]];
   _object setVariable ["characterID",dayz_characterID,true];
   sleep 3;
   detach _object;
   player reveal _object;
   _vehicleType = typeOf _object;
// Send to database
_dir = getDir _object;
_pos = getPos _object;
PVDZE_obj_Publish = [0,_object,[_dir,_location],"Land_Ind_TankSmall2"];
publicVariableServer "PVDZE_obj_Publish";
 
Looking through player_build.sqf im not sure how I would use that to add new buildables... i found a way to call scripts from right click menus of items and got excited that I could create new buildables that way just getting them to write to the database and not dissapear is a nightmare so far
 
are they not one in the same? getPos returns a worldspace coordinate that is needed for location right?

EDIT: just relized i left it as _pos= and then referenced it as _location.... lmao wow.
EDIT: It still does not create. dissapears as soon as created. is there a variable you have to give it so it will actually create? like _object setvariable(something, true);?

You are awesome man. Thanks for the help and bearing with my noobness lol
 
Last edited:
It might be being cleaned up right after it's built as the cleanup checks for "safe" buildables.

I think you may need to have a custom copy of variables.sqf and add your classname to the dayz_allowedObjects array in it.
 
Yeah I did that a couple hours ago and it is staying but I am still not seeing it in the database... I'm sure its something stupid that I am just not seeing but here is my current fuel tank build code...
Code:
_scrapQTY={_x == "ItemCorrugated"} count magazines player;
_panelQTY={_x == "ItemPole"} count magazines player;
_barrelQTY={_x == "ItemFuelBarrel"} count magazines player;
_scrapRQD=1;
_panelRQD=2;
_barrellRQD=5;
if (_scrapQTY <_scrapRQD) exitWith{cutText [format["You need 4 Corrugated Fencing to build a Fuel Tank."], "PLAIN DOWN"];};
if (_panelQTY <_panelRQD) exitWith{cutText [format["You need 2 Metal Poles to build a Fuel Tank."], "PLAIN DOWN"];};
if (_barrelQTY <_barrellRQD) exitWith{cutText [format["You need 5 Fuel Barrels to build a Fuel Tank."], "PLAIN DOWN"];};
if (dayz_combat == 1) then {
  cutText [format["You are in Combat and cannot build a Fuel Tank."], "PLAIN DOWN"];
} else {
   player playActionNow "Medic";
   r_interrupt = false;
   _dis=10;
   _sfx = "repair";
   [player,_sfx,0,false,_dis] call dayz_zombieSpeak;
   [player,_dis,true,(getPosATL player)] spawn player_alertZombies;
 
   sleep 6;
   for "_x" from 1 to _scrapRQD do {
 
  if (_x < _scrapRQD) then {
  player removeMagazine "ItemCorrugated";
  };
  };
   for "_x" from 1 to _barrellRQD do {
  if (_x < _barrellRQD) then {
  player removeMagazine "ItemFuelBarrel";
  };
  };
   for "_x" from 1 to _panelRQD do {
  if (_x < _panelRQD) then {
  player removeMagazine "ItemPole";
  };
  };
   
   _object = "Land_Ind_TankSmall2" createVehicle (position player);
   _object setVariable ["ObjectID", "1", true];
   _object setVariable ["ObjectUID", "1", true]; 
   _object attachto [player,[0.0,3.0,1.5]];
   sleep 3;
   detach _object;
   player reveal _object;
   _object setVariable ["characterID",0,true];
// Send to database
_dir = round(direction _object);
_location = getPosATL _object;
PVDZE_obj_Publish = [0,_object,[_dir,_location ],"Land_Ind_TankSmall2"];
publicVariableServer "PVDZE_obj_Publish";

   cutText [format["You've crafted a Fuel Tank."], "PLAIN DOWN"];
 
   r_interrupt = false;
   player switchMove "";
   player playActionNow "stop";
 
   sleep 10;
};
EDIT: Nevermind this code works. will create a fuel tank and place in database. Many thanks for all the help! Will be adding further buildables in the future to my server.
 
Last edited:
Back
Top