Jump to content

[Release] Build Vectors - Rotate objects in Dayz Epoch (v2.34 P4L & non-P4L)


striker

Recommended Posts

buildvectors.png

 

https://www.youtube.com/watch?v=gsa44JO02VQ&feature=youtu.be

 

Credit Is Due Where Due
 

 


Special Thanks to Raymix and his Script!

Special Thanks to RimBlock and his 

Special Thanks to Jossy and the future improvements I hope to see from him! Check out his work

Special Thanks to KamikazeXeX for his changes to the AdminBuild for Snap Building Pro and his help!

 

Notice
These files have been tested and work on the maps Chernarus and Taviana.

Installation
Warning: This script is fairly untested and could cause unforeseen problems. USE AT YOUR OWN RISK!
Please backup your database before you implement this encase something goes wrong!

Newest Build Vectors Installation (version 4)

 

Snap Build Pro Only

Files & Install guide

http://bitly.com/BuildVectorsSBPv4

 

Plot 4 Life & Snap Build Pro
Files:
http://bitly.com/BuildVectorsV4

Install Guide:
https://github.com/strikerforce/DayzBuildVectors


Legacy Installation (version 3)


Build Vectors with Snap Building Pro 1.4.1 (Optional Download with AdminBuild and Plot 4 Life)

Step 1:

Download the following files from this link (Without Admin Build and Plot 4 Life): http://bitly.com/BuildVectorsV3
Download the following files form this link (With Admin Build and Plot 4 Life) http://bitly.com/BuildVectorsAdminP4LV3
Once you have downloaded that file, move the custom folder to your root directory of your mission file.

Step 2:

Now that you have done that, open up your init.sqf from your mission folder.

Locate the following line.







call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\compiles.sqf"; //Compile regular functions

Right after that line, add this.

call compile preprocessFileLineNumbers "custom\compiles.sqf";  

Find the variable

DZE_BuildOnRoads

add these two/three global variables below it.

DZE_noRotate = []; //Objects that cannot be rotated. Ex: DZE_noRotate = ["VaultStorageLocked"]DZE_curPitch = 45; //Starting rotation angle. Only 1, 5, 45, or 90.//Optional, only if you are using Admin BuildWG_adminBuild = ["","","",""]; //Fill with player UID's

Step 3:


Open up you dayz_server.pbo.

Once you have opened you dayz_server.pbo, navigate to the init folder and open the server_functions.sqf file.

Find this line.









dayz_objectUID2 = {

Replace that whole function with this.

dayz_objectUID2 = {	private["_position","_dir","_key"];	if((count _this) == 2) then{		_dir = _this select 0;		_key = "";		_position = _this select 1;		{			_x = _x * 10;			if ( _x < 0 ) then { _x = _x * -10 };			_key = _key + str(round(_x));		} count _position;		_key = _key + str(round(_dir));	}else{		if((count _this) == 3) then{					if(typename (_this select 2) == "ARRAY")then{							_vector = _this select 2;							if(count _vector == 2)then{								if(((count (_vector select 0)) == 3) && ((count (_vector select 1)) == 3))then{										_key = "";										_position = _this select 1;										{											_x = _x * 10;											if ( _x < 0 ) then { _x = _x * -10 };											_key = _key + str(round(_x));										} count _position;																				_vecCnt = 0;										{											_set = _x;											{												_vecCnt = _vecCnt + (round (_x * 100))																							} foreach _set;																					} foreach _vector;										if(_vecCnt < 0)then{											_vecCnt = ((_vecCnt * -1) * 3);										};										_key = _key + str(_vecCnt);									}else{									_dir = _this select 0;									_key = "";									_position = _this select 1;									{										_x = _x * 10;										if ( _x < 0 ) then { _x = _x * -10 };										_key = _key + str(round(_x));									} count _position;									_key = _key + str(round(_dir));								};							}else{								_dir = _this select 0;								_key = "";								_position = _this select 1;								{									_x = _x * 10;									if ( _x < 0 ) then { _x = _x * -10 };									_key = _key + str(round(_x));								} count _position;								_key = _key + str(round(_dir));							};											}else{						_dir = _this select 0;						_key = "";						_position = _this select 1;						{							_x = _x * 10;							if ( _x < 0 ) then { _x = _x * -10 };							_key = _key + str(round(_x));						} count _position;						_key = _key + str(round(_dir));					};		}else{			if((count _this) == 4) then{					if(typename (_this select 3) == "ARRAY")then{						_vector = _this select 3;						if(count _vector == 2)then{							if(((count (_vector select 0)) == 3) && ((count (_vector select 1)) == 3))then{										_key = "";										_position = _this select 1;										{											_x = _x * 10;											if ( _x < 0 ) then { _x = _x * -10 };											_key = _key + str(round(_x));										} count _position;																				_vecCnt = 0;										{											_set = _x;											{												_vecCnt = _vecCnt + (round (_x * 100))																							} foreach _set;																					} foreach _vector;										if(_vecCnt < 0)then{											_vecCnt = ((_vecCnt * -1) * 3);										};										_key = _key + str(_vecCnt);								}else{								_dir = _this select 0;								_key = "";								_position = _this select 1;								{									_x = _x * 10;									if ( _x < 0 ) then { _x = _x * -10 };									_key = _key + str(round(_x));								} count _position;								_key = _key + str(round(_dir));							};						}else{							_dir = _this select 0;							_key = "";							_position = _this select 1;							{								_x = _x * 10;								if ( _x < 0 ) then { _x = _x * -10 };								_key = _key + str(round(_x));							} count _position;							_key = _key + str(round(_dir));						};					}else{						if(typename (_this select 2) == "ARRAY")then{							_vector = _this select 2;							if(count _vector == 2)then{								if(((count (_vector select 0)) == 3) && ((count (_vector select 1)) == 3))then{											_key = "";											_position = _this select 1;											{												_x = _x * 10;												if ( _x < 0 ) then { _x = _x * -10 };												_key = _key + str(round(_x));											} count _position;																						_vecCnt = 0;											{												_set = _x;												{													_vecCnt = _vecCnt + (round (_x * 100))																									} foreach _set;																							} foreach _vector;											if(_vecCnt < 0)then{												_vecCnt = ((_vecCnt * -1) * 3);											};											_key = _key + str(_vecCnt);									}else{									_dir = _this select 0;									_key = "";									_position = _this select 1;									{										_x = _x * 10;										if ( _x < 0 ) then { _x = _x * -10 };										_key = _key + str(round(_x));									} count _position;									_key = _key + str(round(_dir));								};							}else{								_dir = _this select 0;								_key = "";								_position = _this select 1;								{									_x = _x * 10;									if ( _x < 0 ) then { _x = _x * -10 };									_key = _key + str(round(_x));								} count _position;								_key = _key + str(round(_dir));							};						}else{							_dir = _this select 0;							_key = "";							_position = _this select 1;							{								_x = _x * 10;								if ( _x < 0 ) then { _x = _x * -10 };								_key = _key + str(round(_x));							} count _position;							_key = _key + str(round(_dir));						};					};			}else{				_dir = _this select 0;				_key = "";				_position = _this select 1;				{					_x = _x * 10;					if ( _x < 0 ) then { _x = _x * -10 };					_key = _key + str(round(_x));				} count _position;				_key = _key + str(round(_dir));			};		};			};	_key}; 

Step 4:

Now navigate to the system folder and open the server_monitor.sqf file.

Find the section that begins with the follow line.









// # NOW SPAWN OBJECTS #

And ends with.

// # END SPAWN OBJECTS #

Replace everything in between that with.

// # NOW SPAWN OBJECTS #	_totalvehicles = 0;	{		_idKey = 		_x select 1;		_type =			_x select 2;		_ownerID = 		_x select 3;		_worldspace = 	_x select 4;		_intentory =	_x select 5;		_hitPoints =	_x select 6;		_fuel =			_x select 7;		_damage = 		_x select 8;				_dir = 0;				_pos = [0,0,0];		_wsDone = false;		if (count _worldspace >= 2) then		{			if ((typeName (_worldspace select 0)) == "STRING") then {				_worldspace set [0, call compile (_worldspace select 0)];				_worldspace set [1, call compile (_worldspace select 1)];			};			_dir = _worldspace select 0;			if (count (_worldspace select 1) == 3) then {				_pos = _worldspace select 1;				_wsDone = true;			}		};					if (!_wsDone) then {			if (count _worldspace >= 1) then { _dir = _worldspace select 0; };			_pos = [getMarkerPos "center",0,4000,10,0,2000,0] call BIS_fnc_findSafePos;			if (count _pos < 3) then { _pos = [_pos select 0,_pos select 1,0]; };			diag_log ("MOVED OBJ: " + str(_idKey) + " of class " + _type + " to pos: " + str(_pos));		};				_vector = [[0,0,0],[0,0,0]];		_vecExists = false;		_ownerPUID = "0";		if (count _worldspace >= 3) then{			if(count _worldspace == 3) then{					if(typename (_worldspace select 2) == "STRING")then{						_ownerPUID = _worldspace select 2;					}else{						 if(typename (_worldspace select 2) == "ARRAY")then{							_vector = _worldspace select 2;							if(count _vector == 2)then{								if(((count (_vector select 0)) == 3) && ((count (_vector select 1)) == 3))then{									_vecExists = true;								};							};						};										};								}else{				//Was not 3 elements, so check if 4 or more				if(count _worldspace == 4) then{					if(typename (_worldspace select 3) == "STRING")then{						_ownerPUID = _worldspace select 3;					}else{						if(typename (_worldspace select 2) == "STRING")then{							_ownerPUID = _worldspace select 2;						};					};											if(typename (_worldspace select 2) == "ARRAY")then{						_vector = _worldspace select 2;						if(count _vector == 2)then{							if(((count (_vector select 0)) == 3) && ((count (_vector select 1)) == 3))then{								_vecExists = true;							};						};					}else{						if(typename (_worldspace select 3) == "ARRAY")then{							_vector = _worldspace select 3;							if(count _vector == 2)then{								if(((count (_vector select 0)) == 3) && ((count (_vector select 1)) == 3))then{									_vecExists = true;								};							};						};					};									}else{					//More than 3 or 4 elements found					//Might add a search for the vector, ownerPUID will equal 0				};			};		};		   	   		// diag_log format["Server_monitor: [ObjectID = %1]  [ClassID = %2] [_ownerPUID = %3]", _idKey, _type, _ownerPUID];				if (_damage < 1) then {			//diag_log format["OBJ: %1 - %2", _idKey,_type];						//Create it			_object = createVehicle [_type, _pos, [], 0, "CAN_COLLIDE"];			_object setVariable ["lastUpdate",time];			_object setVariable ["ObjectID", _idKey, true];			_object setVariable ["OwnerPUID", _ownerPUID, true];						_lockable = 0;			if(isNumber (configFile >> "CfgVehicles" >> _type >> "lockable")) then {				_lockable = getNumber(configFile >> "CfgVehicles" >> _type >> "lockable");			};			// fix for leading zero issues on safe codes after restart			if (_lockable == 4) then {				_codeCount = (count (toArray _ownerID));				if(_codeCount == 3) then {					_ownerID = format["0%1", _ownerID];				};				if(_codeCount == 2) then {					_ownerID = format["00%1", _ownerID];				};				if(_codeCount == 1) then {					_ownerID = format["000%1", _ownerID];				};			};			if (_lockable == 3) then {				_codeCount = (count (toArray _ownerID));				if(_codeCount == 2) then {					_ownerID = format["0%1", _ownerID];				};				if(_codeCount == 1) then {					_ownerID = format["00%1", _ownerID];				};			};			_object setVariable ["CharacterID", _ownerID, true];						clearWeaponCargoGlobal  _object;			clearMagazineCargoGlobal  _object;			// _object setVehicleAmmo DZE_vehicleAmmo;						_object setdir _dir;						if(_vecExists)then{				_object setVectorDirAndUp _vector;			};						_object setposATL _pos;			_object setDamage _damage;						if ((typeOf _object) in dayz_allowedObjects) then {				if (DZE_GodModeBase) then {					_object addEventHandler ["HandleDamage", {false}];				} else {					_object addMPEventHandler ["MPKilled",{_this call object_handleServerKilled;}];				};				// Test disabling simulation server side on buildables only.				_object enableSimulation false;				// used for inplace upgrades && lock/unlock of safe				_object setVariable ["OEMPos", _pos, true];							};			if (count _intentory > 0) then {				if (_type in DZE_LockedStorage) then {					// Fill variables with loot					_object setVariable ["WeaponCargo", (_intentory select 0),true];					_object setVariable ["MagazineCargo", (_intentory select 1),true];					_object setVariable ["BackpackCargo", (_intentory select 2),true];				} else {					//Add weapons					_objWpnTypes = (_intentory select 0) select 0;					_objWpnQty = (_intentory select 0) select 1;					_countr = 0;										{						if(_x in (DZE_REPLACE_WEAPONS select 0)) then {							_x = (DZE_REPLACE_WEAPONS select 1) select ((DZE_REPLACE_WEAPONS select 0) find _x);						};						_isOK = 	isClass(configFile >> "CfgWeapons" >> _x);						if (_isOK) then {							_object addWeaponCargoGlobal [_x,(_objWpnQty select _countr)];						};						_countr = _countr + 1;					} count _objWpnTypes; 									//Add Magazines					_objWpnTypes = (_intentory select 1) select 0;					_objWpnQty = (_intentory select 1) select 1;					_countr = 0;					{						if (_x == "BoltSteel") then { _x = "WoodenArrow" }; // Convert BoltSteel to WoodenArrow						if (_x == "ItemTent") then { _x = "ItemTentOld" };						_isOK = 	isClass(configFile >> "CfgMagazines" >> _x);						if (_isOK) then {							_object addMagazineCargoGlobal [_x,(_objWpnQty select _countr)];						};						_countr = _countr + 1;					} count _objWpnTypes;					//Add Backpacks					_objWpnTypes = (_intentory select 2) select 0;					_objWpnQty = (_intentory select 2) select 1;					_countr = 0;					{						_isOK = 	isClass(configFile >> "CfgVehicles" >> _x);						if (_isOK) then {							_object addBackpackCargoGlobal [_x,(_objWpnQty select _countr)];						};						_countr = _countr + 1;					} count _objWpnTypes;				};			};							if (_object isKindOf "AllVehicles") then {				{					_selection = _x select 0;					_dam = _x select 1;					if (_selection in dayZ_explosiveParts && _dam > 0.8) then {_dam = 0.8};					[_object,_selection,_dam] call object_setFixServer;				} count _hitpoints;				_object setFuel _fuel;				if (!((typeOf _object) in dayz_allowedObjects)) then {										//_object setvelocity [0,0,1];					_object call fnc_veh_ResetEH;												if(_ownerID != "0" && !(_object isKindOf "Bicycle")) then {						_object setvehiclelock "locked";					};										_totalvehicles = _totalvehicles + 1;					// total each vehicle					serverVehicleCounter set [count serverVehicleCounter,_type];				};			};			//Monitor the object			PVDZE_serverObjectMonitor set [count PVDZE_serverObjectMonitor,_object];		};	} count (_BuildingQueue + _objectQueue);	// # END SPAWN OBJECTS #

Step 5:

Now go back to your mission folder and open up the file description.ext.

Add the following to the end of that file.









#include "custom\snap_pro\snappoints.hpp"

Step 6:

Install Precise Base Building by Mikeeeyy.



NOTE: server_monitor.sqf is already done for you. Also, This script permanently affects the database. If you ever remove vector build or dayz epoch updates, remember to have this part in your server_monitor.sqf








if (count _worldspace >= 2) then		{			if ((typeName (_worldspace select 0)) == "STRING") then {				_worldspace set [0, call compile (_worldspace select 0)];				_worldspace set [1, call compile (_worldspace select 1)];			};			_dir = _worldspace select 0;			if (count (_worldspace select 1) == 3) then {				_pos = _worldspace select 1;				_wsDone = true;			}		};	 

Step 7 (Optional):
If you are planning to use the noRotate array, you need to see this post for a fix.




Road Map

  • Keep menus up when clicked for better user experience

Known Issues

  • None

Change Log





Version 1:

Released

Version 1.1:

Updated server_monitor.sqf to make sure the vector is the correct format.

Version 2:

Updated files for the snap building pro update v1.3.

Added files for Adminbuild and Right Clickables.

Version 3:

Updated files for snap building pro v1.4.1

Ghost preview supported (Thanks Jossy!)

Version 4:

Cleaned up some of the HORRENDOUS code :P

Fixed issue with objects not snapping correctly to objects of a certain degree after restart. ;)

 

 

