[Release] BaseBuilding 1.2 Improvements 0.1 (better and editable Keycode, permanent Owner)

server_publishObject.sqf
Code:
private ["_class","_uid","_charID","_object","_worldspace","_key","_code","_fuel"];
//[dayz_characterID,_tent,[_dir,_location],"TentStorage"]
_charID =        _this select 0;
_object =        _this select 1;
_worldspace =    _this select 2;
_class =        _this select 3;
_fuel =            _this select 4;
_code =            _this select 5; //added to pick up the code which we passed from player_build.sqf
 
//if (!(_object isKindOf "Building")) exitWith {
//    deleteVehicle _object;
//};
_allowed = [_object, "Server"] call check_publishobject;
if (!_allowed) exitWith { };
 
 
//diag_log ("PUBLISH: Attempt " + str(_object));
 
//get UID
_uid = _worldspace call dayz_objectUID2;
 
//Send request
_key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, 0 , _charID, _worldspace, [], [], _fuel,_uid];
//_key = format["CHILD:308:%1:%2:%3:%4:%5:", dayz_instance, _class, _charID, _worldspace, _fuel, _uid];
//diag_log ("HIVE: WRITE: "+ str(_key));
_key call server_hiveWrite;
//_code = _fuel * 1000; //would be only necessary if we wouldn't pass the code from player_build.sqf
_object setVariable ["Code", _code,true]; //set the Code to the Object
_object setVariable ["ObjectUID", _uid,true]; //set ObjectUID to the Object
_object setVariable ["Classname", _class,true]; //set Classname to the Object
 
_object setVariable ["ObjectUID", _uid,true];
 
if (_object isKindOf "TentStorage") then {
    _object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
};
 
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
 
diag_log ("PUBLISH: Created " + (_class) + " with ID " + _uid);

And the other one:
player_build.sqf

I went back and looked for anything I may have done and there was one thing.
In server_publishObject.sqf at the top we (reality users) should have had this:

Code:
private ["_class","_uid","_charID","_object","_worldspace","_key"];
//[dayz_characterID,_tent,[_dir,_location],"TentStorage"]
_charID =        _this select 0;
_object =        _this select 1;
_worldspace =    _this select 2;
_class =        _this select 3;

OP says to add _code = _this select 5; after _fuel = _this select 4;
Do not just place _code = _this select 5; after _class = _this select 3; simply because that's all you had there.

Make sure to add in_fuel = _this select 4;
The section should now look like this:

Code:
private ["_class","_uid","_charID","_object","_worldspace","_key","_code","_fuel"];
//[dayz_characterID,_tent,[_dir,_location],"TentStorage"]
_charID =        _this select 0;
_object =        _this select 1;
_worldspace =    _this select 2;
_class =        _this select 3;
_fuel =            _this select 4;
_code =            _this select 5; //added to pick up the code which we passed from player_build.sqf
 
Player_build.sqf
Code:
private ["_class","_uid","_charID","_object","_worldspace","_key","_code","_fuel"];
//[dayz_characterID,_tent,[_dir,_location],"TentStorage"]
_charID =        _this select 0;
_object =        _this select 1;
_worldspace =    _this select 2;
_class =        _this select 3;
_fuel =            _this select 4;
_code =            _this select 5; //added to pick up the code which we passed from player_build.sqf
 
//if (!(_object isKindOf "Building")) exitWith {
//    deleteVehicle _object;
//};
_allowed = [_object, "Server"] call check_publishobject;
if (!_allowed) exitWith { };
 
 
//diag_log ("PUBLISH: Attempt " + str(_object));
 
//get UID
_uid = _worldspace call dayz_objectUID2;
 
//Send request
_key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, 0 , _charID, _worldspace, [], [], _fuel,_uid];
//_key = format["CHILD:308:%1:%2:%3:%4:%5:", dayz_instance, _class, _charID, _worldspace, _fuel, _uid];
//diag_log ("HIVE: WRITE: "+ str(_key));
_key call server_hiveWrite;
//_code = _fuel * 1000; //would be only necessary if we wouldn't pass the code from player_build.sqf
_object setVariable ["Code", _code,true]; //set the Code to the Object
_object setVariable ["ObjectUID", _uid,true]; //set ObjectUID to the Object
_object setVariable ["Classname", _class,true]; //set Classname to the Object
 
_object setVariable ["ObjectUID", _uid,true];
 
if (_object isKindOf "TentStorage") then {
    _object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
};
 
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
 
