Jump to content

[Release] Gebriel Safe Zones Maybe


Recommended Posts

If you like my work, please consider a donation:

btn_donate_LG.gif $USD

btn_donate_LG.gif $EURO

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

*** for vehicles that entered the safezone.

*** The only file that change is the file safezone.sqf.

Rai!

Gebriel

angelwithsword_zps2fb55b02.jpg

We, from Clodovil BR Server, are proud to present you, the Gebriel Safe Zones. (safe as heaven).

SAFEZONES?

Safezones are excluding areas where peace must be maintained or, sadly, forced.

WHAT MOST SAFE PREVENTS

Cant kill other players

Cant destroy vehicles

Cant access any gear for any player/vehicle

WHAT GEBRIEL PREVENTS

Cant kill other players

Cant destroy vehicles

Can't mess with any player gear

Can't mess with vehicles you does not have ownerity

Can't mess with gear of vehicles you does not have ownerity

VEHICLE OWNERITY?

Is when you have acess to a vehicle inside a safe zone, you have access to the vehicle and to the vehicle gear.

HOW TO HAVE VEHICLE OWNERITY IN THE SAFE ZONE?

You must enter the safe zone inside the vehicle.

If a group of 10 people is on a truck and this truck enters the safe zone, those 10 players will have access to the truck and to the truck gear. No more players will have access to it.

HOW TO REMOVE VEHICLE OWNERITY?

You must try to invade the vehicle you does not have ownerity. After the first invasion try, a 8 minutes counter will start, and when the counter reachs zero the vehicle will loose it ownerity and will be avaliable to all players, until someone enters again in the safe with it.

HOW TO STOP THE 8 MINUTOS COUNTER?

One or more of the vehicle owners need to re-enters in the safe with the vehicle.

WHAT ABOUT VEHICLES THAT ON SERVER START ARE IN THE SAFE ZONES?

They don't have ownerity and don't have god mode. But if a player re-enters with it in the safe zone, he will gain ownerity over it.

NOTE

Vehicle ownerity is something that only exists inside safe zones.

{[THE CODE]} {[THE CODE]} {[THE CODE]}

1) INIT.SQF

At the end of your init.sqf file, add this code:

if (!isServer) then {
	//Gebriel Safe
	[] execVM "custom\safezone.sqf";	
};
2) [MISSION FOLDER]\CUSTOM\SAFEZONE.SQF

This bellow is the main script, it's called from the init.sqf file.

Create a new text file, put this code bellow in it, rename the text file to safezone.sqf and put it in your [mission folder]\custom\ folder (create this folder if necessary).

Thanks for Maca134 for the Custom Remote Messages Script:

//Gebriel Safezones
//By Donnovan from Brazil
don_incar = 0;
don_firedEH_1 = nil;
don_godon_1 = 0;
inSafeZone = false;
[] spawn {
	private ["_runOneTime","_canbuild","_don_passengers","_don_veh_crew","_don_player_veh","_don_veh_driver"];
	waitUntil {!(isNil "canbuild")};
	_runOneTime = false;
	_canbuild = canbuild;
	while {true} do {
		waitUntil {!((_canbuild && canbuild) || (!_canbuild && !canbuild)) || !_runOneTime};
		_canbuild = canbuild;
		if (!canbuild) then {
			player_zombieCheck = {};
			fnc_usec_damageHandler = {};
			fnc_usec_unconscious  = {};
			player allowDamage false;
			player removeAllEventHandlers "handleDamage"; don_godon_1 = 1; inSafeZone = true; sleep 0.025;
			[] spawn {
				private ["_myHdEh"];
				while {!canbuild} do {
					_myHdEh = player addEventHandler ["handleDamage", {0}];
					sleep 0.02;
					player removeEventHandler ["handleDamage",_myHdEh];
				};
			};
			if (isNil "don_firedEH_1") then {
				don_firedEH_1 = 0; sleep 0.025;
				don_firedEH_1 = player addEventHandler ["Fired",{
					cutText ["Can't fire with godon.","PLAIN DOWN", 2];
					deleteVehicle (_this select 6);
				}];
			};
		};
		if (canbuild && _runOneTime) then {
			[] spawn {
				for "_x" from 1 to 30 do {
					if (_x >= 6) then {cutText [format ["%1 seconds to godoff and shoton.", 31-_x], "PLAIN DOWN"];};
					sleep 1;
					if (!canbuild) exitWith {};
					if (_x == 30) then {
						cutText ["Godoff and Shoton!", "PLAIN DOWN"];
						player_zombieCheck = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_zombieCheck.sqf";
						fnc_usec_damageHandler = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_damageHandler.sqf";
						fnc_usec_unconscious = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_unconscious.sqf";
						player allowDamage true;
						player removeAllEventHandlers "handleDamage";
						player addEventHandler ["handleDamage", {_this call fnc_usec_damageHandler;}];
						player removeEventHandler ["Fired", don_firedEH_1]; don_firedEH_1 = nil;
						don_godon_1 = 0; inSafeZone = false;
					};
				};
			};
		};
		if (!canbuild && don_incar == 1) then {
			_don_player_veh = don_player_veh; don_veh_crew = crew _don_player_veh; _don_veh_driver = driver _don_player_veh;
			_don_player_veh allowDamage false;
			_don_player_veh removeAllEventHandlers "handleDamage";
			_don_player_veh addEventHandler ["handleDamage", {0}];
			_don_player_veh removeAllEventHandlers "Fired";
			_don_player_veh addEventHandler ["Fired",{deleteVehicle (_this select 6);}];			
			//PASSENGERS NAMES
			_don_passengers = ""; {if (Alive _x) then {_don_passengers = _don_passengers + format [" %1",name _x];};} forEach don_veh_crew;
			_don_veh_crew = []; {if (Alive _x) then {_don_veh_crew = _don_veh_crew + [getPlayerUID _x];};} forEach don_veh_crew;
			//ASSING OWNERS
			if (player == _don_veh_driver) then {
				_don_player_veh setVariable ["don_ownerity_code", format ["%1_%2", getPlayerUID player, round diag_tickTime], true];
				_don_player_veh setVariable ["don_crew", _don_veh_crew, true]; //CHANGE
				_don_player_veh setVariable ["don_passengers", _don_passengers, true];
			};
		};
		if (canbuild && don_incar == 1) then {
			_don_player_veh = don_player_veh; _don_veh_driver = driver _don_player_veh;			
			[_don_player_veh] spawn {
				for "_x" from 1 to 15 do {
					sleep 1;
					if (!canbuild) exitWith {};
					if (_x == 15) then {
						(_this select 0) allowDamage true;
						(_this select 0) removeAllEventHandlers "handleDamage";
						(_this select 0) addEventHandler ["handleDamage", {_this call vehicle_handleDamage;}];
						(_this select 0) removeAllEventHandlers "Fired";
					};
				};	
			};
			//DISASSING OWNERS
			if (player == _don_veh_driver) then {
				_don_player_veh setVariable ["don_ownerity_code", nil, true];
				_don_player_veh setVariable ["don_crew", nil, true];
				_don_player_veh setVariable ["don_passengers", nil, true];
			};
		};
		_runOneTime = true;
	};
};
[] spawn {
	private ["_don_veh_crew","_wait_time","_last_mark","_max_time"];
	while {true} do {
		_max_time = 480;
		waitUntil {sleep 0.0625; vehicle player != player};
		don_player_veh = vehicle player;
		don_incar = 1;
		if (!canbuild) then {
			//VEHICLE OWNERITY CHECK
			_don_veh_crew = don_player_veh getVariable ["don_crew", nil]; if (isNil "_don_veh_crew") then {_don_veh_crew = [getPlayerUID player];};
			if !(getPlayerUID player in _don_veh_crew) then {
				call compile format ['if (isNil "don_%1") then {don_%1 = diag_tickTime;}; _last_mark = don_%1;', don_player_veh getVariable ["don_ownerity_code", 0]];
				_wait_time = diag_tickTime - _last_mark;
				if (_wait_time < _max_time) then {
					player action ["getOut", don_player_veh];
					[objNull, player, rSAY, "error1"] call RE;
					cuttext [format ["Owners:%1. %2 seconds to liberate.", don_player_veh getVariable ["don_passengers","Owners not found"], round (_max_time - _wait_time)], "PLAIN DOWN"];
					cad_pvar_smessage = [format ["%1 is messing with your vehicle! %2 seconds to liberate!", name player, round (_max_time - _wait_time)], _don_veh_crew];
					publicVariable "cad_pvar_smessage";
				} else {
					call compile format ['don_%1 = nil;', don_player_veh getVariable ["don_ownerity_code", 0]];
					//DISASSING OWNERS
					don_player_veh setVariable ["don_ownerity_code", nil, true];
					don_player_veh setVariable ["don_crew", nil, true];
					don_player_veh setVariable ["don_passengers", nil, true];
					cuttext [format ["Vehicle is now free for all!"], "PLAIN DOWN"];
					cad_pvar_smessage = [format ["One of your safe vehicle is now free and player %1 is in it!", name player], _don_veh_crew];
					publicVariable "cad_pvar_smessage";
				};
			};
			don_player_veh allowDamage false;
			don_player_veh removeAllEventHandlers "handleDamage";
			don_player_veh addEventHandler ["handleDamage", {0}];
			don_player_veh removeAllEventHandlers "Fired";
			don_player_veh addEventHandler ["Fired",{deleteVehicle (_this select 6);}];
		};
		if (canbuild) then {
			don_player_veh allowDamage true;
			don_player_veh removeAllEventHandlers "handleDamage";
			don_player_veh addEventHandler ["handleDamage", {_this call vehicle_handleDamage;}];
			don_player_veh removeAllEventHandlers "Fired";
			//DISASSING OWNERS
			if (player == driver don_player_veh) then {
				don_player_veh setVariable ["don_ownerity_code", nil, true];
				don_player_veh setVariable ["don_crew", nil, true];
				don_player_veh setVariable ["don_passengers", nil, true];
			};
		};
		waitUntil {sleep 0.0625; vehicle player == player};
		don_incar = 0;
		don_player_veh = nil;
	};
};
//Thanks Maca for the Remote Message idea
"cad_pvar_smessage" addPublicVariableEventHandler {
	private ["_message", "_receivers"];
	_message = (_this select 1) select 0; _receivers = (_this select 1) select 1;
	if (getPlayerUID player in _receivers) then {cutText [_message, "PLAIN DOWN"];};
};
3) [MISSION FOLDER]\DAYZ_CODE\COMPILE\FN_GEARMENUCHECKS.SQF

