Jump to content

[Release v1.0.5] Precise Base Building - Persistent bases after restart! (Updated 22/09/15)


Mikeeeyy

Recommended Posts

Precise Base Building

What is it?
Ever made a super neat base and then after a server restart it moves slightly creating gaps in your walls? This fixes that problem and keeps all buildables exactly where you placed them after a server restart. It also saves vehicle positions precisely which may or may not reduce the 'buginess' of vehicles on player placed floors.

What's new in version 1.0.5?
This version removes the quotation marks wrapping the direction and position values in the worldspace field. Installation is now also a lot easier.

Upgrading from v1.0.4 to 1.0.5
Tutorial to uninstall v1.0.4 is here: https://docs.google.com/document/d/1eQe0gf8VkKji_NRjLB_o1STTo1BnKlWkkEA6N29rvU4 (I refuse to use the text editor on this website... abysmal...)
Then simply follow the installation tutorial below.
You MUST execute this query on your database: http://pastebin.com/QZgLH6tw

Compatibility:
Works with Snap Building Pro.
Works with Plot for Life.
Works with Build Vectors.
Works with Private Hive Tools.
Objects already in the database won't be affected.

Credit:
KillzoneKid for the 'KK_fnc_floatToString' and 'KK_fnc_positionToString' functions which makes this possible.

Installation:

  1. Un-PBO your dayz_server.pbo.
  2. Open up 'server_publishObject.sqf' located in the compile folder (dayz_server\compile\server_publishObject.sqf).
    Find this line:
    _key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, 0 , _charID, _worldspace, [], [], 0,_uid];

    and replace it with:

    _key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, 0 , _charID, _worldspace call AN_fnc_formatWorldspace, [], [], 0,_uid];
  3. Open up 'server_functions.sqf' located in the init folder (dayz_server\init\server_functions.sqf).
    All these functions to the very bottom:
    KK_fnc_floatToString = {
        private "_arr";
        if (abs (_this - _this % 1) == 0) exitWith { str _this };
        _arr = toArray str abs (_this % 1);
        _arr set [0, 32];
        toString (toArray str (
            abs (_this - _this % 1) * _this / abs _this
        ) + _arr - [32])
    };
    
    KK_fnc_positionToString = {
        format [
            "[%1,%2,%3]",
            _this select 0 call KK_fnc_floatToString,
            _this select 1 call KK_fnc_floatToString,
            _this select 2 call KK_fnc_floatToString
        ]
    };
    
    AN_fnc_formatWorldspace = {
        private "_ws";
        _ws = toArray str _this;
        format ["[%1,%2%3]", _this select 0 call KK_fnc_floatToString, _this select 1 call KK_fnc_positionToString, toString ([_ws, (_ws find 93) + 1, count _ws - 2] call BIS_fnc_subSelect)]
    };
  4. Open up 'server_swapObject.sqf' located in the compile folder (dayz_server\compile\server_swapObject.sqf).
    Find this line:
    _key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, 0 , _charID, _worldspace, [], [], 0,_uid];

    and replace it with:

    _key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, 0 , _charID, _worldspace call AN_fnc_formatWorldspace, [], [], 0,_uid];
  5. Open up 'server_updateObject.sqf' located in the compile folder (dayz_server\compile\server_updateObject.sqf).
    Find this:
        _worldspace = [
            round (getDir _object),
            _position
        ];
    and replace it with:
        _worldspace = [getDir _object, _position] call AN_fnc_formatWorldspace;
    
  6. Save all the files you've edited, repack your 'dayz_server' folder into a PBO and you're done!
Edited by Mikeeeyy
Fixed AN_fnc_formatWorldspace
Link to comment
Share on other sites

Looks great.  Them gaps are a real pain :) .

 

When you say it is compatible with P4L, I take it you mean version 2+ ?.  Looks like it is but just want to confirm as that is the version also using the worldspace field ;) .

 

Thanks for the work and taking the time to share.

Link to comment
Share on other sites

Looks great.  Them gaps are a real pain :) .

 

When you say it is compatible with P4L, I take it you mean version 2+ ?.  Looks like it is but just want to confirm as that is the version also using the worldspace field ;) .

 

Thanks for the work and taking the time to share.

 

Yep, should work perfectly fine as it only modifies the existing entries in the worldspace array :)

Link to comment
Share on other sites

7c18af8f84.jpg

Version 1.0.1

  • Fixed a zero divisor error.
  • Shortened up the compiles by removing duplicate code.

86aab96380.jpg

  1. Replace old compiles with the ones below:
    KK_fnc_floatToString = {
    	private "_arr";
    	if (abs (_this - _this % 1) == 0) exitWith { _this };
    	_arr = toArray str abs (_this % 1);
    	_arr set [0, 32];
    	toString (toArray str (
    		abs (_this - _this % 1) * _this / abs _this
    	) + _arr - [32])
    };
    
    KK_fnc_positionToString = {
    	format [
    		"[%1,%2,%3]",
    		_this select 0 call KK_fnc_floatToString,
    		_this select 1 call KK_fnc_floatToString,
    		_this select 2 call KK_fnc_floatToString
    	]
    };
    
