Jump to content
  • 0

Merging two scripts, Vehicle Garage & Doormanagement


Kimzer

Question

Hey! I need some help merging the vehicle garage script with the doormanagement. 

As far as i can tell they will conflict in server_updateObject.sqf

 

The below is mine with doormanagement and vehicle paint added. And the last bit of code in this topic is from Overheat's github.

Can anyone help me put the changes for vehicle garage in?

private ["_object","_type","_objectID","_uid","_lastUpdate","_needUpdate","_object_position","_object_inventory","_object_damage","_isNotOk","_parachuteWest","_firstTime","_object_killed","_object_repair","_isbuildable"];
_object = _this select 0;
if (isNull(_object)) exitWith {diag_log format["Skipping Null Object: %1", _object]};

_type 			= _this select 1;
_parachuteWest 	= ((typeOf _object == "ParachuteWest")||(typeOf _object == "ParachuteC"));
_isbuildable 	= (typeOf _object) in dayz_allowedObjects;
_isNotOk 		= false;
_firstTime 		= false;
_objectID 		= _object getVariable ["ObjectID","0"];
_uid 			= _object getVariable ["ObjectUID","0"];

if ((typeName _objectID != "string")||(typeName _uid != "string")) then {
    diag_log(format["Non-string Object: ID %1 UID %2", _objectID, _uid]);
    _objectID = "0";
    _uid = "0";
};

if (!_parachuteWest and !(locked _object)) then {
	if ((_objectID == "0")&&(_uid == "0")) then {
		_object_position = getPosATL _object;
    	_isNotOk = true;
	};
};

if (_isNotOk and _isbuildable) exitWith {};

_lastUpdate = _object getVariable ["lastUpdate",time];
_needUpdate = (if (_object in update_whitelist) then {false} else {_object in needUpdate_objects});

/* Vehicle Paint Start */
_object_position = {
	private["_position","_worldspace","_fuel","_key","_colour","_colour2"];
		_position = getPosATL _object;
		if (_object isKindOf "AllVehicles") then {
			_colour = _object getVariable ["Colour","0"];
			_colour2 = _object getVariable ["Colour2","0"];
			_worldspace = [
				round(direction _object),
				_position,
				_colour,
				_colour2
			];
			_fuel = fuel _object;
		} else {
			_worldspace = [
				round(direction _object),
				_position
			];
			_fuel = 0;
		};
		_key = format["CHILD:305:%1:%2:%3:",_objectID,_worldspace,_fuel];
		//diag_log ("HIVE: WRITE: "+ str(_key));
		_key call server_hiveWrite;
	};
/* Vehicle Paint End */
/* Door Management Start */
_object_inventory = {
		private["_inventory","_previous","_key"];
		_isNormal = true;
		if (typeOf (_object)in DZE_DoorsLocked) then{
		_isNormal = false;
		_inventory = _object getVariable ["doorfriends", []];
		};
		if(_isNormal)then {
		_inventory = [
		getWeaponCargo _object,
		getMagazineCargo _object,
		getBackpackCargo _object
		];
		};
		_previous = str(_object getVariable["lastInventory",[]]);
		if (str(_inventory) != _previous) then {
			_object setVariable["lastInventory",_inventory];
			if (_objectID == "0") then {
				_key = format["CHILD:309:%1:%2:",_uid,_inventory];
			} else {
				_key = format["CHILD:303:%1:%2:",_objectID,_inventory];
			};
			_key call server_hiveWrite;
		};
	};
/* Door Management End */
/* [_object,_type] spawn server_updateObject; */
private ["_object","_type","_objectID","_uid","_lastUpdate","_needUpdate","_object_position","_object_inventory","_object_damage","_isNotOk","_parachuteWest","_firstTime","_object_killed","_object_repair","_isbuildable","_garagelist"];
_object = 	_this select 0;
if(isNull(_object)) exitWith {diag_log format["Skipping Null Object: %1", _object];};
if ((typeOf _object) in DZE_Garage) then {_garagelist = _this select 2;};
_type = _this select 1;
_parachuteWest = ((typeOf _object == "ParachuteWest") || (typeOf _object == "ParachuteC"));
_isbuildable = (typeOf _object) in dayz_allowedObjects;
_isNotOk = false;
_firstTime = false;
_objectID = _object getVariable ["ObjectID","0"];
_uid = _object getVariable ["ObjectUID","0"];