This code bellow goes at the end of your custom dayz_code\compile\fn_gearMenuChecks.sqf.

Thanks for Maca134 for the no-player-gear-acess-in-safe script.

To have a custom dayz_code\compile\fn_gearMenuChecks.sqf file you will need a custom dayz_code\init\compiles.sqf, since the first is called in game by the second, so you need a custom compiles.sqf that calls your custom fn_gearMenuChecks.sqf file, and since compiles.sqf is now custom, you need to change the call in init.sqf to it, since compiles.sqf is called in-game by init.sqf.

More on that later! Sorry for now! If you have any doubt, please ask!

//Prevents players opening others backpacks MACA123
if (isNil "inSafeZone") then {inSafeZone = false;};
if ((!canbuild || inSafeZone) and _cTarget isKindOf "Man" and alive _cTarget and (((vehicle player) distance _cTarget) < 12)) then {
	cutText ["Cannot access other players gear in the safezone." , "PLAIN DOWN"];
	_display closeDisplay 1;
};

//Gebriel Safezones
//by Donnovan from Brazil
if (!canbuild) then {
	private ["_don_iscar","_don_ismycar","_don_crew"];
	_don_iscar = false; _don_ismycar = false;
	if (_cTarget isKindOf "LandVehicle" || _cTarget isKindOf "Air" || _cTarget isKindOf "Ship" ) then {
		_don_crew = _cTarget getVariable ["don_crew", nil]; if (isNil "_don_crew") then {_don_crew = [getPlayerUID player];};
		_don_iscar = true; if ((getPlayerUID player) in _don_crew) then {_don_ismycar = true;};
	};
	if (_don_iscar && !_don_ismycar) then {
		[objNull, player, rSAY, "error1"] call RE;
		cutText ["You can't access this vehicle gear!" , "PLAIN DOWN"];
		_display closeDisplay 1;
	};
};
4) ERROR1.OGG

The scipt have a sound file, download it on this link and put the file at the root of your mission folder: http://s000.tinyupload.com/index.php?file_id=69305942403778252911

Add the sound declaration in description.ext. Here is my description.ext:

//DONN sounds
class CfgSounds {
    sounds[] = {error1};
	class error1 {
		name="error1";
		sound[]={error1.ogg,1,1};
		titles[] = {};
   };
};
You could have more custom sounds on class CfgSounds, if so you need to acomodate then together.

This bellow is a example where the Gebriel Safezones error1.ogg sound coexists with another 2 custom sounds (diescream.ogg and caloideploy.ogg):

//DONN sounds
class CfgSounds
{
    sounds[] = {dieScream,caloideploy,error1};
        class dieScream {
		name="dieScream";
		sound[]={diescream.ogg,1,1};
		titles[] = {};
    };
	class caloideploy {
		name="caloideploy";
		sound[]={deploys\bike\caloi_deploy.ogg,1,1};
		titles[] = {};
    };
	class error1 {
		name="error1";
		sound[]={error1.ogg,1,1};
		titles[] = {};
   };
};
5) BATTLEYE FILTERS

On the BE filter publicvariable.txt, search for the line that starts with 5 "". At the end of this line add a space and after the space add !"cad_pvar_s".

Link to comment
Share on other sites