diag_log ("PUBLISH: Created " + (_class) + " with ID " + _uid);

server_publishObject.sqf

I went back and looked for anything I may have done and there was one thing.
In player_build.sqf at the top we (reality users) should have had this:

Code:
private ["_class","_uid","_charID","_object","_worldspace","_key"];
//[dayz_characterID,_tent,[_dir,_location],"TentStorage"]
_charID =        _this select 0;
_object =        _this select 1;
_worldspace =    _this select 2;
_class =        _this select 3;

OP says to add _code = _this select 5; after _fuel = _this select 4;
Do not just place _code = _this select 5; after _class = _this select 3; simply because that's all you had there.

Make sure to add in_fuel = _this select 4;
The section should now look like this:

Code:
private ["_class","_uid","_charID","_object","_worldspace","_key","_code","_fuel"];
//[dayz_characterID,_tent,[_dir,_location],"TentStorage"]
_charID =        _this select 0;
_object =        _this select 1;
_worldspace =    _this select 2;
_class =        _this select 3;
_fuel =            _this select 4;
_code =            _this select 5; //added to pick up the code which we passed from player_build.sqf

That part is already added in with the tut if im not mistaking or misunderstanding you
 
That part is already added in with the tut if im not mistaking or misunderstanding you

Not exactly, this is what he states:

Merge the first line with this line
Code:
private ["_class","_uid","_charID","_object","_worldspace","_key","_code","_fuel"];
Below this
Code:
_fuel =_this select 4;
Add this
Code:
_code =_this select 5; //added to pick up the code which we passed from player_build.sqf

The assumption was that it was already there, so idk...some people can get confused. While I understood what to do, I know some people will fumble on this. Anyway, all I was saying was that this was the only thing I can see I differentiated on, other than removing the previously noted snippet. With those two edits people should be getting their objects saved in Bliss/Reality.
 
Anyone tried this on Tavi 2.0 yet? My server_monitor.sqf looks much different the one in the tut. Im sure its due to all the other scripts and the fact that its Tavi, lol. BB1.2 does work on my server but we have a few buggy issues. Tents dont remove, some players can remove things after death, others cant. Heres the code I have:
Code:
if (_damage < 1) then {
        diag_log("Spawned: " + str(_idKey) + " " + _type);
       
        _object = createVehicle [_type, _pos, [], 0, "CAN_COLLIDE"];
        _object setVariable ["lastUpdate",time];
 
        // Don't set objects for deployables to ensure proper inventory updates
        if (_ownerID == "0") then {
            _object setVariable ["ObjectID", str(_idKey), true];
        } else {
            _object setVariable ["ObjectUID", _worldspace call dayz_objectUID2, true];
        };
 
        _object setVariable ["CharacterID", _ownerID, true];
       
        clearWeaponCargoGlobal  _object;
        clearMagazineCargoGlobal  _object;
       
        _object setVariable ["ObjectUID", _worldspace call dayz_objectUID2, true];
       
        if (_object isKindOf "TentStorage") then {
            _pos set [2,0];
            _object setpos _pos;
        };
        _object setdir _dir;
        _object setDamage _damage;
Any help would be great! thnx
 
Player_build.sqf
Code:
private ["_class","_uid","_charID","_object","_worldspace","_key","_code","_fuel"];
//[dayz_characterID,_tent,[_dir,_location],"TentStorage"]
_charID =        _this select 0;
_object =        _this select 1;
_worldspace =    _this select 2;
_class =        _this select 3;
_fuel =            _this select 4;
_code =            _this select 5; //added to pick up the code which we passed from player_build.sqf
 
//if (!(_object isKindOf "Building")) exitWith {
//    deleteVehicle _object;
//};
_allowed = [_object, "Server"] call check_publishobject;
if (!_allowed) exitWith { };
 
 
//diag_log ("PUBLISH: Attempt " + str(_object));
 
//get UID
_uid = _worldspace call dayz_objectUID2;
 
//Send request
_key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, 0 , _charID, _worldspace, [], [], _fuel,_uid];
//_key = format["CHILD:308:%1:%2:%3:%4:%5:", dayz_instance, _class, _charID, _worldspace, _fuel, _uid];
//diag_log ("HIVE: WRITE: "+ str(_key));
_key call server_hiveWrite;
//_code = _fuel * 1000; //would be only necessary if we wouldn't pass the code from player_build.sqf
_object setVariable ["Code", _code,true]; //set the Code to the Object
_object setVariable ["ObjectUID", _uid,true]; //set ObjectUID to the Object
_object setVariable ["Classname", _class,true]; //set Classname to the Object
 