Link to comment
Share on other sites

Does this look right:

 

Before mod:

[161.962,[568.695,15333.1,0.131],"7656119797XXXXXX"]

 

After mod:

["308.735962","[13918.163086,13630.681641,0.392172]","7656119797XXXXXX"]
 
 
Using a compiles with provided code wrapped in a if (isServer)
 
Just noticed the update so I will apply :D
 
 
Edit: Appears to be working well in my test environment.   :wub: !
Link to comment
Share on other sites

Yep, should work perfectly fine as it only modifies the existing entries in the worldspace array :)

 

Great, that is what I thought.

 

Have you worked out the max length for the 3 values with [] and "" ?.  Whilst the actual changes should not affect P4L, there may be a little issue with blowing the max field size especially with other mods looking to use the woldspace field for their persistant data too. 

 

I have started a discussion on how best to manage usage of the worldspace filed http://epochmod.com/forum/index.php?/topic/15860-disscussion-on-usage-of-the-worlspace-field-by-mod-makers/?p=119210 so we can try to come up with a loose agreement between mod makers.  Although it wont really affect this mod, you may want to jump in or keep an eye on it.  Hopefully it will contain info from various mod makers intending to use this field so we can all agree and ajust accordingly.

Link to comment
Share on other sites

7c18af8f84.jpg

Version 1.0.2

  • Fixed the previous fix. (If you updated to v1.0.1 then this is a crucial update! If by a rare chance that the object's angle is 0, the code in server_monitor will fail and your server will fail to load! Sorry for the inconvenience.)

86aab96380.jpg

  1. Replace old 'KK_fnc_floatToString' with the one below.
    KK_fnc_floatToString = {
        private "_arr";
        if (abs (_this - _this % 1) == 0) exitWith { str _this };
        _arr = toArray str abs (_this % 1);
        _arr set [0, 32];
        toString (toArray str (
            abs (_this - _this % 1) * _this / abs _this
        ) + _arr - [32])
    };
Link to comment
Share on other sites

do u also have  any suggestions in how to get the server to load again?

 

after messing around for a bit only thing that i could get to work is a database backup

 

Yeah, look through the object_data table for a worldspace looking like this: example: [0, "[1325.2564, 1541.21564, 0.21512]", "165165168516541"]

For me it was the above case, to fix simply add quotations to the single number, 0 --> "0", this will fix the issue.

Example becomes this: ["0", "[1325.2564, 1541.21564, 0.21512]", "165165168516541"]

Link to comment
Share on other sites

My server is still unable to load.

14:11:51 Error in expression <)];

};

_dir = _worldspace select 0;

if (count (_worldspace select 1) == 3) then >

14:11:51 Error position: <count (_worldspace select 1) == 3) then >

14:11:51 Error count: Type String, expected Array,Config entry

14:11:51 File z\addons\dayz_server\system\server_monitor.sqf, line 125

Link to comment
Share on other sites

My server is still unable to load.

14:11:51 Error in expression <)];

};

_dir = _worldspace select 0;

if (count (_worldspace select 1) == 3) then >

14:11:51 Error position: <count (_worldspace select 1) == 3) then >

14:11:51 Error count: Type String, expected Array,Config entry

14:11:51 File z\addons\dayz_server\system\server_monitor.sqf, line 125

 

Read the reply above that I put to the other guy, I explain how to fix it, if you're still clueless dump your object_data table and I'll fix it for you.

Link to comment
Share on other sites

Great, that is what I thought.

 

Have you worked out the max length for the 3 values with [] and "" ?.  Whilst the actual changes should not affect P4L, there may be a little issue with blowing the max field size especially with other mods looking to use the woldspace field for their persistant data too. 

 

I have started a discussion on how best to manage usage of the worldspace filed http://epochmod.com/forum/index.php?/topic/15860-disscussion-on-usage-of-the-worlspace-field-by-mod-makers/?p=119210 so we can try to come up with a loose agreement between mod makers.  Although it wont really affect this mod, you may want to jump in or keep an eye on it.  Hopefully it will contain info from various mod makers intending to use this field so we can all agree and ajust accordingly.

 

Using this and P4L comes out at about half the worldspace limit from what I could see in my object_data table.

Link to comment
Share on other sites

Yeah, look through the object_data table for a worldspace looking like this: example: [0, "[1325.2564, 1541.21564, 0.21512]", "165165168516541"]

For me it was the above case, to fix simply add quotations to the single number, 0 --> "0", this will fix the issue.

Example becomes this: ["0", "[1325.2564, 1541.21564, 0.21512]", "165165168516541"]

ok thanks for the response

i quickly did a database backup cause we have around 20 people playing on the server this time of day and i had already tried to change the 0 to a differend value

good to know to look for the quotations next time

Link to comment
Share on other sites

ok thanks for the response

i quickly did a database backup cause we have around 20 people playing on the server this time of day and i had already tried to change the 0 to a differend value

good to know to look for the quotations next time

 

Np, sorry for the inconvenience.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×
×
  • Create New...