Jump to content
  • 0
Sign in to follow this  
Kimzer

Merging two scripts, Vehicle Garage & Doormanagement

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;
	};
};

Share this post


Link to post
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

Share this post


Link to post
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? 

Share this post


Link to post
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 :)

Share this post


Link to post
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 .

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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 .

Share this post


Link to post
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 ?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Similar Content

    • By salival
      Hi guys,
      Here's an in vehicle garage door opener I wrote a while ago, Original idea was from Sanbird.
      It will scan while you're inside a vehicle for either a locked cinder or a locked wooden door, providing you have access to it, it will allow you to open/close it from inside the car.
      https://github.com/oiad/garageDoorOpener
    • By JakeQue
      Hi guys, need a few updates for the vehicle garage if possible. I need to limit the amount of vehicles per player... 

      Also need to stop overpowered vehicles being stored in the garage. I have updated my player_storeVehicle.sqf with the following code but it's not working, it still stores them : 

       
      // Developed by [GZA] David for German Zombie Apocalypse Servers (https://zombieapo.eu/) private["_unit","_obj","_wogear","_charID","_objectID","_keyavailable","_keyColor","_added","_objectUID","_key","_class","_noStore"]; if(lbCurSel 3802 == -1) exitWith {hint "No Vehicle selected"}; _unit = player; _obj = StoreVehicleList select (lbCurSel 3802); StoreVehicleList = nil; _wogear = _this select 0; closeDialog 0; _noStore = _obj in ["AH64D"]; if (_noStore) exitWith { cutText ["Woah, that vehicle is too overpowered. You can't store that here!", "PLAIN DOWN"]; }; _charID = _obj getVariable ["CharacterID","0"]; _objectID = _obj getVariable ["ObjectID","0"]; _objectUID = _obj getVariable ["ObjectUID","0"]; if (_objectID == "1") exitWith {cutText ["Can not store mission vehicle.", "PLAIN DOWN"];}; // Check for mission vehicle WAI Script _keyavailable = false; _keyColor = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"]; if(_charID != "0") then { { if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in _keyColor) then { if (str(getNumber(configFile >> "CfgWeapons" >> _x >> "keyid")) == _charID) then { _key = _x; _keyavailable = true; }; }; } count (items _unit); } else {_keyavailable = true;}; if (!_keyavailable) exitWith {cutText ["You need the key of the vehicle.", "PLAIN DOWN"];}; _added = false; if (!_wogear) then { _added = [player, Pricegear] call SC_fnc_removeCoins; } else {_added = true;}; Pricegear = nil; if(!_added) exitWith {cutText ["You don't have enough money.", "PLAIN DOWN"];}; if(_charID != "0") then { [_unit,_key] call BIS_fnc_invRemove; cutText ["Key removed!", "PLAIN DOWN"]; }; _obj setvehiclelock "locked"; PVDZE_storeVehicle = [_obj, _unit, _wogear]; publicVariableServer "PVDZE_storeVehicle"; waitUntil {!isNil "PVDZE_storeVehicleResult"}; PVDZ_obj_Destroy = [_objectID,_objectUID,_unit]; publicVariableServer "PVDZ_obj_Destroy"; deleteVehicle _obj; PVDZE_storeVehicleResult = nil; sleep 2; cutText ["Stored Vehicle in Garage.", "PLAIN DOWN"]; Also would be nice to maybe implement an sql event which removes them out the garage after 14 days if anyone could write that? 

      Merci ! xD
    • By Hunt3r
      Hello,
      After wasting many Cinder garage doors due to not placing them the way i wanted them to be facing, I wanted to 
      Ask you all if there is any Way to know what direction a door is facing when placing? 
      Would be a good idea to add an green arrow showing this when placing...
       
      *Note, when using snap-pro it does it automatically so is impossible to tell!
    • By Shizo_Phrenix
      Good morning from Austria,
       
      is in epoch any other garage door available than the standard wood/metal doors?
      It's just about driving into the base with a MTVR or URAL Truck. The only truck who fits is the V3S. 
      Same issues with the Armored Hummer. No chance to geht in (because the weapon is too high).
       
      Any chances to fix that?
      I just want to park every car in my garage - if it's possible?!
       
       
      Thanks!
       
       
       
       
      Cheers Shizo
    • By Uhlan
      A couple of very useful additions to Epoch, I submit, would be hatches (doors in floors) and doors with no top frames (barn doors) so vehicles like MTVRs can fit through.
       
      Hatches could be in 3 general sizes; 1/4 floor, 1/2 floor, and whole floor.
      Barn doors would basically be split, side opening garage doors in a large wall with no top frame so the space above could be left open or another door stacked on top to make a very tall door, or even a regular garage door above the barn doors.  The doors could swing out, hinged at the sides, or slide to either side like a true barn door.  All of this being lockable as per the current door selection.
       
      Stair railings would be a very handy addition, possible replacing supports?  Why are there stair supports anyway except for aesthetic purposes?
       
       
  • Advertisement
  • Supporters
  • Discord

×
×
  • Create New...