Jump to content

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


Recommended Posts

I figured it out.

When the player disconnect, his player obj became null, so the vehicle in the safezone lose his owner and became avaliable.

When the player dies, the player obj does not became null until the player body dissapear. So, while the player body is on the map, the car is owned by it.

Will fix that.

Edited by Donnovan
Link to comment
Share on other sites

First of all thanks Donnovan for this awesome script :)

My Co-Admin and me tested it intensively and we have only one last persistent problem. If the server restarts and the first player run into the safezone he doesn't have God Mode so it's possible to kill him. If he leaves the Safezone and runs again into it the God Mode works. After that everything worked fine until next restart. Always the first player who run into the safezone after restart has no God Mode until he leaves it and enters the safezone again. Is this problem known? How can I fix this? Thanks in advance.

Edit:

If anyone has the same problem just try this:

Change this line:

if (hasInterface) then {

To:

if (!isDedicated) then {

That solved it for me.

Greetings

 

 

Link to comment
Share on other sites

Hello i have also test this script verry hard. 

Its a really good script, verry verry thanks.

But i have see one Problem, can you help me or change this.

The Problem is the locked Vehicle have Godmode in the Safe Area, but Non Key vehicles have not Godmode.

When i shoot from Outside into the Safezone on a Non Key vehicle , i can destroy it.

 

Grezze

Edited by Tweety060286
Link to comment
Share on other sites

HI

it would be nice to add the ability infistar_safezone

1. USE_AI_REMOVER = true; // use this to remove Missionbots (AI) within 100m of a player if the player is in a safezone
2. LOG_EnterLeave = true; // it will log your .RPT when a player enters or leaves the safezone! (only works with infiSTAR.de admin tools / AntiHack)
/* You can use USE_CANBUILD or/and (collaborating) with custom positions below (USE_POSITIONS) [position or zone,radius] */
3. USE_SIGNS = true; // use this to build signs around the safezone

Link to comment
Share on other sites

  • 4 weeks later...

At first look it seems that AI ignores me after I've been inside a safezone. The 60 sec of godmode passed and I could kill them but they simply wouldn't react.

Need to test this out a bit more though

 

Edit: Only seems to partially happen when you arrive at the mission before the godmode runs out. The first one I tested didn't react at all the 2nd one did react properly.

Gonna test it out a bit more but so far really like it. Thanks for yet another awesome script. Really gotta get some money your way when I can

Link to comment
Share on other sites

Thankyou.

I beleive i need to reveal players to AI when players became hostile again or AI will not notice this change in player status.

{if (!isPlayer _x) then {_x reveal player;};} forEach (player nearEntities ["CAManBase",400]);

 

 

 

Link to comment
Share on other sites

  • 4 weeks later...

use sqf file

            //LEAVED SAFE
            donn_InSafeZone = false;
            systemChat (localize "STR_safezone_2");
            donn_inSafeCounter spawn {
                _inSafeIndex = _this;
                _unGod = true;
                for "_c" from 0 to 3 do {
                    _sleep = 10;
                    if (vehicle player != player) then {_sleep = 3;};
                    systemChat ("in " + str (_sleep*3-_c*_sleep) + "/" + str (_sleep*3) + " seconds.");
                    uiSleep _sleep;
                    if (donn_InSafeZone || _inSafeIndex != donn_inSafeCounter) exitWith {
                        _unGod = false;
                    };

use xml file

<?xml version="1.0" encoding="utf-8"?>
<Project name="dayz">
        <Package name="dayz">

                <Key ID="STR_safezone_2">
                        <Original>Leaving safe zone</Original>
                        <English>Leaving safe zone</English>
            <French>Laissant zone de sécurité</French>
            <German>Verlassen sichere Zone</German>
            <Portuguese>Saindo de zona segura</Portuguese>
                </Key>
        </Package>
</Project>

 

Auto detect languages cliente arma2

Link to comment
Share on other sites

  • 3 months later...
  • 3 months later...

hey man, sorry to necro such an old thread, but i just got into Arma2 dayz mod (well learning how to get a server up and rtunning), after getting bored with the SA edition (please don't hate me), just need to know if there is supposed to be a file/folder to download or do i just create the files from your texts? still new to all this but i'm loving the challenge, Overpoch is still too far over my head right now!

Link to comment
Share on other sites

  • 1 month later...
  • 7 months later...
On 3/4/2017 at 2:00 PM, SKS.Goliath said:

Please ask for an update  thx

try for 1.6

Spoiler

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 "PVDZ_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\veh_handleDam.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!";
};

 

 

Link to comment
Share on other sites

Spoiler

Error in expression <d;
};
} forEach donn_traders;
[_minDist,_tName,_tPos,_tRad]
};


[] spawn {
_max>
  Error position: <_tName,_tPos,_tRad]
};


[] spawn {
_max>
  Error Undefined variable in expression: _tname
File mpmissions\__CUR_MP.Chernarus\custom\safezone.sqf, line 47
Error in expression <getVariable ['don_owner',objNull]);
if (_ownerSet) then {
_x setVariable ['don_o>
  Error position: <_ownerSet) then {
_x setVariable ['don_o>
  Error Undefined variable in expression: _ownerset
File mpmissions\__CUR_MP.Chernarus\custom\safezone.sqf, line 131

Client side error running this

Link to comment
Share on other sites

@DieTanx  @SKS.Goliath

Spoiler

private ["_owner","_hasOwner","_this","_tName","_tPos","_tRad","_obj","_radNumber","_minDist","_safePos","_safeRad","_dist","_maxVel",
"_result","_attacker","_damage","_veh",""_inSafeIndex,"_unGod","_inSafe","_ownerSet","_don_veh_owner","_ownerGroup","_ownerGroupTag",
"_playerID","_nearP","_nearV","_countNear","_countNearF","_friends"];

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 "PVDZ_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\veh_handleDam.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!";
};

 

 

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