if ((typeName _objectID != "string") || (typeName _uid != "string")) then { 
    diag_log(format["Non-string Object: ID %1 UID %2", _objectID, _uid]);
    _objectID = "0";
    _uid = "0";
};
if (!_parachuteWest && !(locked _object)) then {
	if (_objectID == "0" && _uid == "0") then {
		_object_position = getPosATL _object;
    	_isNotOk = true;
	};
};

if (_isNotOk && _isbuildable) exitWith {};
if (_isNotOk) exitWith { deleteVehicle _object; diag_log(format["Deleting object %1 with invalid ID at pos [%2,%3,%4]",typeOf _object,_object_position select 0,_object_position select 1, _object_position select 2]); };

_lastUpdate = _object getVariable ["lastUpdate",time];
_needUpdate = _object in needUpdate_objects;

_object_position = {
	private["_position","_worldspace","_fuel","_key","_colour","_colour2"];
	_position = getPosATL _object;
	if (_object isKindOf "AllVehicles") then {
		_colour = _object getVariable ["Colour","0"];
		_colour2 = _object getVariable ["Colour2","0"];
		_worldspace = [
			round(direction _object),
			_position,
			_colour,
			_colour2
		];
		_fuel = fuel _object;
	} else {
		_worldspace = [
			round(direction _object),
			_position
		];
		_fuel = 0;
	};
	_key = format["CHILD:305:%1:%2:%3:",_objectID,_worldspace,_fuel];
	//diag_log ("HIVE: WRITE: "+ str(_key));
	_key call server_hiveWrite;
};

_object_inventory = {
	private["_inventory","_previous","_key"];
		if ((typeOf _object) in DZE_Garage) then {
			if (isNil "_garagelist") then {
				_garagelist = _object getVariable ["StoredVehicles",[]];
			};
			if (_objectID == "0") then {
				_key = format["CHILD:309:%1:%2:",_uid,_garagelist];
			} else {
				_key = format["CHILD:303:%1:%2:",_objectID,_garagelist];
			};
			_key call server_hiveWrite;
		} else {
			_inventory = [
				getWeaponCargo _object,
				getMagazineCargo _object,
				getBackpackCargo _object
			];
			_previous = str(_object getVariable["lastInventory",[]]);
			if (str(_inventory) != _previous) then {
				_object setVariable["lastInventory",_inventory];
				if (_objectID == "0") then {
					_key = format["CHILD:309:%1:%2:",_uid,_inventory];
				} else {
					_key = format["CHILD:303:%1:%2:",_objectID,_inventory];
				};
				//diag_log ("HIVE: WRITE: "+ str(_key));
				_key call server_hiveWrite;
			};
		};
};

_object_damage = {
	private["_hitpoints","_array","_hit","_selection","_key","_damage"];
		if ((typeOf _object) in DZE_Garage) then {
			_damage = damage _object;
			_array = _object getVariable ["GarageFriends",[]];
		} else {
			_hitpoints = _object call vehicle_getHitpoints;
			_damage = damage _object;
			_array = [];
			{
				_hit = [_object,_x] call object_getHit;
				_selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
				if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
				_object setHit ["_selection", _hit];
			} count _hitpoints;
		};
	
		_key = format["CHILD:306:%1:%2:%3:",_objectID,_array,_damage];
		//diag_log ("HIVE: WRITE: "+ str(_key));
		_key call server_hiveWrite;
	_object setVariable ["needUpdate",false,true];
	};

_object_killed = {
	private["_hitpoints","_array","_hit","_selection","_key","_damage"];
	_hitpoints = _object call vehicle_getHitpoints;
	//_damage = damage _object;
	_damage = 1;
	_array = [];
	{
		_hit = [_object,_x] call object_getHit;
		_selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
		if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
		_hit = 1;
		_object setHit ["_selection", _hit];
	} count _hitpoints;
	
	if (_objectID == "0") then {
		_key = format["CHILD:306:%1:%2:%3:",_uid,_array,_damage];
	} else {
		_key = format["CHILD:306:%1:%2:%3:",_objectID,_array,_damage];
	};
	//diag_log ("HIVE: WRITE: "+ str(_key));
	_key call server_hiveWrite;
	_object setVariable ["needUpdate",false,true];
	if ((count _this) > 2) then {
		_killer = _this select 2;
		_charID = _object getVariable ['CharacterID','0'];
		_objID 	= _object getVariable['ObjectID','0'];
		_objUID	= _object getVariable['ObjectUID','0'];
		_worldSpace = getPosATL _object;
		if (getPlayerUID _killer != "") then {
			_name = if (alive _killer) then { name _killer; } else { format["OBJECT %1", _killer]; };
			diag_log format["Vehicle killed: Vehicle %1 (TYPE: %2), CharacterID: %3, ObjectID: %4, ObjectUID: %5, Position: %6, Killer: %7 (UID: %8)", _object, (typeOf _object), _charID, _objID, _objUID, _worldSpace, _name, (getPlayerUID _killer)];
		} else {
			diag_log format["Vehicle killed: Vehicle %1 (TYPE: %2), CharacterID: %3, ObjectID: %4, ObjectUID: %5, Position: %6", _object, (typeOf _object), _charID, _objID, _objUID, _worldSpace];
		};
	};
};