Appreciate and support my work? btn_donate_LG.gif

Link to comment
Share on other sites

for everyone who need it,

 

s_player_setVectorsReset
s_player_setVectorsForward
s_player_setVectorsBack
s_player_setVectorsLeft
s_player_setVectorsRight
s_player_setVectors1
s_player_setVectors5
s_player_setVectors45
s_player_setVectors90
 
are the action names for maybe antihack like infi.
Link to comment
Share on other sites

 

for everyone who need it,

 

s_player_setVectorsReset
s_player_setVectorsForward
s_player_setVectorsBack
s_player_setVectorsLeft
s_player_setVectorsRight
s_player_setVectors1
s_player_setVectors5
s_player_setVectors45
s_player_setVectors90
 
are the action names for maybe antihack like infi.

 

You will likely want to add those to your custom variables for undefined variable errors in the RPT

Link to comment
Share on other sites

get the following error:

 

8:50:00 Error in expression <tdir _dir;
 
if(_vecExists)then{
_object setVectorDirAndUp _vector;
};
 
_object s>
18:50:00   Error position: <setVectorDirAndUp _vector;
};
 
_object s>
18:50:00   Error setvectordirandup: Type string, expected Array
18:50:00 File z\addons\dayz_server\system\server_monitor.sqf, line 172
 
Due to the error my server will stuck in waiting for server to start authentification
Link to comment
Share on other sites

Works Great. Been testing all morning with various objects and seems very well done. There is a bit of a learning curve to manipulate them (buildables) to your liking, but overall a HUGE step in the right direction for base building. I was even able to build cinder roofs! 

 

Keep up the good work!

 

~RED

 

PS, Had no problems with the latest version of infistar.

Link to comment
Share on other sites

 

get the following error:

 

8:50:00 Error in expression <tdir _dir;
 
if(_vecExists)then{
_object setVectorDirAndUp _vector;
};
 
_object s>
18:50:00   Error position: <setVectorDirAndUp _vector;
};
 
_object s>
18:50:00   Error setvectordirandup: Type string, expected Array
18:50:00 File z\addons\dayz_server\system\server_monitor.sqf, line 172
 
Due to the error my server will stuck in waiting for server to start authentification

 

 

Are you using any other mod that uses the worldspace array? Sounds like the worldspace array is like this...

 

[30.61,[8289.48,2503.63,0],"string"]

 

A simple fix would be to do the following:

 

Find the following line in server_monitor.sqf file in the systems folder of the server.pbo 

if (count _worldspace >= 2) then{

Replace that whole if statement with the following.

		if (count _worldspace >= 2) then
		{
			if(count _worldspace == 3) then{
				_vector = _worldspace select 2;
				if(typename _vector == "ARRAY")then{
					if(count _vector == 2)then{
						if(((count (_vector select 0)) == 3) && ((count (_vector select 1)) == 3))then{
							_vecExists = true;
						};
					};

				};

			};
			_dir = _worldspace select 0;
			if (count (_worldspace select 1) == 3) then {
				_pos = _worldspace select 1;
				_wsDone = true;
			}
		};
Link to comment
Share on other sites

What did you add to fn_selfActions.sqf? I already have a custom one due to the currency system on my server.

 

Not much actually, just two lines.

 

Around line 632 on a fresh copy:

s_player_upgrade_build = player addAction [format[localize "STR_EPOCH_ACTIONS_UPGRADE",_text], "custom\player_upgrade.sqf",_cursorTarget, -1, false, true, "",""];

Around line 650 on a fresh copy:

s_player_downgrade_build = player addAction [format[localize "STR_EPOCH_ACTIONS_REMLOCK",_text], "custom\player_buildingDowngrade.sqf",_cursorTarget, -2, false, true, "",""];

Basically a file path change.  :)

Link to comment
Share on other sites

Great addition to Raymix's Snap Building! One thing I'd suggest is adding support for RimBlock's plot for life as that uses the same entry in the worldspace array, maybe add a config variable like "BV_PlotForLifeInstalled = true" then move the worldspace entry over by one, just a suggestion anyhow. Creates so many base building possibilities it's great!

 

If you added support it would look like this:

[[<dir>, <position>], <player uid>, <vector>]

Link to comment
Share on other sites

I am hoping Striker's addition and Rimblock's PfL will make their way into official epoch as toggleable options from init.sqf for an "ultimate compatibility" between these mods if I may, lol. I mean.. lets keep them mission file sizes low, right?  :ph34r:

Link to comment
Share on other sites

I am hoping Striker's addition and Rimblock's PfL will make their way into official epoch as toggleable options from init.sqf for an "ultimate compatibility" between these mods if I may, lol. I mean.. lets keep them mission file sizes low, right?  :ph34r:

This. As far as I'm aware RimBlock's P4L is making it's way into Official Epoch but won't make it until 1.0.6.

Link to comment
Share on other sites

Not much actually, just two lines.

 

Around line 632 on a fresh copy:

s_player_upgrade_build = player addAction [format[localize "STR_EPOCH_ACTIONS_UPGRADE",_text], "custom\player_upgrade.sqf",_cursorTarget, -1, false, true, "",""];

Around line 650 on a fresh copy:

s_player_downgrade_build = player addAction [format[localize "STR_EPOCH_ACTIONS_REMLOCK",_text], "custom\player_buildingDowngrade.sqf",_cursorTarget, -2, false, true, "",""];