Forgot to put the BattlEye filters step, main post updated with:

 

5) BATTLEYE FILTERS

On the BE filter publicvariable.txt, search for the line that starts with 5 "". At the end of this line add a space and after the space add !"cad_pvar_s".

Any feedback, please?

Link to comment
Share on other sites

What, VentZer0? You liked it?

 

Gebriel presents!

not really, no specific safezones, no speedlimit, people still being able to fire weapons and kill eachother, people who drove into the safezone and left the vehicle have to wait 8 minutes to get back in it, vehicles could still be destroyed.

I am not impressed.

Yes I did install it just they way you described it. It is pretty much fool proof to install.

Link to comment
Share on other sites

I would like to add this to my server  but

but Where do I put the safezone coords ???

 

You don't need to mess with safe coordinates, it will use the game build in trader sensors/coordinates.

 

If you want safezone in Air Craft Dealer, this sensor/coordinate need to be created since its not exist by default.

I can help you in anything.

Link to comment
Share on other sites

NEWS: FIX 1, PLAYER GOD MODE - !DONE!

*Main post updated* with fix 1. Fix 1 consists of 4 lines that was added on "[MISSION FOLDER]\CUSTOM\SAFEZONE.SQF". Those linas are commented with a "//FIX 1" at the end.

 

What its fix?

The ausence of those lines (2 when turning god mode on and 2 when turning it off) alowed player to die when a vehicle runs over hin, and, not fully confirmed, allowed player to die when shot by a soldier AI.

The added lines are already on main post, they are:

player removeAllEventHandlers "handleDamage"; //FIX 1
player addEventHandler ["handleDamage", {0}]; //FIX 1
player removeAllEventHandlers "handleDamage"; //FIX 1
player addEventHandler ["handleDamage", {_this select 2}]; //FIX 1
NEWS: FIX 2, VEHICLE OWNERITY ON LOGOFF - !WIP!

If the player have ownerity over a vehicle inside the safe, and he logoff from the game and join again, he will loose this vehicle ownerity but the message that inform owners, when someone try to invade the vehicle, will still show him as a owner.

Way to fix: Store owners as player UID strings instead of player Objects. Fix is a work in progress still.

Link to comment
Share on other sites

NEW FEATURE 1 - *NOT STILL ON MAIN POST*

- Players have a aditional god mode (30 sec) when leaving the safe zones.

- Vehicles have a aditional god mode (15 sec) when leaving the safe zones.

- Players and vehicles can't shot when in the aditional god mode state.

EXTRA REQUERIMENT FOR NEW FEATURE 1 TO WORK

- If you does not use infiStar, the extra requeriment does not exist.

- If you use infiStar, like we do on our server, the extra requeriment is: modify 1 line of infiStar AH.SQF file.

Are you guys interested in see it?

UPDATE ON FIX 1 - SEE POST ABOVE

Remember FIX 1 on the post above this one? This fix will not work if you have infiStar, so players on safes still can die if a vehicle runs over hin and, may be, players still can die for AI.

To that FIX 1 to works on servers with infiStar and players stop diening with those causes (vehicle & AI) it's needed a change in 1 line of infiStar AH.SQF file.

Are you guys interested in see it?

CONCLUSION

So the 30 seconds aditional god mode and a 100% eficienty god mode solution requires the change of 2 lines in infiStar AH.SQF file.

If you don't use infiStar, there will be no extra needs to use those new feature and fix, remembering the new feature is still not revealed on main post.

Link to comment
Share on other sites

  • 2 weeks later...

GEBRIEL SAFEZONES UPDATED

- 30 seconds of bonus god mode and no-shot for players leaving the trader.

- 15 seconds of bonus god mode and no-shot for vehicles leaving the trader.

- Don't need any change in infiStar if you use it (i announced that a change would be needed).

- Ownerity stays even if you log-off or die.

Need any help in installation? Ask me here!

Link to comment
Share on other sites

Important update.

The change is already on the main post.

2) [MISSION FOLDER]\CUSTOM\SAFEZONE.SQF

Changed from:

			[] spawn {
				while {!canbuild} do {
					player addEventHandler ["handleDamage", {0}];
					sleep 0.01;
				};
			};
to:

			[] spawn {
				private ["_myHdEh"];
				while {!canbuild} do {
					_myHdEh = player addEventHandler ["handleDamage", {0}];
					sleep 0.02;
					player removeEventHandler ["handleDamage",_myHdEh];
				};
			};
The original code was creating multiple event handlers that are only deleted when the player leave the safe or if the server have infiStar (infiStar delete the handle damage event handler each 0.5 seconds). With the change the code will create just one event handler in any situation.
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
×
×
  • Create New...