_object setVariable ["ObjectUID", _uid,true];
 
if (_object isKindOf "TentStorage") then {
    _object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
};
 
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
 
diag_log ("PUBLISH: Created " + (_class) + " with ID " + _uid);

And the other one:
server_publishObject.sqf

Both your quoted code and your publishobj.sqf are the code from publishobj.sqf. But I dont think player_build is part of the issue so that's ok. Will check your fix shortly
 
Still getting

Code:
2013-05-27 11:04:12 HiveExt: [Information] Method: 308 Params: 1:Land_Misc_Cargo2E:0:26939206:[296.057,[985.788,1891.97,0.105]]:[]:[]:4.311:9858189201296:
2013-05-27 11:04:12 HiveExt: [Information] Result: ["PASS"]
2013-05-27 11:04:12 Database: [Error] Error 1452 (Cannot add or update a child row: a foreign key constraint fails (`dayz`.`instance_deployable`, CONSTRAINT `instance_deployable_ibfk_2` FOREIGN KEY (`owner_id`) REFERENCES `survivor` (`id`))) in MySQLStmtExecute SQL: 'insert into `instance_deployable` (`unique_id`, `deployable_id`, `owner_id`, `instance_id`, `worldspace`, `inventory`, `Damage`,`Hitpoints`, `Fuel`, `created`) select ?, d.id, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP from deployable d where d.class_name = ? VALUES(9858189201296, 26939206, 1, "[296.057,[985.788,1891.97,0.105]]", "[]", 0, "[]", 4.310999870300293, "Land_Misc_Cargo2E")'


Um, no. I have posted both my player_build.sqf and my server_publishObject.sqf (through the download link cause it's too large text-wise). Just look at those if you are getting confused by this, sorry I don't know how else to help :/

I'd like to try using your player_build.sqf after you update the link
 
Oh sorry didn't notice that, will update the post...

Had it backwards too, that's what I get for posting at 2am...fixed now.

Code:
2013-05-27 11:04:12 HiveExt: [Information] Method: 308 Params: 1:Land_Misc_Cargo2E:0:26939206:[296.057,[985.788,1891.97,0.105]]:[]:[]:4.311:9858189201296:
2013-05-27 11:04:12 HiveExt: [Information] Result: ["PASS"]
2013-05-27 11:04:12 Database: [Error] Error 1452 (Cannot add or update a child row: a foreign key constraint fails (`dayz`.`instance_deployable`, CONSTRAINT `instance_deployable_ibfk_2` FOREIGN KEY (`owner_id`) REFERENCES `survivor` (`id`))) in MySQLStmtExecute SQL: 'insert into `instance_deployable` (`unique_id`, `deployable_id`, `owner_id`, `instance_id`, `worldspace`, `inventory`, `Damage`,`Hitpoints`, `Fuel`, `created`) select ?, d.id, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP from deployable d where d.class_name = ? VALUES(9858189201296, 26939206, 1, "[296.057,[985.788,1891.97,0.105]]", "[]", 0, "[]", 4.310999870300293, "Land_Misc_Cargo2E")'

Your object is passing the publish checks and trying to be written but the insert statement is failing when mySQL tries to compile it. What version of mySQL are you using? Foreign key creation can error out when the SQL version is incompatible. Also are you using Bliss (like DayZ.ST) or Reality? I can confirm it works for Reality on my test center but if you are using Bliss you will probably run into that type of error as well.
 
BB Improvements still work on Epoch 1.0.1 just merged everything and it works ;)

Yeah Phoenix you was right I did messed up with that line. Should be fixed now.

/dayz_server/server_publishObject.sqf

Below this
Code:
_class =_this select 3;

Add this
Code:
_fuel = _this select 4;
_code = _this select 5; //added to pick up the code which we passed from player_build.sqf
 
Oh sorry didn't notice that, will update the post...

Had it backwards too, that's what I get for posting at 2am...fixed now.

