Jump to content

Andre Safe Zones for Arma 2 (It's good man!)


Recommended Posts

MEGA UPDATE ON 26 OF OCTOBER OF 2015

FEATURES

- COMPATIBLE WITH INFISTAR

- COMPATIBLE WITH DZGM

- PEOPLE TAGGED AS FRIENDLY OR IN YOUR GROUP (DZGM) CAN ACCESS YOUR GEAR

- PEOPLE TAGGED AS FRIENDLY OR IN YOUR GROUP (DZGM) CAN ACCESS YOUR CAR & CAR GEAR

- A CAR IS YOURS IF YOU ENTERED THE SAFEZONE DRIVING IT

- NO-BUILD ZONES ARROUND SAFEZONES

- 60 SECONDS, FOR PLAYERS ON FOOT, OR 30 SECONDS, FOR MOTORIZED PLAYERS, EXTRA GOD MODE ON SAFE ZONE EXIT

- PLAYER GOD MODE AND NO-SHOT MODE

- REAL VEHICLE GOD MODE AND VEHICLE NO-SHOT MODE FOR ALL PLAYERS

 

If it worked and you enjoy it, i ask for a donation. Thankyou!

btn_donate_LG.gif $USD
btn_donate_LG.gif $EURO

 

INSTALLATION

Put the file andre_safezone.sqf in the root of you mission file.

Add to the end of your init.sqf the line: execVM "andre_safezone.sqf";

 

THE SCRIPT andre_safezones.sqf

if (hasInterface) then {
	//MAP SAFEZONES (READY FOR CHERNARUS)
	donn_traders = [
		["Safe 1",[6325,7807,0],160,500],
		["Safe 2",[4063,11664,0],160,500],
		["Safe 3",[11447,11364,0],160,500],
		["Safe 4",[1606,7803,0],160,500],
		["Safe 5",[12944,12766,0],160,500], 
		["Safe 6",[12060,12640,0],160,500]
	];
	waitUntil {uiSleep 0.5;!isNil "PVDZE_plr_LoginRecord"};
	inSafeZone = false;
	donn_InSafeZone = false;
	donn_canbuild = true;
	donn_incarWas = [];
	donn_inSafeCounter = 0;
	donn_vehicle_handleDamage = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\vehicle_handleDamage.sqf";
	vehicle_handleDamage_timer = 0;
	vehicle_handleDamage = {
		_owner = (_this select 0) getVariable ["don_owner",objNull];
		_hasOwner = !isNull _owner;
		if (_hasOwner) then {
			if (time - vehicle_handleDamage_timer > 2) then {
				vehicle_handleDamage_timer = time;
				systemChat "This vehicle have God Mode!";
			};
		} else {
			_this call donn_vehicle_handleDamage;				
		};
	};
	
	//SAFEZONE PROXIMITY CHECK FUNCTION
	donn_calcSafe = {
		private ["_tName","_tPos","_tRad"];
		_obj = _this select 0;
		_radNumber = 1 + (_this select 1);
		_minDist = 100000;
		{
			_safePos = _x select 1;
			_safeRad = _x select _radNumber;
			_dist = (_obj distance _safePos) - _safeRad;
			if (_dist < _minDist) then {
				_minDist = _dist;
				_tName = _x select 0;
				_tPos = _x select 1;
				_tRad = _safeRad;
			};
		} forEach donn_traders;
		[_minDist,_tName,_tPos,_tRad]
	};

	//SAFEZONE ENTER AND EXIT
	[] spawn {
		_maxVel = 80;
		while {true} do {
			//CHECK IF IN SAFE
			_result = [player,1] call donn_calcSafe;_minDist = _result select 0;
			while {_minDist > 0} do {
				uiSleep (((_minDist/_maxVel) max 1) min 10);
				_result = [player,1] call donn_calcSafe;
				_minDist = _result select 0;
			};
			
			//SAFE ON
			donn_InSafeZone = true;
			donn_inSafeCounter = donn_inSafeCounter + 1;
			systemChat "You are in the Safe Zone...";
			player_zombieCheck = {};
			fnc_usec_unconscious = {};
			fnc_usec_damageHandler_timer = 0;
			fnc_usec_damageHandler = {
				_attacker = _this select 3;
				if (!isNull _attacker) then {
					if (isPlayer _attacker) then {
						if (time - fnc_usec_damageHandler_timer > 2) then {
							fnc_usec_damageHandler_timer = time;
							[nil,_attacker,"loc",rHINT,"This player have God Mode!"] call RE;
						};
					};
				};
				_damage = 0;
				_damage
			};
			player_fired = {deleteVehicle (_this select 6);};
			player setCaptive true;
			inSafeZone = true; //INFISTAR FIRED EH RELATED
			_veh = vehicle player;
			if (_veh != player) then {
				donn_incarWas = donn_incarWas + [_veh];
				_veh addEventHandler ["Fired",{deleteVehicle (_this select 6);}];
				if (player == driver _veh) then {
					_veh setVariable ['don_owner',driver _veh,true];
				};
			};
			
			//CHECK IF LEAVED FROM SAFE
			_tPos = _result select 2;
			_tRad = _result select 3;
			_dist = player distance _tPos;
			while {_dist < _tRad} do {
				uiSleep 1;
				_dist = player distance _tPos;
			};

			//LEAVED SAFE
			donn_InSafeZone = false;
			systemChat "You leaved the Safe Zone...";
			donn_inSafeCounter spawn {
				_inSafeIndex = _this;
				_unGod = true;
				for "_c" from 0 to 5 do {
					_sleep = 10;
					if (vehicle player != player) then {_sleep = 5;};
					systemChat ("God Mode ends in " + str (_sleep*6-_c*_sleep) + "/" + str (_sleep*6) + " seconds.");
					uiSleep _sleep;
					if (donn_InSafeZone || _inSafeIndex != donn_inSafeCounter) exitWith {
						_unGod = false;
					};
				};
				if (_unGod) then {
					systemChat "God Mode ended!";
					player_zombieCheck = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_zombieCheck.sqf";
					fnc_usec_unconscious = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_unconscious.sqf";
					fnc_usec_damageHandler = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_damageHandler.sqf";
					player_fired = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_fired.sqf";
					player setCaptive false;
					inSafeZone = false; //INFISTAR FIRED EH RELATED
					{
						_x removeAllEventHandlers "Fired";
						_inSafe = ([_x,1] call donn_calcSafe) select 0 < 0;
						if (!_inSafe) then {
							_ownerSet = !isNull (_x getVariable ['don_owner',objNull]);
							if (_ownerSet) then {
								_x setVariable ['don_owner',objNull,true];
							};
						};
					} forEach donn_incarWas;
					donn_incarWas = [];
				};
			};
		};
	};
	
	//IN BUILD ZONE CHECK
	[] spawn {
		_maxVel = 50;
		while {true} do {
			_result = [player,2] call donn_calcSafe;
			_minDist = _result select 0;
			while {_minDist > 0} do {
				uiSleep (((_minDist/_maxVel) max 2) min 10);
				_result = [player,2] call donn_calcSafe;
				_minDist = _result select 0;
			};
			donn_canbuild = false;
			systemChat "Your are in the NoBuild zone...";
			_tPos = _result select 2;
			_tRad = _result select 3;
			_dist = player distance _tPos;
			while {_dist < _tRad} do {
				uiSleep 2;
				_dist = player distance _tPos;
			};
			donn_canbuild = true;
			systemChat "You leaved the NoBuild zone...";
		};
	};
	
	//ENTERING VEHICLES PROTECTION
	don_incar = false;
	[] spawn {
		while {true} do {
			waitUntil {uiSleep 1;don_player_veh = vehicle player;don_player_veh != player};
			don_incar = true;
			don_player_veh_isAir = don_player_veh isKindOf "Air"; //NOT NECESSARY
			if (donn_InSafeZone) then {
				_don_veh_owner = don_player_veh getVariable ['don_owner',objNull];
				if (isNull _don_veh_owner) then {
					don_player_veh setVariable ['don_owner',player,true];
					_don_veh_owner = player;
				};
				_ownerGroup = units group _don_veh_owner;
				_ownerGroupTag = _don_veh_owner getVariable ["friendlies",[]];
				_playerID = player getVariable ["CharacterID","0"];
				if (player in _ownerGroup || _playerID in _ownerGroupTag) then {
					if !(don_player_veh in donn_incarWas) then {
						donn_incarWas = donn_incarWas + [don_player_veh];
						don_player_veh addEventHandler ["Fired",{deleteVehicle (_this select 6);}];
					};
				} else {
					player action ['getOut', don_player_veh];
				};
			};
			waitUntil {uiSleep 1; vehicle player != don_player_veh};
			don_incar = false;
		};
	};
	
	//GEAR PROTECTION
	[] spawn {
		while {true} do {
			_playerID = player getVariable ["CharacterID",0];
			if (donn_InSafeZone) then {
				if (!don_incar) then {
					//CHECK NEAR PLAYERS AND VEHICLES
					_nearP = [];_nearV = [];
					{
						if (isPlayer _x && _x != player) then {_nearP = _nearP + [_x];};
					} forEach (player nearEntities ['CAManBase',4]);
					_countNear = count _nearP;
					{
						if (player distance _x < ((sizeOf typeOf _x)/2) + 3) then {_nearV = _nearV + [_x];};
					} forEach (player nearEntities [['LandVehicle','Air','Ship'],25]);
					_countNear = _countNear + count _nearV;
					//CHECK IF ALL ARE FRIENDLY
					_friends = units group player;
					if (_countNear > 0) then {
						_countNearF = {_x in _friends || _playerID in (_x getVariable ["friendlies",[]])} count _nearP;
						_countNearF = _countNearF + ({_owner = _x getVariable ['don_owner',objNull];_owner in _friends || _playerID in (_owner getVariable ["friendlies",[]])} count _nearV);
						if (_countNear > _countNearF && !isNull findDisplay 106) then {
							(findDisplay 106) closedisplay 0;
							closeDialog 0;closeDialog 0;closeDialog 0;
							cutText [format['%1. You is near a stranger player or vehicle and cant access gear now.',name player],'PLAIN'];
						};
					};
				};
				uiSleep 0.25;
			} else {
				uiSleep 2;
			};
		};
	};
	
	//LOG INFO
	diag_log "[ANDRE SAFEZONES] SCRIPT LOADED OK!";
};

 

NO-BUILD ZONES 1 - NO GENERAL BUILD

You must have a custom player_build.sqf. On your custom player_build.sqf, search for this code:

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

Bellow it, add this code:

	// No buildings arround safe zones (no-build zones)
	if(!donn_canbuild) then { _cancel = true; _reason = "\nCannot build on the no-build zone!"; }; //DONN

 

NO-BUILD ZONES 2 - NO SAFE PLACEMENT

You must have a custom vault_pitch.sqf. On your custom vault_pitch.sqf, search for this code:

// Make sure vault is not placed on road. 
if (isOnRoad _vault_location) then { _isOk = true; };

Bellow it, add this code:

// Make sure vault are not placed arround safe zones (no-build zones)
if(!donn_canbuild) then { _isOk = true; };

Search this code more to the end of the file:

cutText [(localize "str_epoch_player_110"), "PLAIN DOWN"];

Change it to:

//cutText [(localize "str_epoch_player_110"), "PLAIN DOWN"];
cutText ["You can''t place safes on the roads or no-build zones!", "PLAIN DOWN"];

 

CONFIGURATION ON andre_safezone.sqf

Search for this code bellow in andre_safezone.sqf, here you need to add the safezones of your map. Default is Chernarus, if you use another map, change it to your safezones.

	donn_traders = [
		["Safe 1",[6325,7807,0],160,500],
		["Safe 2",[4063,11664,0],160,500],
		["Safe 3",[11447,11364,0],160,500],
		["Safe 4",[1606,7803,0],160,500],
		["Safe 5",[12944,12766,0],160,500], 
		["Safe 6",[12060,12640,0],160,500]
	];

Each line contain one safe zone: [Name of the Safe, position of the safe, safe zone radius, no-build zone radius

The name of the safezones is just to organize things better, it does not appears on the enter/leave safezone message.

 

BE FILTERS

None needed.

Edited by Donnovan
Link to comment
Share on other sites

FEATURES FROM HELL SPAWN

- COMPATIBLE WITH INFISTAR

- COMPATIBLE WITH DZGM

- PEOPLE TAGGED AS FRIENDLY OR IN YOUR GROUP (DZGM) CAN ACCESS YOUR GEAR

- PEOPLE TAGGED AS FRIENDLY OR IN YOUR GROUP (DZGM) CAN ACCESS YOUR CAR & CAR GEAR

- A CAR IS YOURS IF YOU ENTERED THE SAFEZONE DRIVING IT

- NO BUILD ZONES ARROUND SAFEZONES

 

INSTALLATION

Put the file andre_safezone.sqf in you mission file.

Add to your init.sqf the line: execVM "andre_safezone.sqf";

 

THE SCRIPT

Download Link: ...

 

BE FILTERS

None.

 

MORE INFO

Please ask bellow.

 

ANOTHER SAFEZONE FOR ARMA 2?

Yes. This one is better, more optimized and less complicated. Its better than the Andre Safezones for Arma 3 and Gebriel Safezones for Arma 2.

 

THANKYOU

Thankyou for the donations, i apreciate. For this one please wait the download link.

Where andre_safezone.sqf ??

Link to comment
Share on other sites

Instead of creating another SafeZone script with Loops 'n Stuff, that is really unecessary, why not update existing Triggers from the mission.sqm, to safe some Loops and with it safe Ram?

Link to comment
Share on other sites

NEXT UPDATE

Vehicle Crash Protection.

 

WHAT IS THAT?

Vehicles from enemies are protected against crash.

 

HOW THIS WILL HELP?

Helis, for example, still explode if you crash on it, even with god mode. This update will avoid that.

 

THIS WILL HELP IN ANY OTHER WAY?

Yes. The server will have less cases of "X destroyed my Heli full of loot in the safe zone!".

 

ALL VEHICLES ARE PROTECTED?

No, just vehicles inside a safezone that is not yours and is not from one of your friends (tagged as friend or in the same DZGM group).

Link to comment
Share on other sites

Thanks works well!

Here are the cords for Chernarus;

//===============
// CONFIGURATION
//===============
 
//Chernarus Safezones
donn_traders = [
["Stary",[6325.6772,7807.7412,0]],
["Bash",[4063.4226,11664.19,0]],
["Klen",[11447.472,11364.504,0]],
["Bandit Vendor",[1606.6443,7803.5156,0]],
["Hero Vendor",[12944.227,12766.889,0]], 
["Airplane Dealer",[5068.6636,9723.4248,0]],
["Wholesaler",[1093.76,2844.97,0]],
["Boat Dealer",[8388.65,2373.57,0]],
["Wholesaler",[13272.7,6096.64,0]],
["Boat Dealer",[13084.4,8253.4,0]]
];

 

Looking forward to Crash protection.

Link to comment
Share on other sites

  • 4 months later...

I finally fully compreend how event handlers work.

This made me possible to make a 100% exact safezone for Arma 2 Epoch.

No one really will be able to shot from any vehicle inside the safe.

Vehicle god mode is exact as that, it will always be turned for any player to any vehicle (not abandoned vehicles).

Protect a player is simple, because the player is allways hosted on the same machine. Vehicles, on the other hand, can be hosted by the server or by any player, an the hoster can change during the game play. This make vehicle protection (god mode and "unable to shot") more complex.

All mastered now.

It's perfect, with 30 seconds god mode for player that exit the safezone in a vehicle and 60 seconds for the ones on foot. Ajustable if the player goes inside a vehicle or leave his vehicle.

It have 1 Monster Plus: No-Build zones.

Do you want the better safezone Epoch has ever seen?

Fully compatible with infiStar and ultra easy instalation. No BE filters needed.

Link to comment
Share on other sites

Tang0, your infiStar is old? Last version? Recent but not last?

You know if infiStar is kicking because i made player_zombieCheck = {}?

This is why you is asking for zombie deletion?

May infiStar is a bit old, and it's working correctly.

Edited by Donnovan
Link to comment
Share on other sites

changed player_zombieCheck = False and it fixed the kick problem thnx 

One of my players found a problem, if he leaves a vehicle in the safezone and is killed outside somewhere, when he respawns and comes back for the vehicle he can no long get into it (thinks its not his) , i cant get into it either except for a split second where i can tp it out of the zone and he can then enter it , any solution to that problem?

Also, even though the zombies do nothing to players in the safezone there can be alot of them there depending on amount of players, would be good if all zeds where deleted in safezone (or tp away as in plotpole script) + if any Ai that enter could be deleted as well (this happens in infistars safezone script)

 

Thnx for the script, i like it alot

Link to comment
Share on other sites

Players in safezone are in captive mode (player setCaptive true;) so AI will not mess with then.

If the player dies, the vehicle is liberated, so if someone enter the vehicle, he will be the new owner of the vehicle.

Are you sure no one entered the vehicle before he was able to get back to it?

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
  • Advertisement
×
×
  • Create New...