_object_repair = {
	private["_hitpoints","_array","_hit","_selection","_key","_damage"];
	_hitpoints = _object call vehicle_getHitpoints;
	_damage = damage _object;
	_array = [];
	{
		_hit = [_object,_x] call object_getHit;
		_selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
		if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
		_object setHit ["_selection", _hit];
	} count _hitpoints;
	
	_key = format["CHILD:306:%1:%2:%3:",_objectID,_array,_damage];
	//diag_log ("HIVE: WRITE: "+ str(_key));
	_key call server_hiveWrite;
	_object setVariable ["needUpdate",false,true];
};

_object setVariable ["lastUpdate",time,true];
switch (_type) do {
	case "all": {
		call _object_position;
		call _object_inventory;
		call _object_damage;
		};
	case "position": {
		if (!(_object in needUpdate_objects)) then {
			//diag_log format["DEBUG Position: Added to NeedUpdate=%1",_object];
			needUpdate_objects set [count needUpdate_objects, _object];
		};
	};
	case "gear": {
		call _object_inventory;
			};
	case "damage": {
		if ( (time - _lastUpdate) > 5) then {
			call _object_damage;
		} else {
			if (!(_object in needUpdate_objects)) then {
				//diag_log format["DEBUG Damage: Added to NeedUpdate=%1",_object];
				needUpdate_objects set [count needUpdate_objects, _object];
			};
		};
	};
	case "killed": {
		call _object_killed;
	};
	case "repair": {
		call _object_damage;
	};
};
Link to comment
Share on other sites

14 answers to this question

Recommended Posts

  • 0

Added that fancy garage by 0verHeaT on my test server and got it to play nice with plot/door management. All you need to do is make 2 small adjustments in 2 serverside files, that's it.

 

In your server_updateObject.sqf you add this

if ((typeOf _object) in DZE_Garage) then {
	_isNormal = false;
	_inventory = _object getVariable ["StoredVehicles",[]];
};

below this part you got there

		_isNormal = true;
		if (typeOf (_object)in DZE_DoorsLocked) then{
		_isNormal = false;
		_inventory = _object getVariable ["doorfriends", []];
		};

And in server_monitor.sqf you'll add this thing, instead of that what's on his git

if ((typeOf _object) in DZE_Garage) then {
    _object setVariable ["StoredVehicles",_inventory,true];
    _object setVariable ["GarageFriends",_hitPoints,true];
};

Afterwards you'll want to add other parts by his instructions, here's an example of that last part you need to add in server_monitor

if ((count _inventory > 0) && !(typeOf( _object) == "Plastic_Pole_EP1_DZ") && !(typeOf( _object) in  DZE_DoorsLocked) && !(typeOf( _object) in  DZE_Garage)) then {

Also remember that all _intentory parts should be _inventory instead

 

P.S. I suggest you have a look at this, it will come in handy at some point when you might want to merge or simply compare 2 files

Link to comment
Share on other sites

  • 0

It works somewhat. The only issue i am seeing is that the garage is constantly locked.

I tried editing it and just making myself have access to all garages, that worked fine.

Tho i am not using P4L. Do you have a solution for that? 

Link to comment
Share on other sites

  • 0

Yeah, looking at it. Tho, i think u are mistaken here ->  "Also remember that all _intentory parts should be _inventory instead" 

I seem to remember _intentory is a common typo in epoch and thats why its used. I tested it with _inventory just for the lulz and it errored hard. 

Just for future reference tho if there anyone else looking for this :)

Link to comment
Share on other sites

  • 0

Added that fancy garage by 0verHeaT on my test server and got it to play nice with plot/door management. All you need to do is make 2 small adjustments in 2 serverside files, that's it.

 

In your server_updateObject.sqf you add this

if ((typeOf _object) in DZE_Garage) then {
	_isNormal = false;
	_inventory = _object getVariable ["StoredVehicles",[]];
};