Code:
2013-05-27 11:04:12 HiveExt: [Information] Method: 308 Params: 1:Land_Misc_Cargo2E:0:26939206:[296.057,[985.788,1891.97,0.105]]:[]:[]:4.311:9858189201296:
2013-05-27 11:04:12 HiveExt: [Information] Result: ["PASS"]
2013-05-27 11:04:12 Database: [Error] Error 1452 (Cannot add or update a child row: a foreign key constraint fails (`dayz`.`instance_deployable`, CONSTRAINT `instance_deployable_ibfk_2` FOREIGN KEY (`owner_id`) REFERENCES `survivor` (`id`))) in MySQLStmtExecute SQL: 'insert into `instance_deployable` (`unique_id`, `deployable_id`, `owner_id`, `instance_id`, `worldspace`, `inventory`, `Damage`,`Hitpoints`, `Fuel`, `created`) select ?, d.id, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP from deployable d where d.class_name = ? VALUES(9858189201296, 26939206, 1, "[296.057,[985.788,1891.97,0.105]]", "[]", 0, "[]", 4.310999870300293, "Land_Misc_Cargo2E")'

Your object is passing the publish checks and trying to be written but the insert statement is failing when mySQL tries to compile it. What version of mySQL are you using? Foreign key creation can error out when the SQL version is incompatible. Also are you using Bliss (like DayZ.ST) or Reality? I can confirm it works for Reality on my test center but if you are using Bliss you will probably run into that type of error as well.



MySQL 5.6 and Reality DB

What would cause the DB to reject now, when it worked prior to the upgrade?
 
Not entirely sure, I'm still new to MySQL. I can tell you I'm running MySQL 5.5 though, so you got 1 up on me. Are you sure you successfully merged the Reality package all the way up to the 0.39 schema? I went back and tried my fix on a Bliss Hive at schema 0.30 and got the same error:

Code:
2013-05-27 21:54:29 HiveExt: [Information] Method: 308 Params: 3541:Land_Campfire_burning:0:12701062:[182.971,[6888.25,11457.8,0.58]]:[]:[]:6.972:688821145786183:
2013-05-27 21:54:29 HiveExt: [Information] Result: ["PASS"]
2013-05-27 21:54:29 Database: [Error] Error 1452 (Cannot add or update a child row: a foreign key constraint fails (`bliss_3541`.`instance_deployable`, CONSTRAINT `instance_deployable_ibfk_2` FOREIGN KEY (`owner_id`) REFERENCES `survivor` (`id`))) in MySQLStmtExecute SQL: 'insert into `instance_deployable` (`unique_id`, `deployable_id`, `owner_id`, `instance_id`, `worldspace`, `inventory`, `Damage`,`Hitpoints`, `Fuel`, `created`) select ?, d.id, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP from deployable d where d.class_name = ? VALUES(688821145786183, 12701062, 3541, "[182.971,[6888.25,11457.8,0.58]]", "[]", 0, "[]", 6.9720001220703125, "Land_Campfire_burning")'

But when I re-merged with a Reality build at schema 0.39 it was fine and passed into my instance_deployable. Try checking for these 3 columns in your instance_deployable table:

Hitpoints | Fuel | Damage

If you don't have those, query this into your database:

Code:
ALTER TABLE `instance_deployable`
ADD COLUMN `Hitpoints`  varchar(500) NOT NULL DEFAULT '[]' AFTER `created`,
ADD COLUMN `Fuel`  double(13,0) NOT NULL DEFAULT 0 AFTER `Hitpoints`,
ADD COLUMN `Damage`  double(13,0) NOT NULL DEFAULT 0 AFTER `Fuel`;
 
Not entirely sure, I'm still new to MySQL. I can tell you I'm running MySQL 5.5 though, so you got 1 up on me. Are you sure you successfully merged the Reality package all the way up to the 0.39 schema? I went back and tried my fix on a Bliss Hive at schema 0.30 and got the same error:

Code:
2013-05-27 21:54:29 HiveExt: [Information] Method: 308 Params: 3541:Land_Campfire_burning:0:12701062:[182.971,[6888.25,11457.8,0.58]]:[]:[]:6.972:688821145786183:
2013-05-27 21:54:29 HiveExt: [Information] Result: ["PASS"]
2013-05-27 21:54:29 Database: [Error] Error 1452 (Cannot add or update a child row: a foreign key constraint fails (`bliss_3541`.`instance_deployable`, CONSTRAINT `instance_deployable_ibfk_2` FOREIGN KEY (`owner_id`) REFERENCES `survivor` (`id`))) in MySQLStmtExecute SQL: 'insert into `instance_deployable` (`unique_id`, `deployable_id`, `owner_id`, `instance_id`, `worldspace`, `inventory`, `Damage`,`Hitpoints`, `Fuel`, `created`) select ?, d.id, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP from deployable d where d.class_name = ? VALUES(688821145786183, 12701062, 3541, "[182.971,[6888.25,11457.8,0.58]]", "[]", 0, "[]", 6.9720001220703125, "Land_Campfire_burning")'

