DayZ S.T Safezones

this is a safezone and anti theft script, i have no idea who originally wrote this and i cant remember where i got it from either and i have editied it a little since i got it
Code:
if (!isServer) then {
    if (isNil "SafeZoneClientCheck") then
    {
        SafeZoneClientCheck = true;
        [] spawn {
            waitUntil {alive player };
            waituntil {!isnull (finddisplay 46)};
            sleep 3;
            if (isNil "inSafezone") then {inSafezone = false;};
            [] spawn {
                while {true} do
                {
                    if ((vehicle player distance zonebash < 75) || (vehicle player distance zoneklen < 75) || (vehicle player distance zonestary < 75)) then
                    {
                        inSafeZone = true;
                        canbuild = false;
                        {
                            if (!isNull _x) then {
                                if !(isPlayer _x) then {
                                    deletevehicle _x;
                                };
                            };
                        } forEach (vehicle player nearEntities ["zZombie_Base",25]);
                    }
                    else
                    {
                        inSafeZone = false;
                        canbuild = true;
                    };
                    sleep 2;
                };
            };
            [] spawn {
                while {true} do
                {
                    sleep 0.5;
                    waitUntil {inSafeZone};
                    waitUntil {player == vehicle player};
                 
                    thePlayer = player;
                    _EH_Fired = player addEventHandler ["Fired",{
                        deleteVehicle (nearestObject [_this select 0,_this select 4]);
                    }];
                    player_zombieCheck = {};
                    player_fired = {};
                    fnc_usec_damageHandler = {};
                    fnc_usec_unconscious = {};
                    object_monitorGear = {};
                    player removeAllEventHandlers "handleDamage";
                    player addEventHandler ["handleDamage", {false}];
                    player allowDamage false;
                 
                    sleep 0.5;
                    waitUntil {((!inSafeZone) || (thePlayer != player))};
                 
                    player removeEventHandler ["Fired", _EH_Fired];
                    player_zombieCheck = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_zombieCheck.sqf";
                    player_fired = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_fired.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";
                    object_monitorGear = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\object_monitorGear.sqf";
                    player addEventHandler ["handleDamage", {true}];
                    player removeAllEventHandlers "handleDamage";
                    player allowDamage true;
                };
            };
            [] spawn
            {
                if (isNil "inSafezone") then
                {
                    inSafezone = false;
                };
                _ownGear = false;
                while {true} do
                {
                    if (inSafezone) then
                    {
                        _list = ({isPlayer _x} count (getPos vehicle player nearEntities [['AllVehicles'], 10])) - 1;
                        if (_list > 0) then
                        {
                            if( !isNull (FindDisplay 106) ) then
                            {
                                if( !_ownGear ) then
                                {
                                    player action ["GEAR", ""];
                                    systemchat "Other player within 10m can only access own gear";
                                    _ownGear = true;
                                };
                            }
                            else
                            {
                                if(_ownGear) then
                                {
                                    _ownGear = false;
                                };
                            };
                        };
                    };
                sleep 0.1;
                };
            };
        };
    };
};
save that as safezone.sqf and put it in your mission file
then in your init.sqf find

if (!isDedicated) then {

then just under that look for

_void = [] execVM "R3F_Realism\R3F_Realism_Init.sqf";

and add this line underneath it

_nul = [] execVM "safezone.sqf";
 
Back
Top