below this part you got there

		_isNormal = true;
		if (typeOf (_object)in DZE_DoorsLocked) then{
		_isNormal = false;
		_inventory = _object getVariable ["doorfriends", []];
		};

And in server_monitor.sqf you'll add this thing, instead of that what's on his git

if ((typeOf _object) in DZE_Garage) then {
    _object setVariable ["StoredVehicles",_inventory,true];
    _object setVariable ["GarageFriends",_hitPoints,true];
};

Afterwards you'll want to add other parts by his instructions, here's an example of that last part you need to add in server_monitor

if ((count _inventory > 0) && !(typeOf( _object) == "Plastic_Pole_EP1_DZ") && !(typeOf( _object) in  DZE_DoorsLocked) && !(typeOf( _object) in  DZE_Garage)) then {

Also remember that all _intentory parts should be _inventory instead

 

P.S. I suggest you have a look at this, it will come in handy at some point when you might want to merge or simply compare 2 files

 

 

I get it all to work but what do you use to build the garage i use deploy anything and for some reason it wont let me in the garage menu i just get garage locked .

Link to comment
Share on other sites

  • 0

You need plot 4 life or something similar that stores your owner id in the database.

 

For example i've added virtual garage to a fuel barrel or whatever kind of barrel it is that you can build :D

Well i have plot for life and i use deploy anything to deploy a garage on my own plotpole parameter but still i only get garage is locked for some reason .

Dont get any rpt errors either .

Things i have running is plot for life , doormanagement  , plotmanagement and snap pro with vectors and all that stuff .

 

In deploy anything i made it so i rightclick on a plotdeed i can deploy a garage and a heli spawn spot .

Tried adding myself to the plotpole aswell .

Checked the rpt and it logged the building to database cause i get the hivewrite message .

 

Anyway i could get in contact with you like on ts or something ??

 

Thanks for the quick reply btw doesnt happen that much :D

Link to comment
Share on other sites

  • 0

Maybe this topic could help you:

 

0verHeaT created a solution for me how to use the PlotManagement with the Vehicle Garage. If you are listed as Plot Friend you will get the option "Garage Menu". If there is no Plot Pole or you're not listed it won't work of course.

 

@ Antichrist

 

Do you have also problems with storage location in the database? After 15 vehicles saved to the garage no other vehicles get saved anymore. Do you have any idea for this problem?

 

Best regards,

 

GudrunGisela

Link to comment
Share on other sites

  • 0

Yes of course this is a possibility but by default the # of vehicles in a garage is set to 40 or 50 I think. I also removed the setting that the inventory of the vehicle is saved to the database too because one full truck with many difficult items leads to a full garage and I think this is not normal. I think I missed a setting that adjust the maximum capacity of the inventory line in the database but I don't know if it's caused by the script or the database itself. I would be very grateful if someone has a solution for this.

Link to comment
Share on other sites

  • 0

I have tried installing this three times. Each time I used a different way to get a garage. infiSTAR, Alchemy Building and just putting a plotpole next to one already on the map and each time I got "Garage Locked" so I gave up .... Would love to get it working though.

Link to comment
Share on other sites

  • 0

Well i got it work for a bit but meant going into the database and write the plotpole owner id to the garage itself .

So if would be great if somebody could enlighten us on how to get the garage to get written to the plotpole with building it .

Right now i tried using deploy anything script but that works untill restart comes , after restart it seems the garage is back to a state that is not a part of your plot anymore .

Link to comment
Share on other sites

  • 0

Maybe this topic could help you:

 

0verHeaT created a solution for me how to use the PlotManagement with the Vehicle Garage. If you are listed as Plot Friend you will get the option "Garage Menu". If there is no Plot Pole or you're not listed it won't work of course.

 

@ Antichrist

 

Do you have also problems with storage location in the database? After 15 vehicles saved to the garage no other vehicles get saved anymore. Do you have any idea for this problem?

 

Best regards,

 

GudrunGisela

What do you use to deploy a garage then if i may ask ?

Link to comment
Share on other sites

  • 0

Maybe this topic could help you:

 

0verHeaT created a solution for me how to use the PlotManagement with the Vehicle Garage. If you are listed as Plot Friend you will get the option "Garage Menu". If there is no Plot Pole or you're not listed it won't work of course.

 

@ Antichrist

 

Do you have also problems with storage location in the database? After 15 vehicles saved to the garage no other vehicles get saved anymore. Do you have any idea for this problem?

 

Best regards,

 

GudrunGisela

This actually worked great thanks :D

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
  • Discord

×
×
  • Create New...