Jump to content

My Locked Vehicles with God Mode


Donnovan

Recommended Posts

*** UPDATED WITH A MAJOR BUG FIX IN THE DATE 2014-10-06 1:10 PM

*** This update will fix the Repair Vehicle working always in all cases

*** without the need of vehicle parts, wheell, glass, motor or tools

*** The only file that changed was the file lock_god.sqf.

Hi,

Here is My Locked Vehicles with God Mode.

FEATURES:

- The Vehicles survives Kamikaze attack!

- The God Mode not expires when the player exit the server!

- Can be easily upgraded to plot proximity god mode or anything else!

- Initial locked Vehicles have God Mode!

INSTALLATION!

1) LOCK_GOD.SQF

Create a file with the name lock_god.sqf, with the content bellow, and put it into a folder called custom inside your mission folder.

if (isServer) then {
	"cad_pvar_set_veh" addPublicVariableEventHandler {
		private ["_veh","_godOn"];
		_veh = _this select 1 select 0;
		_godOn = _this select 1 select 1;
		if (_godOn) then {
			_veh allowDamage false;
			_veh RemoveAllEventHandlers "handleDamage";
			_veh addEventHandler ["handleDamage",{0}];
		} else {
			_veh allowDamage true;
			_veh RemoveAllEventHandlers "handleDamage";
			_veh addEventHandler ["handleDamage",{_this call vehicle_handleDamage;}];
		};
	};
};

local_lockUnlock = {
	private ["_vehicle","_status"];
	_vehicle = _this select 0;
	_status = _this select 1;

	if (local _vehicle || isServer) then {
		if(_status) then {
			_vehicle setVehicleLock "LOCKED";
			if (count (crew _vehicle) == 0) then{ //MIKE POST
				_vehicle allowDamage false;
				_vehicle RemoveAllEventHandlers "handleDamage";
				_vehicle addEventHandler ["handleDamage",{0}];
				cad_pvar_set_veh = [_vehicle,true];
				publicVariableServer "cad_pvar_set_veh";
			}; //MIKE POST

		} else {
			_vehicle setVehicleLock "UNLOCKED";
			_vehicle allowDamage true;
			_vehicle RemoveAllEventHandlers "handleDamage";
			_vehicle addEventHandler ["handleDamage",{_this call vehicle_handleDamage;}];
			cad_pvar_set_veh = [_vehicle,false];
			publicVariableServer "cad_pvar_set_veh";
		};
	};
};
2)INIT.SQF

Open your init.sqf (located in your mission folder) and search for that line:

call compile preprocessFileLineNumbers "z\addons\dayz_code\init\compiles.sqf";	//Compile regular functions
If you don't find it, search for the line:

call compile preprocessFileLineNumbers "dayz_code\init\compiles.sqf";	//Compile regular functions
Bellow it, add the line:

call compile preprocessFileLineNumbers "custom\lock_god.sqf";
3) SYSTEM/SERVER_MONITOR.SQF:

Now, to make initial locked vehicles invunerable until unlocked, you must modify the server_monitor.sqf server file, located in dayz_server/system/server_monitor.sqf:

Change that:

if(_ownerID != "0" && !(_object isKindOf "Bicycle")) then {
	_object setvehiclelock "locked";
};
To that:

if(_ownerID != "0" && !(_object isKindOf "Bicycle")) then {
	_object setvehiclelock "locked";
	//LOCK GOD BEGIN
	_object allowDamage false;
	_object RemoveAllEventHandlers "handleDamage";
	_object addEventHandler ["handleDamage",{0}];						
	//LOCK GOD END
};
4) BATTLEYE EXCESSION:

You need to liberate the public variable cad_pvar_set_veh in BattlEye.

END

It's done!

I have done tests with players of my server. But feel free to make your tests so we have sure everything is ok!

Link to comment
Share on other sites

Mike, you is right.

Added two lines based on your post, those lines have a //MIKE POST comment at the end.

Those two lines are untested, i can't test it now, my wife awaits me.

WORK TO DO:

- Make it compatible with Gebriel Safe Zones and Admin Tools so unlocking vehicles in safe does not remove its invunerability set by Gebriel or Admin Tools.

Link to comment
Share on other sites

I did it this way long ago... I have never found  any problems with it.

I have posted it here and there but eveyone wants to use a script for it.

I got a few comments of other admis that tried it and they say it works for them also

I just added a few simple lines to K.I.S.S

 local_lockUnlock.sqf

 

private ["_vehicle","_status"];
_vehicle = _this select 0;
_status = _this select 1;


if (local _vehicle) then {
if(_status) then {
_vehicle setVehicleLock "LOCKED";
_vehicle allowDamage false;
_vehicle enableSimulation true;
} else {
_vehicle setVehicleLock "UNLOCKED";
_vehicle allowDamage true;
        _vehicle enableSimulation true;
};
};
Link to comment
Share on other sites

Calamity,

This is indeed simple, i would just like to test those tree things:

- If the player that locked the vehicle exits the server, the vehicle is still invincible?

- The invincibility works against Heli Kamikaze?

- At server restart, locked vehicles are invincible?

Since you use it for some time, did you know the answers?

Link to comment
Share on other sites

Calamity,

This is indeed simple, i would just like to test those tree things:

- If the player that locked the vehicle exits the server, the vehicle is still invincible?

- The invincibility works against Heli Kamikaze?

- At server restart, locked vehicles are invincible?

Since you use it for some time, did you know the answers?

 

1) YES

2) YES

3) YES

 

Besides, this has been done serveral times:

 

Topics:

 

http://epochmod.com/forum/index.php?/topic/8155-script-locked-vehicles-no-damage/page-2?hl=%2Bvehicle+%2Bgodmode#entry59527

http://dayzepoch.com/forum/index.php?/topic/3190-godmode-vehicles-in-safe-zones/?p=20384

 

Link to comment
Share on other sites

So far so good but what if someone like me uses a custom salvage vehicle script, if the Vehicle is locked you can basicly dupe Engine Parts, Fueltank. Also you can still disassable some PArts like Tires for example, how do i get this work?

 

Here is my Salvage Vehicle Script

 

http://pastebin.com/AUnaybnQ

 

 

It would be nice if some of you gentlemen help me out.

Link to comment
Share on other sites

  • 2 weeks later...

*** UPDATED WITH A MAJOR BUG FIX IN THE DATE 2014-10-06 1:10 PM

*** This update will fix the Repair Vehicle working always in all cases

*** without the need of vehicle parts, wheell, glass, motor or tools

*** The only file that changed was the file lock_god.sqf.

Changed that:

_vehicle addEventHandler ["handleDamage", {_this select 2;}];
to that:

_vehicle addEventHandler ["handleDamage", {_this call vehicle_handleDamage;}];
Thanks a lot StiflresM0M!
Link to comment
Share on other sites

  • 5 months later...

you can simply edit the salvage line on your fn_selfaction:

 

from this:

if ((dayz_myCursorTarget != _cursorTarget) && _isVehicle && !_isMan && _hasToolbox && (damage _cursorTarget < 1) && !_isDisallowRepair) then {

to this:

if ((dayz_myCursorTarget != _cursorTarget) && _isVehicle && !_isMan && _hasToolbox && (damage _cursorTarget < 1) && !_isDisallowRepair && !locked _cursorTarget) then {

This will remove the repair and salvage option on locked vehicles

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Discord

×
×
  • Create New...