Basically a file path change.  :)

Thanks, works great!

Link to comment
Share on other sites

Arg I really want this.. but I don't want to give up geeks admin build. It is awesome for building stuff for admin events. Lets you set them up super fast. Is there any way to add geeks admin build to this?

 

I was having similar thoughts, so I decided to edit some files. 

 

I used diffmerge to compare the files and copied the appropriate parts across

 

player_build.sqf (THIS ONE DOESNT WORK PROPERLY!!!!) - PROPER WORKING VERSION DOWN BELOW

/*
	DayZ Base Building
	Made for DayZ Epoch please ask permission to use/edit/distrubute email [email protected].
*/
private ["_helperColor","_objectHelper","_objectHelperDir","_objectHelperPos","_canDo",
"_location","_dir","_classname","_item","_hasRequiredTools","_missingT","_missingB","_hasrequireditem","_missing","_hastoolweapon","_cancel","_reason","_started","_finished","_animState","_isMedic","_dis","_sfx","_hasbuilditem","_tmpbuilt","_onLadder","_isWater","_require","_text","_offset","_IsNearPlot","_isOk","_location1","_location2","_counter","_limit","_proceed","_num_removed","_position","_object","_canBuildOnPlot","_friendlies","_nearestPole","_ownerID","_findNearestPoles","_findNearestPole","_distance","_classnametmp","_ghost","_isPole","_needText","_lockable","_zheightchanged","_rotate","_combination_1","_combination_2","_combination_3","_combination_4","_combination","_combination_1_Display","_combinationDisplay","_zheightdirection","_abort","_isNear","_need","_needNear","_vehicle","_inVehicle","_previewCounter","_requireplot","_objHupDiff","_objHDiff","_isLandFireDZ","_isTankTrap","_isNear2","_typeIsString","_isBuildAdmin","_needBuildItem","_hasbuilditems","_itemIn","_countIn","_qty","_missingQty","_textMissing","_removed","_tobe_removed_total","_removed_total","_ownerPUID", "_playerUID"];

DZE_BuildVector = [[0,0,0],[0,0,0]];

if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_40") , "PLAIN DOWN"]; };
DZE_ActionInProgress = true;