But when I re-merged with a Reality build at schema 0.39 it was fine and passed into my instance_deployable. Try checking for these 3 columns in your instance_deployable table:

Hitpoints | Fuel | Damage

If you don't have those, query this into your database:

Code:
ALTER TABLE `instance_deployable`
ADD COLUMN `Hitpoints`  varchar(500) NOT NULL DEFAULT '[]' AFTER `created`,
ADD COLUMN `Fuel`  double(13,0) NOT NULL DEFAULT 0 AFTER `Hitpoints`,
ADD COLUMN `Damage`  double(13,0) NOT NULL DEFAULT 0 AFTER `Fuel`;



I do have all 3. Here is an example string from my instance_deployable table:

Code:
369  767511095091333  13  384  1  [333.198,[7675.12,10950.9,0.12]]    []    2013-05-19 12:53:46  2013-05-19 12:53:46  []  0  0


I'm wondering if, while I was poking about, changed something in player_build.sqf and missed it while reverting. Which is why I was interested in your player_build file. I'll test with it now. Unless the issue is solely with my DB?

Edit: Still getting the same error after using your player_build
 
hiya ! i wanna add this mod to my dayz.st server but im so lost, please if i load my mission and server.pbo can any add this for me please?,
I can donate :)
Thanks !
 
I did notice that when manually entering the "fuel" value, it gets automatically rounded to the nearest whole number. (i.e. 4.20132135432 becomes 4)
 
BB Improvements still work on Epoch 1.0.1 just merged everything and it works ;)

Yeah Phoenix you was right I did messed up with that line. Should be fixed now.

/dayz_server/server_publishObject.sqf

Below this
Code:
_class =_this select 3;

Add this
Code:
_fuel = _this select 4;
_code = _this select 5; //added to pick up the code which we passed from player_build.sqf
Hello,kikyou2 could you give me a hand about edit BB1.2 stuff?

stuff was working,but when i active anti hack script,the menu banned,anybody who knew how to fix that>(i already added all actions in ah.sqf,but not working)
 
I'm wondering if, while I was poking about, changed something in player_build.sqf and missed it while reverting. Which is why I was interested in your player_build file. I'll test with it now. Unless the issue is solely with my DB?

Edit: Still getting the same error after using your player_build

Your issue seems, at this point, to be in the DB itself rather than the code. The code is trying to inject the deployable data into your table but it's failing because mySQL can't/won't accept it with the constraint error. But yeah, I'm still a newb at database stuff so the column data was my best guess. However make sure to still check that you are up to Reality 0.39 because that I suppose is the only version I know works.
 
I did notice that when manually entering the "fuel" value, it gets automatically rounded to the nearest whole number. (i.e. 4.20132135432 becomes 4)


Don't know how it is for other serverbuilds. But at epoch you can add anything you want, but the streamobjects round it to 3 digits after the comma so I decided to make the Keycode 4 digits long so that Keycode 4351 would be 4,351 fuel in the database.

Lucky as I was the database accepts over 1,0 values (was sceptically cause the value is normally maximum 1.0).

You can also add the keycode into the Hitpoints field like in Origins, but there you got to work with arrays and I thought to keep it simple is the best way.

One addition for Epoch users generally for using BaseBuilding Mod with new 1.0.1 Version:

Everything works you just have to comment out the playerbuild line in the compiles.sqf in your mission.pbo. That will prevent that the new player_build.sqf from new Epoch Crafting will be overwritten. The compiling isn't needed anyhow cause the Recipe Menu is pointing already at the player_build.sqf in the mission file. So there is no need do precompile it ;)

So you can benefit from both crafting systems
 
Your issue seems, at this point, to be in the DB itself rather than the code. The code is trying to inject the deployable data into your table but it's failing because mySQL can't/won't accept it with the constraint error. But yeah, I'm still a newb at database stuff so the column data was my best guess. However make sure to still check that you are up to Reality 0.39 because that I suppose is the only version I know works.

I do appreciate your help, unfortunately I'm far behind yourself as far as the DB goes. I'll try setting up a vanilla server with just bb1.2 and these improvements on a new db tomorrow.

I am at 0.39. Are the 'fuel' values stored as just XXXX or X.XXX?
 
Back
Top