// disallow building if too many objects are found within 30m
if((count ((getPosATL player) nearObjects ["All",30])) >= DZE_BuildingLimit) exitWith {DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_41"), "PLAIN DOWN"];};

_onLadder =		(getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
_isWater = 		dayz_isSwimming;
_cancel = false;
_reason = "";
_canBuildOnPlot = false;
_isBuildAdmin = (getPlayerUID player) in WG_adminBuild;

_vehicle = vehicle player;
_inVehicle = (_vehicle != player);

_playerUID = getPlayerUID player;
//snap
helperDetach = false;
_canDo = (!r_drag_sqf and !r_player_unconscious);

_vector = [];

fnc_SetPitchBankYawBuild = { 
    private ["_object","_rotations","_aroundX","_aroundY","_aroundZ","_dirX","_dirY","_dirZ","_upX","_upY","_upZ","_dir","_up","_dirXTemp",
    "_upXTemp"];
    _object = _this select 0; 
    _rotations = _this select 1; 
    _aroundX = _rotations select 0; 
    _aroundY = _rotations select 1; 
    _aroundZ = (360 - (_rotations select 2)) - 360; 
    _dirX = 0; 
    _dirY = 1; 
    _dirZ = 0; 
    _upX = 0; 
    _upY = 0; 
    _upZ = 1; 
    if (_aroundX != 0) then { 
        _dirY = cos _aroundX; 
        _dirZ = sin _aroundX; 
        _upY = -sin _aroundX; 
        _upZ = cos _aroundX; 
    }; 
    if (_aroundY != 0) then { 
        _dirX = _dirZ * sin _aroundY; 
        _dirZ = _dirZ * cos _aroundY; 
        _upX = _upZ * sin _aroundY; 
        _upZ = _upZ * cos _aroundY; 
    }; 
    if (_aroundZ != 0) then { 
        _dirXTemp = _dirX; 
        _dirX = (_dirXTemp* cos _aroundZ) - (_dirY * sin _aroundZ); 
        _dirY = (_dirY * cos _aroundZ) + (_dirXTemp * sin _aroundZ);        
        _upXTemp = _upX; 
        _upX = (_upXTemp * cos _aroundZ) - (_upY * sin _aroundZ); 
        _upY = (_upY * cos _aroundZ) + (_upXTemp * sin _aroundZ); 		
    }; 
    _dir = [_dirX,_dirY,_dirZ]; 
    _up = [_upX,_upY,_upZ]; 
    _object setVectorDirAndUp [_dir,_up];
	DZE_BuildVector = [_dir,_up];
}; 

DZE_Q = false;
DZE_Z = false;

DZE_Q_alt = false;
DZE_Z_alt = false;

DZE_Q_ctrl = false;
DZE_Z_ctrl = false;

DZE_5 = false;
DZE_4 = false;
DZE_6 = false;
DZE_F = false;

DZE_cancelBuilding = false;

call gear_ui_init;
closeDialog 1;

if (_isWater) exitWith {DZE_ActionInProgress = false; cutText [localize "str_player_26", "PLAIN DOWN"];};
if (_inVehicle) exitWith {DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_42"), "PLAIN DOWN"];};
if (_onLadder) exitWith {DZE_ActionInProgress = false; cutText [localize "str_player_21", "PLAIN DOWN"];};
if (player getVariable["combattimeout", 0] >= time) exitWith {DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_43"), "PLAIN DOWN"];};

_typeIsString = ((typeName _this) == "STRING");
//diag_log format["Type is STRING: %1",_typeIsString];
if (_typeIsString) then {
	_item =	_this;
};
if (!_typeIsString) then {
	_item =	_this select 0;
};

// Need Near Requirements
_abort = false;
_distance = 10;
_reason = "";

if (_typeIsString) then {
	_needNear = 	getArray (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "neednearby");

	{
		switch(_x) do{
			case "fire":
			{
				_distance = 3;
				_isNear = {inflamed _x} count (getPosATL player nearObjects _distance);
				if(_isNear == 0) then {
					_abort = true;
					_reason = "fire";
				};
			};
			case "workshop":
			{
				_distance = 3;
				_isNear = count (nearestObjects [player, ["Wooden_shed_DZ","WoodShack_DZ","WorkBench_DZ"], _distance]);
				if(_isNear == 0) then {
					_abort = true;
					_reason = "workshop";
				};
			};
			case "fueltank":
			{
				_distance = 30;
				_isNear = count (nearestObjects [player, dayz_fuelsources, _distance]);
				_isNear2 = nearestObjects [player, dayz_fuelsources, _distance];
				if(_isNear == 0) then {
					_abort = true;
					_reason = "fuel tank";
					_distance = 30;
				};
			};
		};
	} forEach _needNear;


	if(_abort) exitWith {
		cutText [format[(localize "str_epoch_player_135"),_reason,_distance], "PLAIN DOWN"];
		DZE_ActionInProgress = false;
	};
};

if (_typeIsString) then {
	_classname = 	getText (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "create");
	_classnametmp = _classname;
	_require =  getArray (configFile >> "cfgMagazines" >> _this >> "ItemActions" >> "Build" >> "require");
};
if (!_typeIsString) then {
	_classname = _this select 0;
	_classnametmp = _classname;
	_require = _this select 1;
};
_text = 		getText (configFile >> "CfgVehicles" >> _classname >> "displayName");
_ghost = getText (configFile >> "CfgVehicles" >> _classname >> "ghostpreview");

_lockable = 0;
if(isNumber (configFile >> "CfgVehicles" >> _classname >> "lockable")) then {
	_lockable = getNumber(configFile >> "CfgVehicles" >> _classname >> "lockable");
};

_requireplot = DZE_requireplot;
if(isNumber (configFile >> "CfgVehicles" >> _classname >> "requireplot")) then {
	_requireplot = getNumber(configFile >> "CfgVehicles" >> _classname >> "requireplot");
};

_isAllowedUnderGround = 1;
if(isNumber (configFile >> "CfgVehicles" >> _classname >> "nounderground")) then {
	_isAllowedUnderGround = getNumber(configFile >> "CfgVehicles" >> _classname >> "nounderground");
};


if (!_typeIsString) then {
	_offset = _this select 3;
};
if (_typeIsString) then {
	_offset = 	getArray (configFile >> "CfgVehicles" >> _classname >> "offset");
	if((count _offset) <= 0) then {
		_offset = [0,1.5,0];
	};
};

_isPole = (_classname == "Plastic_Pole_EP1_DZ");
_isLandFireDZ = (_classname == "Land_Fire_DZ");

_distance = DZE_PlotPole select 0;
_needText = localize "str_epoch_player_246";

if(_isPole) then {
	_distance = DZE_PlotPole select 1;
};

// check for near plot
_findNearestPoles = nearestObjects [(vehicle player), ["Plastic_Pole_EP1_DZ"], _distance];
_findNearestPole = [];

{
	if (alive _x) then {
		_findNearestPole set [(count _findNearestPole),_x];
	};
} count _findNearestPoles;

_IsNearPlot = count (_findNearestPole);

// If item is plot pole && another one exists within 45m
if(_isPole && _IsNearPlot > 0) exitWith {  DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_44") , "PLAIN DOWN"]; };

if(_IsNearPlot == 0) then {

	// Allow building of plot
	if(_requireplot == 0 || _isLandFireDZ) then {
		_canBuildOnPlot = true;
	};

} else {
	// Since there are plots nearby we check for ownership && then for friend status

	// check nearby plots ownership && then for friend status
	_nearestPole = _findNearestPole select 0;

	// Find owner
	_ownerID = _nearestPole getVariable ["ownerPUID","0"];

	 // //diag_log format["Player_build start: [PlayerUID = %1]  [OwnerID = %2]", _playerUID, _ownerID];

	// check if friendly to owner
	if(_playerUID == _ownerID) then {  //Keep ownership
		// owner can build anything within his plot except other plots
		if(!_isPole) then {
			_canBuildOnPlot = true;		
		};
	} else {
		// disallow building plot
		if(!_isPole) then {
			_friendlies		= player getVariable ["friendlyTo",[]];
			// check if friendly to owner
			if(_ownerID in _friendlies) then {
				_canBuildOnPlot = true;
			};
		};
	};
};

// _message
if(!_canBuildOnPlot) exitWith {  DZE_ActionInProgress = false; cutText [format[(localize "STR_EPOCH_PLAYER_135"),_needText,_distance] , "PLAIN DOWN"]; };

_missingT = "";
_missingB = "";
_hasRequiredTools = true;
_hasbuilditem = true;
if (!_isBuildAdmin) then {
	{
		//diag_log format["Testing for tool: %1",_x];
		_hastoolweapon = _x in weapons player;
		if(!_hastoolweapon) exitWith {_hasRequiredTools = false; _missingT = getText (configFile >> "cfgWeapons" >> _x >> "displayName");};
	} forEach _require;

	if (!_typeIsString && _hasRequiredTools) then {
		_needBuildItem = _this select 2;
		{
			_itemIn = _x select 0;
			_countIn = _x select 1;
			_qty = { (_x == _itemIn) || (configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn) } count magazines player;
			if(_qty < _countIn) exitWith { _missingB = getText(configFile >> "CfgMagazines" >> _itemIn >> "displayName"); _missingQty = (_countIn - _qty); _hasbuilditem = false;};
		} forEach _needBuildItem;
	};
	
	if (_typeIsString && _hasRequiredTools) then {
		_hasbuilditem = _this in magazines player;
	};
};
// Message If missing
if (!_hasRequiredTools) exitWith {DZE_ActionInProgress = false; cutText [format[(localize "str_epoch_player_137"),_missingT] , "PLAIN DOWN"];};

if (!_typeIsString && !_hasbuilditem) exitWith {DZE_ActionInProgress = false; cutText [format[(localize "str_epoch_player_146"),_missingQty, _missingB], "PLAIN DOWN"];};
if (_typeIsString && !_hasbuilditem) exitWith {DZE_ActionInProgress = false; cutText [format[(localize "str_player_31"),_text,"build"] , "PLAIN DOWN"]; };


//Proceed after item check
if (_hasRequiredTools && _hasbuilditem) then {

	_location = [0,0,0];
	_isOk = true;

	// get inital players position
	_location1 = getPosATL player;
	_dir = getDir player;

	// if ghost preview available use that instead
	/*if (_ghost != "") then {
		_classname = _ghost;
	};*/

	_object = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"];
	_object setDir 0;
	//Build gizmo
	_objectHelper = "Sign_sphere10cm_EP1" createVehicle _location;
	_helperColor = "#(argb,8,8,3)color(0,0,0,0,ca)";
	_objectHelper setobjecttexture [0,_helperColor];
	_objectHelper attachTo [player,_offset];
	_object attachTo [_objectHelper,[0,0,0]];
	_position = getPosATL _objectHelper;
	
	//cutText [(localize "str_epoch_player_45"), "PLAIN DOWN"];

	_objHDiff = 0;

if (isClass (missionConfigFile >> "SnapBuilding" >> _classname)) then {	
	["","","",["Init",_object,_classname,_objectHelper]] spawn snap_build;
};
		if (isClass (missionConfigFile >> "SnapBuilding" >> _classname)) then {	
		["","","",["Init",_object,_classname,_objectHelper]] spawn snap_build;
	};

	DZE_updateVec = false;
	DZE_memDir = getDir _objectHelper;
	DZE_memForBack = 0;
	DZE_memLeftRight = 0;
	if !(_classname in DZE_noRotate) then{
		s_player_setVectorsReset = player addaction ["Reset","custom\snap_pro\player_vectorChange.sqf","reset"];
		s_player_setVectorsForward = player addaction ["Pitch Forward","custom\snap_pro\player_vectorChange.sqf","forward"];
		s_player_setVectorsBack = player addaction ["Pitch Back","custom\snap_pro\player_vectorChange.sqf","back"];
		s_player_setVectorsLeft = player addaction ["Bank Left","custom\snap_pro\player_vectorChange.sqf","left"];
		s_player_setVectorsRight = player addaction ["Bank Right","custom\snap_pro\player_vectorChange.sqf","right"];
		s_player_setVectors1 = player addaction ["Increment by 1 degree","custom\snap_pro\player_vectorChange.sqf","1"];
		s_player_setVectors5 = player addaction ["Increment by 5 degrees","custom\snap_pro\player_vectorChange.sqf","5"];
		s_player_setVectors45 = player addaction ["Increment by 45 degrees","custom\snap_pro\player_vectorChange.sqf","45"];
		s_player_setVectors90 = player addaction ["Increment by 90 degrees","custom\snap_pro\player_vectorChange.sqf","90"];
	};
	
	while {_isOk} do {

		_zheightchanged = false;
		_zheightdirection = "";
		_rotate = false;

		if (DZE_Q) then {
			DZE_Q = false;
			_zheightdirection = "up";
			_zheightchanged = true;
		};
		if (DZE_Z) then {
			DZE_Z = false;
			_zheightdirection = "down";
			_zheightchanged = true;
		};
		if (DZE_Q_alt) then {
			DZE_Q_alt = false;
			_zheightdirection = "up_alt";
			_zheightchanged = true;
		};
		if (DZE_Z_alt) then {
			DZE_Z_alt = false;
			_zheightdirection = "down_alt";
			_zheightchanged = true;
		};
		if (DZE_Q_ctrl) then {
			DZE_Q_ctrl = false;
			_zheightdirection = "up_ctrl";
			_zheightchanged = true;
		};
		if (DZE_Z_ctrl) then {
			DZE_Z_ctrl = false;
			_zheightdirection = "down_ctrl";
			_zheightchanged = true;
		};
		if (DZE_4) then {
			_rotate = true;
			DZE_4 = false;
			if (helperDetach) then {
				_dir = -45;
				DZE_memDir = DZE_memDir - 45;
			} else {
				_dir = 180;
				DZE_memDir = 180;
			};
		};
		if (DZE_6) then {
			_rotate = true;
			DZE_6 = false;
			if (helperDetach) then {
				_dir = 45;
				DZE_memDir = DZE_memDir + 45;
			} else {
				_dir = 0;
				DZE_memDir = 0;
			};
		};
			if(DZE_updateVec) then{
			[_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYawBuild;
			DZE_updateVec = false;
		};
		
		if (DZE_F and _canDo) then {
		
			if (helperDetach) then {
				_objectHelper attachTo [player];
				DZE_memDir = DZE_memDir-(getDir player);
				helperDetach = false;
				[_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYawBuild;
			} else {		
				_objectHelperPos = getPosATL _objectHelper;
				detach _objectHelper;			
				DZE_memDir = getDir _objectHelper;
				[_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYawBuild;
				_objectHelper setPosATL _objectHelperPos;
				_objectHelper setVelocity [0,0,0]; //fix sliding glitch
				helperDetach = true;
			};
			DZE_F = false;
		};

		if(_rotate) then {
			[_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYawBuild;
		};

		if(_zheightchanged) then {
			if (!helperDetach) then {
			detach _objectHelper;
			};

			_position = getPosATL _objectHelper;

			if(_zheightdirection == "up") then {
				_position set [2,((_position select 2)+0.1)];
				_objHDiff = _objHDiff + 0.1;
			};
			if(_zheightdirection == "down") then {
				_position set [2,((_position select 2)-0.1)];
				_objHDiff = _objHDiff - 0.1;
			};

			if(_zheightdirection == "up_alt") then {
				_position set [2,((_position select 2)+1)];
				_objHDiff = _objHDiff + 1;
			};
			if(_zheightdirection == "down_alt") then {
				_position set [2,((_position select 2)-1)];
				_objHDiff = _objHDiff - 1;
			};

			if(_zheightdirection == "up_ctrl") then {
				_position set [2,((_position select 2)+0.01)];
				_objHDiff = _objHDiff + 0.01;
			};
			if(_zheightdirection == "down_ctrl") then {
				_position set [2,((_position select 2)-0.01)];
				_objHDiff = _objHDiff - 0.01;
			};

			_objectHelper setDir (getDir _objectHelper);

			if((_isAllowedUnderGround == 0) && ((_position select 2) < 0)) then {
				_position set [2,0];
			};

			_objectHelper setPosATL _position;

			//diag_log format["DEBUG Change BUILDING POS: %1", _position];

			if (!helperDetach) then {
			_objectHelper attachTo [player];
			};
			
			[_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYawBuild;
		};

		sleep 0.5;

		_location2 = getPosATL player;

		if(DZE_5) exitWith {
			_isOk = false;
			detach _object;
			_dir = getDir _object;
			_vector = [(vectorDir _object),(vectorUp _object)];
			_position = getPosATL _object;
			//diag_log format["DEBUG BUILDING POS: %1", _position];
			deleteVehicle _object;
			detach _objectHelper;
			deleteVehicle _objectHelper;
		};

		if(_location1 distance _location2 > 10) exitWith {
			_isOk = false;
			_cancel = true;
			_reason = "You've moved to far away from where you started building (within 10 meters)";
			detach _object;
			deleteVehicle _object;
			detach _objectHelper;
			deleteVehicle _objectHelper;
		};
		
		if(_IsNearPlot == 0 && !_isPole) then {
			_findNearestPoles = nearestObjects [_objectHelper, ["Plastic_Pole_EP1_DZ"], 30];
			_nearestPole = _findNearestPoles select 0;
			_objectHelperPos = getPosATL _objectHelper;
			if (_objectHelperPos distance _nearestPole < 30) exitWith {
				_isOk = false; 
				_cancel = true;
				_reason = "You cannot enter plot pole area while building is in progress";
				detach _object;
				deleteVehicle _object;
				detach _objectHelper;
				deleteVehicle _objectHelper;
			};
		};
			
		
		if(_location1 distance _objectHelperPos > 10) exitWith {
			_isOk = false;
			_cancel = true;
			_reason = "Object is placed to far away from where you started building (within 10 meters)";
			detach _object;
			deleteVehicle _object;
			detach _objectHelper;
			deleteVehicle _objectHelper;
		};

		if(abs(_objHDiff) > 10) exitWith {
			_isOk = false;
			_cancel = true;
			_reason = "Cannot move up || down more than 10 meters";
			detach _object;
			deleteVehicle _object;
			detach _objectHelper;
			deleteVehicle _objectHelper;
		};

		if (player getVariable["combattimeout", 0] >= time) exitWith {
			_isOk = false;
			_cancel = true;
			_reason = (localize "str_epoch_player_43");
			detach _object;
			deleteVehicle _object;
			detach _objectHelper;
			deleteVehicle _objectHelper;
		};

		if (DZE_cancelBuilding) exitWith {
			_isOk = false;
			_cancel = true;
			_reason = "Cancelled building.";
			detach _object;
			deleteVehicle _object;
			detach _objectHelper;
			deleteVehicle _objectHelper;
		};
	};
		if !(_classname in DZE_noRotate) then{
		player removeAction s_player_setVectorsReset;
		player removeAction s_player_setVectorsForward;
		player removeAction s_player_setVectorsBack;
		player removeAction s_player_setVectorsLeft;
		player removeAction s_player_setVectorsRight;
		player removeAction s_player_setVectors1;
		player removeAction s_player_setVectors5;
		player removeAction s_player_setVectors45;
		player removeAction s_player_setVectors90;
	};

	//No building on roads unless toggled
	if (!DZE_BuildOnRoads) then {
		if (isOnRoad _position) then { _cancel = true; _reason = "Cannot build on a road."; };
	};

	// No building in trader zones
	if(!canbuild) then { _cancel = true; _reason = "Cannot build in a city."; };

	if(!_cancel) then {

		_classname = _classnametmp;

		// Start Build
		_tmpbuilt = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"];

		_tmpbuilt setdir _dir;

		// Get position based on object
		_location = _position;

		if((_isAllowedUnderGround == 0) && ((_location select 2) < 0)) then {
			_location set [2,0];
		};

		_tmpbuilt setVectorDirAndUp _vector;
		_tmpbuilt setPosATL _location;


		cutText [format[(localize "str_epoch_player_138"),_text], "PLAIN DOWN"];

		_limit = 3;

		if (DZE_StaticConstructionCount > 0) then {
			_limit = DZE_StaticConstructionCount;
		} else {
			if (isNumber (configFile >> "CfgVehicles" >> _classname >> "constructioncount")) then {
				_limit = getNumber(configFile >> "CfgVehicles" >> _classname >> "constructioncount");
			};
		};

		_isOk = true;
		_proceed = false;
		_counter = 0;
		
		while {_isOk && !_isBuildAdmin} do {

			[10,10] call dayz_HungerThirst;
			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 || (player getVariable["combattimeout", 0] >= time)) then {
					r_doLoop = false;
				};
				if (DZE_cancelBuilding) exitWith {
					r_doLoop = false;
				};
				sleep 0.1;
			};
			r_doLoop = false;


			if(!_finished) exitWith {
				_isOk = false;
				_proceed = false;
			};

			if(_finished) then {
				_counter = _counter + 1;
			};

			cutText [format[(localize "str_epoch_player_139"),_text, _counter,_limit], "PLAIN DOWN"];

			if(_counter == _limit) exitWith {
				_isOk = false;
				_proceed = true;
			};
		};
		if (_isBuildAdmin) then {
			_isOk = false;
			_proceed = true;
		};

		if (_proceed) then {
		//diag_log "Proceed OK";
			_tobe_removed_total = 0;
			_removed_total = 0;
			_temp_removed_array = [];
			if (!_isBuildAdmin) then {
				//diag_log "Is Admin REMOVE NOT OK";
				if (_typeIsString) then {
					_tobe_removed_total = ([player,_item] call BIS_fnc_invRemove);
					_removed_total = _tobe_removed_total;
				};
				if (!_typeIsString) then {
					{
						_removed = 0;
						_itemIn = _x select 0;
						_countIn = _x select 1;
						// //diag_log format["Recipe Finish: %1 %2", _itemIn,_countIn];
						_tobe_removed_total = _tobe_removed_total + _countIn;
			
						{					
							if( (_removed < _countIn) && ((_x == _itemIn) || configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn)) then {
							_num_removed = ([player,_x] call BIS_fnc_invRemove);
								_removed = _removed + _num_removed;
								_removed_total = _removed_total + _num_removed;
								if(_num_removed == 1) then {
									_temp_removed_array set [count _temp_removed_array,_x];
								};
							};
						} forEach magazines player;
					} forEach _needBuildItem;
				};
			} else {
				//diag_log "Is Admin REMOVE OK";
				_tobe_removed_total = 1;
				_removed_total = 1;
			};
			if((_tobe_removed_total == _removed_total) && (_removed_total >= 1)) then {
				//diag_log "Removed Item OK";
				cutText [format[localize "str_build_01",_text], "PLAIN DOWN"];

				if (_isPole) then {
					[] spawn player_plotPreview;
				};

				_tmpbuilt setVariable ["OEMPos",_location,true];

				if(_lockable > 1) then {
					//diag_log "Is Lockable OK";
					_combinationDisplay = "";

					switch (_lockable) do {

						case 2: { // 2 lockbox
							_combination_1 = (floor(random 3)) + 100; // 100=red,101=green,102=blue
							_combination_2 = floor(random 10);
							_combination_3 = floor(random 10);
							_combination = format["%1%2%3",_combination_1,_combination_2,_combination_3];
							dayz_combination = _combination;
							if (_combination_1 == 100) then {
								_combination_1_Display = "Red";
							};
							if (_combination_1 == 101) then {
								_combination_1_Display = "Green";
							};
							if (_combination_1 == 102) then {
								_combination_1_Display = "Blue";
							};
							_combinationDisplay = format["%1%2%3",_combination_1_Display,_combination_2,_combination_3];
						};

						case 3: { // 3 combolock
							_combination_1 = floor(random 10);
							_combination_2 = floor(random 10);
							_combination_3 = floor(random 10);
							_combination = format["%1%2%3",_combination_1,_combination_2,_combination_3];
							dayz_combination = _combination;
							_combinationDisplay = _combination;
						};

						case 4: { // 4 safe
							_combination_1 = floor(random 10);
							_combination_2 = floor(random 10);
							_combination_3 = floor(random 10);
							_combination_4 = floor(random 10);
							_combination = format["%1%2%3%4",_combination_1,_combination_2,_combination_3,_combination_4];
							dayz_combination = _combination;
							_combinationDisplay = _combination;
						};
					};

					_tmpbuilt setVariable ["CharacterID",_combination,true];
					_tmpbuilt setVariable ["ownerPUID",_playerUID,true];


					PVDZE_obj_Publish = [_combination,_tmpbuilt,[_dir,_location,_playerUID],_classname];
					//diag_log "Publish Lockable";
					publicVariableServer "PVDZE_obj_Publish";

					cutText [format[(localize "str_epoch_player_140"),_combinationDisplay,_text], "PLAIN DOWN", 5];


				} else {
					_tmpbuilt setVariable ["CharacterID",dayz_characterID,true];
					_tmpbuilt setVariable ["ownerPUID",_playerUID,true];
					
					// fire?
					if(_tmpbuilt isKindOf "Land_Fire_DZ") then {
						_tmpbuilt spawn player_fireMonitor;
					} else {
						//diag_log "Publish Other";
						PVDZE_obj_Publish = [dayz_characterID,_tmpbuilt,[_dir,_location,_playerUID],_classname];
						publicVariableServer "PVDZE_obj_Publish";
					};
				};
			} else {
				//diag_log "Remove Item NOT OK";
				deleteVehicle _tmpbuilt;
				cutText [(localize "str_epoch_player_46") , "PLAIN DOWN"];
				{
					[player,_x] call BIS_fnc_invAdd;
				} forEach _temp_removed_array;				
			};

		} else {
			//diag_log "Proceed NOT OK";
			r_interrupt = false;
			if (vehicle player == player) then {
				[objNull, player, rSwitchMove,""] call RE;
				player playActionNow "stop";
			};

			deleteVehicle _tmpbuilt;

			cutText [(localize "str_epoch_player_46") , "PLAIN DOWN"];
		};

	} else {
		//diag_log "Cancel is TRUE";
		deleteVehicle _tmpbuilt;
		cutText [format[(localize "str_epoch_player_47"),_text,_reason], "PLAIN DOWN"];
	};
};

DZE_ActionInProgress = false; 

 

player_upgrade.sqf (working fine) 

/*
	DayZ Base Building Upgrades
	Made for DayZ Epoch please ask permission to use/edit/distrubute email [email protected].
*/
private ["_location","_dir","_classname","_missing","_text","_proceed","_num_removed","_object","_missingQty","_itemIn","_countIn","_qty","_removed","_removed_total","_tobe_removed_total","_objectID","_objectUID","_temp_removed_array","_textMissing","_newclassname","_requirements","_obj","_upgrade","_lockable","_combination_1","_combination_2","_combination_3","_combination","_objectCharacterID","_canBuildOnPlot","_friendlies","_nearestPole","_ownerID","_distance","_needText","_findNearestPoles","_findNearestPole","_IsNearPlot","_isBuildAdmin"];

if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_52") , "PLAIN DOWN"]; };
DZE_ActionInProgress = true;

player removeAction s_player_upgrade_build;
s_player_upgrade_build = 1;


_distance = 30;
_needText = localize "str_epoch_player_246";

// check for near plot
_findNearestPoles = nearestObjects [(vehicle player), ["Plastic_Pole_EP1_DZ"], _distance];
_findNearestPole = [];
_isBuildAdmin = (getPlayerUID player) in WG_adminBuild;

{
	if (alive _x) then {
		_findNearestPole set [(count _findNearestPole),_x];
	};
} count _findNearestPoles;

_IsNearPlot = count (_findNearestPole);

_canBuildOnPlot = false;

if(_IsNearPlot == 0) then {
	_canBuildOnPlot = true;
} else {
	
	// check nearby plots ownership && then for friend status
	_nearestPole = _findNearestPole select 0;

	// Find owner 
	_ownerID = _nearestPole getVariable["ownerPUID","0"];
	_playerUID = getPlayerUID player;

	// diag_log format["DEBUG BUILDING: %1 = %2", dayz_characterID, _ownerID];

	// check if friendly to owner
	if(_playerUID == _ownerID) then {
		_canBuildOnPlot = true;		
	} else {
		_friendlies		= player getVariable ["friendlyTo",[]];
		// check if friendly to owner
		if(_ownerID in _friendlies) then {
			_canBuildOnPlot = true;
		};
	};
};

// exit if not allowed due to plot pole
if(!_canBuildOnPlot) exitWith {  DZE_ActionInProgress = false; cutText [format[(localize "str_epoch_player_157"),_needText,_distance] , "PLAIN DOWN"]; };

// get cursortarget from addaction
_obj = _this select 3;

// Find objectID
_objectID 	= _obj getVariable ["ObjectID","0"];

// Find objectUID
_objectUID	= _obj getVariable ["ObjectUID","0"];

if(_objectID == "0" && _objectUID == "0") exitWith {DZE_ActionInProgress = false; s_player_upgrade_build = -1; cutText [(localize "str_epoch_player_50"), "PLAIN DOWN"];};

// Get classname
_classname = typeOf _obj;

// Find display name
_text = getText (configFile >> "CfgVehicles" >> _classname >> "displayName");

// Find next upgrade
_upgrade = getArray (configFile >> "CfgVehicles" >> _classname >> "upgradeBuilding");

if ((count _upgrade) > 0) then {

	_newclassname = _upgrade select 0;

	_lockable = 0;
	if(isNumber (configFile >> "CfgVehicles" >> _newclassname >> "lockable")) then {
		_lockable = getNumber(configFile >> "CfgVehicles" >> _newclassname >> "lockable");
	};

	_requirements = _upgrade select 1;
	
	_missingQty = 0;
	_missing = "";
	
	_proceed = true;
	if (!_isBuildAdmin) then {
	{
		_itemIn = _x select 0;
		_countIn = _x select 1;
		_qty = { (_x == _itemIn) || (configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn) } count magazines player;
		if(_qty < _countIn) exitWith { _missing = _itemIn; _missingQty = (_countIn - _qty); _proceed = false; };
	} forEach _requirements;
	};
	
	if (_proceed) then {
		if (!_isBuildAdmin) then {
			[1,1] call dayz_HungerThirst;
			player playActionNow "Medic";
			[player,20,true,(getPosATL player)] spawn player_alertZombies;
		};
		_temp_removed_array = [];
		_removed_total = 0;
		_tobe_removed_total = 0;
		
		if (!_isBuildAdmin) then {		
			{
			_removed = 0;
			_itemIn = _x select 0;
			_countIn = _x select 1;
			// diag_log format["Recipe Finish: %1 %2", _itemIn,_countIn];
			_tobe_removed_total = _tobe_removed_total + _countIn;

			{					
				if( (_removed < _countIn) && ((_x == _itemIn) || configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn)) then {
					_num_removed = ([player,_x] call BIS_fnc_invRemove);
					_removed = _removed + _num_removed;
					_removed_total = _removed_total + _num_removed;
					if(_num_removed >= 1) then {
						_temp_removed_array set [count _temp_removed_array,_x];
					};
				};
		
			} forEach magazines player;

		} forEach _requirements;
		};

		// all parts removed proceed
		if (_tobe_removed_total == _removed_total) then {
			
			// Get position
			_location	= _obj getVariable["OEMPos",(getposATL _obj)];

			// Get direction
			_dir = getDir _obj;

			// Get Vector
			_vector = [(vectorDir _obj),(vectorUp _obj)];
			
			// Current charID
			_objectCharacterID 	= _obj getVariable ["CharacterID","0"];
			_ownerID = _obj getVariable["ownerPUID","0"];

			_classname = _newclassname;
			
			// Create new object 
			_object = createVehicle [_classname, [0,0,0], [], 0, "CAN_COLLIDE"];

			// Set direction
			_object setDir _dir;
			
			// Set vector
			_object setVectorDirAndUp _vector;
			
			// Set location
			_object setPosATL _location;

			// Set Owner.
			_object setVariable ["ownerPUID",_ownerID,true];
			
			if (_lockable == 3) then {

				_combination_1 = floor(random 10);
				_combination_2 = floor(random 10);
				_combination_3 = floor(random 10);
				_combination = format["%1%2%3",_combination_1,_combination_2,_combination_3];
				
				_objectCharacterID = _combination;
				
				cutText [format[(localize "str_epoch_player_158"),_combination,_text], "PLAIN DOWN", 5];
			} else {	
				cutText [format[(localize "str_epoch_player_159"),_text], "PLAIN DOWN", 5];
			};

			PVDZE_obj_Swap = [_objectCharacterID,_object,[_dir,_location, _ownerID, _vector],_classname,_obj,player];
			publicVariableServer "PVDZE_obj_Swap";

			player reveal _object;
			
		} else {
		
			{player addMagazine _x;} count _temp_removed_array;
			cutText [format[(localize "str_epoch_player_145"),_removed_total,_tobe_removed_total], "PLAIN DOWN"];
		
		};
	} else {
		_textMissing = getText(configFile >> "CfgMagazines" >> _missing >> "displayName");
		cutText [format[(localize "str_epoch_player_146"),_missingQty, _textMissing], "PLAIN DOWN"];
	};

} else {
	cutText [(localize "str_epoch_player_82"), "PLAIN DOWN"];
};

DZE_ActionInProgress = false;
s_player_upgrade_build = -1; 

 

 

this works with all my right click extra buildables, geeks admin build, p4l, vectors, and snap pro

 

Now, for me i've got this working pretty much fine. i've just noticed that metal floors don't like to be saved with vectors. they reset to being flat on restart. 

is this a common issue? or is this due to the changes ive made to get things working with my customised files?

 

everything else i've built on my test server is fine. and saves correctly. 

the worldspace doesn't appear to be getting updated in my sql db for floors like it is with everything else

 

example below: 

ObjectUID;Instance;Classname;Datestamp;LastUpdated;CharacterID;Worldspace;Inventory;Hitpoints;Fuel;Damage
1985044584080;11;CinderWall_DZ;2014-08-09 13:17:07;2014-08-09 13:17:07;660;[353.354,[1984.97,4458.41,0.039],"76561198035522330",[[-0.116,0.993,0],[-0.702,-0.082,0.707]]];[];[];0.00000;0.00000

ObjectUID;Instance;Classname;Datestamp;LastUpdated;CharacterID;Worldspace;Inventory;Hitpoints;Fuel;Damage
19830445542983;11;MetalFloor_DZ;2014-08-09 13:20:41;2014-08-09 13:20:41;660;[83.337,[1983.03,4455.39,2.86],"76561198035522330"];[];[];0.00000;0.00000

edit* im just going through my player_build.sqf again and have noticed some of my PVDZE_obj_Publish = lines have omitted the _vector part.  i'll re-add and see how it goes 

edit2* i updated player_build.sqf to include the _vector lines... lo and behold it all works. it was me who stuffed up (no surprises there haha) 

 

updated player_build.sqf  (working with vectors, snap-pro, plot 4 life, geeks admin build + extra right click buildables)

this one functions properly. it is based off prymary's

/*
	DayZ Base Building
	Made for DayZ Epoch please ask permission to use/edit/distrubute email [email protected].
*/
private ["_helperColor","_objectHelper","_objectHelperDir","_objectHelperPos","_canDo",
"_location","_dir","_classname","_item","_hasRequiredTools","_missingT","_missingB","_hasrequireditem","_missing","_hastoolweapon","_cancel","_reason","_started","_finished","_animState","_isMedic","_dis","_sfx","_hasbuilditem","_tmpbuilt","_onLadder","_isWater","_require","_text","_offset","_IsNearPlot","_isOk","_location1","_location2","_counter","_limit","_proceed","_num_removed","_position","_object","_canBuildOnPlot","_friendlies","_nearestPole","_ownerID","_findNearestPoles","_findNearestPole","_distance","_classnametmp","_ghost","_isPole","_needText","_lockable","_zheightchanged","_rotate","_combination_1","_combination_2","_combination_3","_combination_4","_combination","_combination_1_Display","_combinationDisplay","_zheightdirection","_abort","_isNear","_need","_needNear","_vehicle","_inVehicle","_previewCounter","_requireplot","_objHupDiff","_objHDiff","_isLandFireDZ","_isTankTrap","_isNear2","_typeIsString","_isBuildAdmin","_needBuildItem","_hasbuilditems","_itemIn","_countIn","_qty","_missingQty","_textMissing","_removed","_tobe_removed_total","_removed_total","_ownerPUID", "_playerUID"];

DZE_BuildVector = [[0,0,0],[0,0,0]];

if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_40") , "PLAIN DOWN"]; };
DZE_ActionInProgress = true;

// disallow building if too many objects are found within 30m
if((count ((getPosATL player) nearObjects ["All",30])) >= DZE_BuildingLimit) exitWith {DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_41"), "PLAIN DOWN"];};

_onLadder =		(getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
_isWater = 		dayz_isSwimming;
_cancel = false;
_reason = "";
_canBuildOnPlot = false;
_isBuildAdmin = (getPlayerUID player) in WG_adminBuild;

_vehicle = vehicle player;
_inVehicle = (_vehicle != player);

_playerUID = getPlayerUID player;
//snap
helperDetach = false;
_canDo = (!r_drag_sqf and !r_player_unconscious);

_vector = [];

fnc_SetPitchBankYawBuild = { 
    private ["_object","_rotations","_aroundX","_aroundY","_aroundZ","_dirX","_dirY","_dirZ","_upX","_upY","_upZ","_dir","_up","_dirXTemp",
    "_upXTemp"];
    _object = _this select 0; 
    _rotations = _this select 1; 
    _aroundX = _rotations select 0; 
    _aroundY = _rotations select 1; 
    _aroundZ = (360 - (_rotations select 2)) - 360; 
    _dirX = 0; 
    _dirY = 1; 
    _dirZ = 0; 
    _upX = 0; 
    _upY = 0; 
    _upZ = 1; 
    if (_aroundX != 0) then { 
        _dirY = cos _aroundX; 
        _dirZ = sin _aroundX; 
        _upY = -sin _aroundX; 
        _upZ = cos _aroundX; 
    }; 
    if (_aroundY != 0) then { 
        _dirX = _dirZ * sin _aroundY; 
        _dirZ = _dirZ * cos _aroundY; 
        _upX = _upZ * sin _aroundY; 
        _upZ = _upZ * cos _aroundY; 
    }; 
    if (_aroundZ != 0) then { 
        _dirXTemp = _dirX; 
        _dirX = (_dirXTemp* cos _aroundZ) - (_dirY * sin _aroundZ); 
        _dirY = (_dirY * cos _aroundZ) + (_dirXTemp * sin _aroundZ);        
        _upXTemp = _upX; 
        _upX = (_upXTemp * cos _aroundZ) - (_upY * sin _aroundZ); 
        _upY = (_upY * cos _aroundZ) + (_upXTemp * sin _aroundZ); 		
    }; 
    _dir = [_dirX,_dirY,_dirZ]; 
    _up = [_upX,_upY,_upZ]; 
    _object setVectorDirAndUp [_dir,_up];
	DZE_BuildVector = [_dir,_up];
}; 

DZE_Q = false;
DZE_Z = false;

DZE_Q_alt = false;
DZE_Z_alt = false;

DZE_Q_ctrl = false;
DZE_Z_ctrl = false;

DZE_5 = false;
DZE_4 = false;
DZE_6 = false;
DZE_F = false;

DZE_cancelBuilding = false;

call gear_ui_init;
closeDialog 1;

if (_isWater) exitWith {DZE_ActionInProgress = false; cutText [localize "str_player_26", "PLAIN DOWN"];};
if (_inVehicle) exitWith {DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_42"), "PLAIN DOWN"];};
if (_onLadder) exitWith {DZE_ActionInProgress = false; cutText [localize "str_player_21", "PLAIN DOWN"];};
if (player getVariable["combattimeout", 0] >= time) exitWith {DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_43"), "PLAIN DOWN"];};

_typeIsString = ((typeName _this) == "STRING");
//diag_log format["Type is STRING: %1",_typeIsString];
if (_typeIsString) then {
	_item =	_this;
};
if (!_typeIsString) then {
	_item =	_this select 0;
};

// Need Near Requirements
_abort = false;
_distance = 10;
_reason = "";

if (_typeIsString) then {
	_needNear = 	getArray (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "neednearby");

	{
		switch(_x) do{
			case "fire":
			{
				_distance = 3;
				_isNear = {inflamed _x} count (getPosATL player nearObjects _distance);
				if(_isNear == 0) then {
					_abort = true;
					_reason = "fire";
				};
			};
			case "workshop":
			{
				_distance = 3;
				_isNear = count (nearestObjects [player, ["Wooden_shed_DZ","WoodShack_DZ","WorkBench_DZ"], _distance]);
				if(_isNear == 0) then {
					_abort = true;
					_reason = "workshop";
				};
			};
			case "fueltank":
			{
				_distance = 30;
				_isNear = count (nearestObjects [player, dayz_fuelsources, _distance]);
				if(_isNear == 0) then {
					_abort = true;
					_reason = "fuel tank";
				};
			};
		};
	} forEach _needNear;


	if(_abort) exitWith {
		cutText [format[(localize "str_epoch_player_135"),_reason,_distance], "PLAIN DOWN"];
		DZE_ActionInProgress = false;
	};
};

if (_typeIsString) then {
	_classname = 	getText (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "create");
	_classnametmp = _classname;
	_require =  getArray (configFile >> "cfgMagazines" >> _this >> "ItemActions" >> "Build" >> "require");
};
if (!_typeIsString) then {
	_classname = _this select 0;
	_classnametmp = _classname;
	_require = _this select 1;
};
_text = 		getText (configFile >> "CfgVehicles" >> _classname >> "displayName");
_ghost = getText (configFile >> "CfgVehicles" >> _classname >> "ghostpreview");

_lockable = 0;
if(isNumber (configFile >> "CfgVehicles" >> _classname >> "lockable")) then {
	_lockable = getNumber(configFile >> "CfgVehicles" >> _classname >> "lockable");
};

_requireplot = DZE_requireplot;
if(isNumber (configFile >> "CfgVehicles" >> _classname >> "requireplot")) then {
	_requireplot = getNumber(configFile >> "CfgVehicles" >> _classname >> "requireplot");
};

_isAllowedUnderGround = 1;
if(isNumber (configFile >> "CfgVehicles" >> _classname >> "nounderground")) then {
	_isAllowedUnderGround = getNumber(configFile >> "CfgVehicles" >> _classname >> "nounderground");
};


if (!_typeIsString) then {
	_offset = _this select 3;
};
if (_typeIsString) then {
	_offset = 	getArray (configFile >> "CfgVehicles" >> _classname >> "offset");
	if((count _offset) <= 0) then {
		_offset = [0,1.5,0];
	};
};

_isPole = (_classname == "Plastic_Pole_EP1_DZ");
_isLandFireDZ = (_classname == "Land_Fire_DZ");

_distance = DZE_PlotPole select 0;
_needText = localize "str_epoch_player_246";

if(_isPole) then {
	_distance = DZE_PlotPole select 1;
};

// check for near plot
_findNearestPoles = nearestObjects [(vehicle player), ["Plastic_Pole_EP1_DZ"], _distance];
_findNearestPole = [];

{
	if (alive _x) then {
		_findNearestPole set [(count _findNearestPole),_x];
	};
} count _findNearestPoles;

_IsNearPlot = count (_findNearestPole);

// If item is plot pole && another one exists within 45m
if(_isPole && _IsNearPlot > 0) exitWith {  DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_44") , "PLAIN DOWN"]; };

if(_IsNearPlot == 0) then {

	// Allow building of plot
	if(_requireplot == 0 || _isLandFireDZ) then {
		_canBuildOnPlot = true;
	};

} else {
	// Since there are plots nearby we check for ownership && then for friend status

	// check nearby plots ownership && then for friend status
	_nearestPole = _findNearestPole select 0;

	// Find owner
	_ownerID = _nearestPole getVariable ["ownerPUID","0"];

	 // //diag_log format["Player_build start: [PlayerUID = %1]  [OwnerID = %2]", _playerUID, _ownerID];

	// check if friendly to owner
	if(_playerUID == _ownerID) then {  //Keep ownership
		// owner can build anything within his plot except other plots
		if(!_isPole) then {
			_canBuildOnPlot = true;		
		};
	} else {
		// disallow building plot
		if(!_isPole) then {
			_friendlies		= player getVariable ["friendlyTo",[]];
			// check if friendly to owner
			if(_ownerID in _friendlies) then {
				_canBuildOnPlot = true;
			};
		};
	};
};

// _message
if(!_canBuildOnPlot) exitWith {  DZE_ActionInProgress = false; cutText [format[(localize "STR_EPOCH_PLAYER_135"),_needText,_distance] , "PLAIN DOWN"]; };

_missingT = "";
_missingB = "";
_hasRequiredTools = true;
_hasbuilditem = true;
if (!_isBuildAdmin) then {
	{
		//diag_log format["Testing for tool: %1",_x];
		_hastoolweapon = _x in weapons player;
		if(!_hastoolweapon) exitWith {_hasRequiredTools = false; _missingT = getText (configFile >> "cfgWeapons" >> _x >> "displayName");};
	} forEach _require;

	if (!_typeIsString && _hasRequiredTools) then {
		_needBuildItem = _this select 2;
		{
			_itemIn = _x select 0;
			_countIn = _x select 1;
			_qty = { (_x == _itemIn) || (configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn) } count magazines player;
			if(_qty < _countIn) exitWith { _missingB = getText(configFile >> "CfgMagazines" >> _itemIn >> "displayName"); _missingQty = (_countIn - _qty); _hasbuilditem = false;};
		} forEach _needBuildItem;
	};
	
	if (_typeIsString && _hasRequiredTools) then {
		_hasbuilditem = _this in magazines player;
	};
};
// Message If missing
if (!_hasRequiredTools) exitWith {DZE_ActionInProgress = false; cutText [format[(localize "str_epoch_player_137"),_missingT] , "PLAIN DOWN"];};

if (!_typeIsString && !_hasbuilditem) exitWith {DZE_ActionInProgress = false; cutText [format[(localize "str_epoch_player_146"),_missingQty, _missingB], "PLAIN DOWN"];};
if (_typeIsString && !_hasbuilditem) exitWith {DZE_ActionInProgress = false; cutText [format[(localize "str_player_31"),_text,"build"] , "PLAIN DOWN"]; };


//Proceed after item check
if (_hasRequiredTools && _hasbuilditem) then {

	_location = [0,0,0];
	_isOk = true;

	// get inital players position
	_location1 = getPosATL player;
	_dir = getDir player;

	// if ghost preview available use that instead
	/*if (_ghost != "") then {
		_classname = _ghost;
	};*/

	_object = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"];
	_object setDir 0;
	//Build gizmo
	_objectHelper = "Sign_sphere10cm_EP1" createVehicle _location;
	_helperColor = "#(argb,8,8,3)color(0,0,0,0,ca)";
	_objectHelper setobjecttexture [0,_helperColor];
	_objectHelper attachTo [player,_offset];
	_object attachTo [_objectHelper,[0,0,0]];
	_position = getPosATL _objectHelper;
	
	//cutText [(localize "str_epoch_player_45"), "PLAIN DOWN"];

	_objHDiff = 0;

	if (isClass (missionConfigFile >> "SnapBuilding" >> _classname)) then {	
		["","","",["Init",_object,_classname,_objectHelper]] spawn snap_build;
	};

	DZE_updateVec = false;
	DZE_memDir = getDir _objectHelper;
	DZE_memForBack = 0;
	DZE_memLeftRight = 0;
	if !(_classname in DZE_noRotate) then{
		s_player_setVectorsReset = player addaction ["Reset","custom\snap_pro\player_vectorChange.sqf","reset"];
		s_player_setVectorsForward = player addaction ["Pitch Forward","custom\snap_pro\player_vectorChange.sqf","forward"];
		s_player_setVectorsBack = player addaction ["Pitch Back","custom\snap_pro\player_vectorChange.sqf","back"];
		s_player_setVectorsLeft = player addaction ["Bank Left","custom\snap_pro\player_vectorChange.sqf","left"];
		s_player_setVectorsRight = player addaction ["Bank Right","custom\snap_pro\player_vectorChange.sqf","right"];
		s_player_setVectors1 = player addaction ["Increment by 1 degree","custom\snap_pro\player_vectorChange.sqf","1"];
		s_player_setVectors5 = player addaction ["Increment by 5 degrees","custom\snap_pro\player_vectorChange.sqf","5"];
		s_player_setVectors45 = player addaction ["Increment by 45 degrees","custom\snap_pro\player_vectorChange.sqf","45"];
		s_player_setVectors90 = player addaction ["Increment by 90 degrees","custom\snap_pro\player_vectorChange.sqf","90"];
	};
	
	while {_isOk} do {

		_zheightchanged = false;
		_zheightdirection = "";
		_rotate = false;

		if (DZE_Q) then {
			DZE_Q = false;
			_zheightdirection = "up";
			_zheightchanged = true;
		};
		if (DZE_Z) then {
			DZE_Z = false;
			_zheightdirection = "down";
			_zheightchanged = true;
		};
		if (DZE_Q_alt) then {
			DZE_Q_alt = false;
			_zheightdirection = "up_alt";
			_zheightchanged = true;
		};
		if (DZE_Z_alt) then {
			DZE_Z_alt = false;
			_zheightdirection = "down_alt";
			_zheightchanged = true;
		};
		if (DZE_Q_ctrl) then {
			DZE_Q_ctrl = false;
			_zheightdirection = "up_ctrl";
			_zheightchanged = true;
		};
		if (DZE_Z_ctrl) then {
			DZE_Z_ctrl = false;
			_zheightdirection = "down_ctrl";
			_zheightchanged = true;
		};
		if (DZE_4) then {
			_rotate = true;
			DZE_4 = false;
			if (helperDetach) then {
				_dir = -45;
				DZE_memDir = DZE_memDir - 45;
			} else {
				_dir = 180;
				DZE_memDir = 180;
			};
		};
		if (DZE_6) then {
			_rotate = true;
			DZE_6 = false;
			if (helperDetach) then {
				_dir = 45;
				DZE_memDir = DZE_memDir + 45;
			} else {
				_dir = 0;
				DZE_memDir = 0;
			};
		};
		
		if(DZE_updateVec) then{
			[_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYawBuild;
			DZE_updateVec = false;
		};
		
		if (DZE_F and _canDo) then {
		
			if (helperDetach) then {
				_objectHelper attachTo [player];
				DZE_memDir = DZE_memDir-(getDir player);
				helperDetach = false;
				[_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYawBuild;
			} else {		
				_objectHelperPos = getPosATL _objectHelper;
				detach _objectHelper;			
				DZE_memDir = getDir _objectHelper;
				[_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYawBuild;
				_objectHelper setPosATL _objectHelperPos;
				_objectHelper setVelocity [0,0,0]; //fix sliding glitch
				helperDetach = true;
			};
			DZE_F = false;
		};

		if(_rotate) then {
			[_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYawBuild;
		};

		if(_zheightchanged) then {
			if (!helperDetach) then {
			detach _objectHelper;
			};

			_position = getPosATL _objectHelper;

			if(_zheightdirection == "up") then {
				_position set [2,((_position select 2)+0.1)];
				_objHDiff = _objHDiff + 0.1;
			};
			if(_zheightdirection == "down") then {
				_position set [2,((_position select 2)-0.1)];
				_objHDiff = _objHDiff - 0.1;
			};

			if(_zheightdirection == "up_alt") then {
				_position set [2,((_position select 2)+1)];
				_objHDiff = _objHDiff + 1;
			};
			if(_zheightdirection == "down_alt") then {
				_position set [2,((_position select 2)-1)];
				_objHDiff = _objHDiff - 1;
			};

			if(_zheightdirection == "up_ctrl") then {
				_position set [2,((_position select 2)+0.01)];
				_objHDiff = _objHDiff + 0.01;
			};
			if(_zheightdirection == "down_ctrl") then {
				_position set [2,((_position select 2)-0.01)];
				_objHDiff = _objHDiff - 0.01;
			};

			_objectHelper setDir (getDir _objectHelper);

			if((_isAllowedUnderGround == 0) && ((_position select 2) < 0)) then {
				_position set [2,0];
			};

			_objectHelper setPosATL _position;

			//diag_log format["DEBUG Change BUILDING POS: %1", _position];

			if (!helperDetach) then {
				_objectHelper attachTo [player];
			};
			
			[_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYawBuild;
		};

		sleep 0.5;

		_location2 = getPosATL player;

		if(DZE_5) exitWith {
			_isOk = false;
			detach _object;		
			_dir = getDir _object;
			_vector = [(vectorDir _object),(vectorUp _object)];
			_position = getPosATL _object;
			//diag_log format["DEBUG BUILDING POS: %1", _position];
			deleteVehicle _object;
			detach _objectHelper;
			deleteVehicle _objectHelper;
		};

		if(_location1 distance _location2 > 10) exitWith {
			_isOk = false;
			_cancel = true;
			_reason = "You've moved to far away from where you started building (within 10 meters)";
			detach _object;
			deleteVehicle _object;
			detach _objectHelper;
			deleteVehicle _objectHelper;
		};
		
		if(_IsNearPlot == 0 && !_isPole) then {
			_findNearestPoles = nearestObjects [_objectHelper, ["Plastic_Pole_EP1_DZ"], 30];
			_nearestPole = _findNearestPoles select 0;
			_objectHelperPos = getPosATL _objectHelper;
			if (_objectHelperPos distance _nearestPole < 30) exitWith {
				_isOk = false; 
				_cancel = true;
				_reason = "You cannot enter plot pole area while building is in progress";
				detach _object;
				deleteVehicle _object;
				detach _objectHelper;
				deleteVehicle _objectHelper;
			};
		};
			
		
		if(_location1 distance _objectHelperPos > 10) exitWith {
			_isOk = false;
			_cancel = true;
			_reason = "Object is placed to far away from where you started building (within 10 meters)";
			detach _object;
			deleteVehicle _object;
			detach _objectHelper;
			deleteVehicle _objectHelper;
		};

		if(abs(_objHDiff) > 10) exitWith {
			_isOk = false;
			_cancel = true;
			_reason = "Cannot move up || down more than 10 meters";
			detach _object;
			deleteVehicle _object;
			detach _objectHelper;
			deleteVehicle _objectHelper;
		};

		if (player getVariable["combattimeout", 0] >= time) exitWith {
			_isOk = false;
			_cancel = true;
			_reason = (localize "str_epoch_player_43");
			detach _object;
			deleteVehicle _object;
			detach _objectHelper;
			deleteVehicle _objectHelper;
		};

		if (DZE_cancelBuilding) exitWith {
			_isOk = false;
			_cancel = true;
			_reason = "Cancelled building.";
			detach _object;
			deleteVehicle _object;
			detach _objectHelper;
			deleteVehicle _objectHelper;
		};
	};
	
	if !(_classname in DZE_noRotate) then{
		player removeAction s_player_setVectorsReset;
		player removeAction s_player_setVectorsForward;
		player removeAction s_player_setVectorsBack;
		player removeAction s_player_setVectorsLeft;
		player removeAction s_player_setVectorsRight;
		player removeAction s_player_setVectors1;
		player removeAction s_player_setVectors5;
		player removeAction s_player_setVectors45;
		player removeAction s_player_setVectors90;
	};

	//No building on roads unless toggled
	if (!DZE_BuildOnRoads) then {
		if (isOnRoad _position) then { _cancel = true; _reason = "Cannot build on a road."; };
	};

	// No building in trader zones
	if(!canbuild) then { _cancel = true; _reason = "Cannot build in a city."; };

	if(!_cancel) then {

		_classname = _classnametmp;

		// Start Build
		_tmpbuilt = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"];

		_tmpbuilt setdir _dir;

		// Get position based on object
		_location = _position;

		if((_isAllowedUnderGround == 0) && ((_location select 2) < 0)) then {
			_location set [2,0];
		};

		_tmpbuilt setVectorDirAndUp _vector;
		_tmpbuilt setPosATL _location;


		cutText [format[(localize "str_epoch_player_138"),_text], "PLAIN DOWN"];

		_limit = 3;

		if (DZE_StaticConstructionCount > 0) then {
			_limit = DZE_StaticConstructionCount;
		}
		else {
			if (isNumber (configFile >> "CfgVehicles" >> _classname >> "constructioncount")) then {
				_limit = getNumber(configFile >> "CfgVehicles" >> _classname >> "constructioncount");
			};
		};

		_isOk = true;
		_proceed = false;
		_counter = 0;
		
		while {_isOk && !_isBuildAdmin} do {

			[10,10] call dayz_HungerThirst;
			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 || (player getVariable["combattimeout", 0] >= time)) then {
					r_doLoop = false;
				};
				if (DZE_cancelBuilding) exitWith {
					r_doLoop = false;
				};
				sleep 0.1;
			};
			r_doLoop = false;


			if(!_finished) exitWith {
				_isOk = false;
				_proceed = false;
			};

			if(_finished) then {
				_counter = _counter + 1;
			};

			cutText [format[(localize "str_epoch_player_139"),_text, _counter,_limit], "PLAIN DOWN"];

			if(_counter == _limit) exitWith {
				_isOk = false;
				_proceed = true;
			};
		};
		if (_isBuildAdmin) then {
			_isOk = false;
			_proceed = true;
		};

		if (_proceed) then {
		//diag_log "Proceed OK";
			_tobe_removed_total = 0;
			_removed_total = 0;
			_temp_removed_array = [];
			if (!_isBuildAdmin) then {
				//diag_log "Is Admin REMOVE NOT OK";
				if (_typeIsString) then {
					_tobe_removed_total = ([player,_item] call BIS_fnc_invRemove);
					_removed_total = _tobe_removed_total;
				};
				if (!_typeIsString) then {
					{
						_removed = 0;
						_itemIn = _x select 0;
						_countIn = _x select 1;
						// //diag_log format["Recipe Finish: %1 %2", _itemIn,_countIn];
						_tobe_removed_total = _tobe_removed_total + _countIn;
			
						{					
							if( (_removed < _countIn) && ((_x == _itemIn) || configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn)) then {
							_num_removed = ([player,_x] call BIS_fnc_invRemove);
								_removed = _removed + _num_removed;
								_removed_total = _removed_total + _num_removed;
								if(_num_removed == 1) then {
									_temp_removed_array set [count _temp_removed_array,_x];
								};
							};
						} forEach magazines player;
					} forEach _needBuildItem;
				};
			} else {
				//diag_log "Is Admin REMOVE OK";
				_tobe_removed_total = 1;
				_removed_total = 1;
			};
			if((_tobe_removed_total == _removed_total) && (_removed_total >= 1)) then {
				//diag_log "Removed Item OK";
				cutText [format[localize "str_build_01",_text], "PLAIN DOWN"];

				if (_isPole) then {
					[] spawn player_plotPreview;
				};

				_tmpbuilt setVariable ["OEMPos",_location,true];

				if(_lockable > 1) then {
					//diag_log "Is Lockable OK";
					_combinationDisplay = "";

					switch (_lockable) do {

						case 2: { // 2 lockbox
							_combination_1 = (floor(random 3)) + 100; // 100=red,101=green,102=blue
							_combination_2 = floor(random 10);
							_combination_3 = floor(random 10);
							_combination = format["%1%2%3",_combination_1,_combination_2,_combination_3];
							dayz_combination = _combination;
							if (_combination_1 == 100) then {
								_combination_1_Display = "Red";
							};
							if (_combination_1 == 101) then {
								_combination_1_Display = "Green";
							};
							if (_combination_1 == 102) then {
								_combination_1_Display = "Blue";
							};
							_combinationDisplay = format["%1%2%3",_combination_1_Display,_combination_2,_combination_3];
						};

						case 3: { // 3 combolock
							_combination_1 = floor(random 10);
							_combination_2 = floor(random 10);
							_combination_3 = floor(random 10);
							_combination = format["%1%2%3",_combination_1,_combination_2,_combination_3];
							dayz_combination = _combination;
							_combinationDisplay = _combination;
						};

						case 4: { // 4 safe
							_combination_1 = floor(random 10);
							_combination_2 = floor(random 10);
							_combination_3 = floor(random 10);
							_combination_4 = floor(random 10);
							_combination = format["%1%2%3%4",_combination_1,_combination_2,_combination_3,_combination_4];
							dayz_combination = _combination;
							_combinationDisplay = _combination;
						};
					};

					_tmpbuilt setVariable ["CharacterID",_combination,true];
					_tmpbuilt setVariable ["ownerPUID",_playerUID,true];


					PVDZE_obj_Publish = [_combination,_tmpbuilt,[_dir,_location,_playerUID,_vector],_classname];
					//diag_log "Publish Lockable";
					publicVariableServer "PVDZE_obj_Publish";

					cutText [format[(localize "str_epoch_player_140"),_combinationDisplay,_text], "PLAIN DOWN", 5];


				} else {
					_tmpbuilt setVariable ["CharacterID",dayz_characterID,true];
					_tmpbuilt setVariable ["ownerPUID",_playerUID,true];
					
					// fire?
					if(_tmpbuilt isKindOf "Land_Fire_DZ") then {
						_tmpbuilt spawn player_fireMonitor;
					} else {
						PVDZE_obj_Publish = [dayz_characterID,_tmpbuilt,[_dir,_location,_playerUID,_vector],_classname];
						publicVariableServer "PVDZE_obj_Publish";
					};
				};
			} else {
				//diag_log "Remove Item NOT OK";
				deleteVehicle _tmpbuilt;
				cutText [(localize "str_epoch_player_46") , "PLAIN DOWN"];
				{
					[player,_x] call BIS_fnc_invAdd;
				} forEach _temp_removed_array;				
			};

		} else {
			//diag_log "Proceed NOT OK";
			r_interrupt = false;
			if (vehicle player == player) then {
				[objNull, player, rSwitchMove,""] call RE;
				player playActionNow "stop";
			};

			deleteVehicle _tmpbuilt;

			cutText [(localize "str_epoch_player_46") , "PLAIN DOWN"];
		};

	} else {
		//diag_log "Cancel is TRUE";
		deleteVehicle _tmpbuilt;
		cutText [format[(localize "str_epoch_player_47"),_text,_reason], "PLAIN DOWN"];
	};
};

DZE_ActionInProgress = false; 

ObjectUID;Instance;Classname;Datestamp;LastUpdated;CharacterID;Worldspace;Inventory;Hitpoints;Fuel;Damage
198104448612142;11;MetalFloor_DZ;2014-08-09 14:18:49;2014-08-09 14:18:49;660;[265.291,[1980.96,4448.6,1.151],"76561198035522330",[[-0.705,-0.058,0.707],[0.705,0.058,0.707]]];[];[];0.00000;0.00000

Vectors now saving to the database with metal floors! yay

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...