Safe Zones [Working]

Credit:
me-for this tutorial only
maca134-For the original epoch code!

Tutorial:
First you need to create a SQF called (safezone.sqf)
add inside:
Code:
Private ["_EH_Fired"];
 
if (isNil "inSafezone") then {
    inSafezone = false;
};
 
while {true} do {
    waitUntil { inSafeZone };
    titleText [format["Entering Safe Zone. Your weapons have been deactivated."],"PLAIN DOWN"]; titleFadeOut 4;
 
    waitUntil { player == vehicle player };
 
    thePlayer = vehicle player;
    _EH_Fired = thePlayer addEventHandler ["Fired", {
        titleText ["You can not fire your weapon in a safe zone.","PLAIN DOWN"]; titleFadeOut 4;
        NearestObject [_this select 0,_this select 4] setPos[0,0,0];
    }];
 
    player_zombieCheck = {};
    fnc_usec_damageHandler = {};
    fnc_usec_unconscious  = {};
    thePlayer removeAllEventHandlers "handleDamage";
    thePlayer addEventHandler ["handleDamage", {false}];
    thePlayer allowDamage false;
 
    waitUntil { !inSafeZone };
 
    titleText [format["Exiting Safe Zone. Your weapons have been reactivated."],"PLAIN DOWN"]; titleFadeOut 4;
    thePlayer removeEventHandler ["Fired", _EH_Fired];
 
    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";
    thePlayer addEventHandler ["handleDamage", {true}];
    thePlayer removeAllEventHandlers "handleDamage";
    thePlayer allowDamage true;
};

Next Open up Mission.sqm find this

Code:
        class Item1
        {
            side="LOGIC";
            class Vehicles
            {
                items=1;
                class Item0
                {
                    position[]={708.96582,35.858719,3533.1272};
                    id=50;
                    side="LOGIC";
                    vehicle="FunctionsManager";
                    leader=1;
                    lock="UNLOCKED";
                    skill=0.60000002;
                };
            };
        };
    };

Add This Below It

Code:
class Sensors
    {
    items=2;
    class Item0
        {
            position[]={11471,0,11333};
            ractivationBy="ANY";
            repeating=1;
            interruptable=1;
            age="UNKNOWN";
            name="trading_post1";
            expCond="(player distance trading_post1) < 80;";
            expActiv="inSafeZone = true;";
            expDesactiv="inSafeZone = false;";
        class Effects
        {
        };
    };
    class Item1
        {
            position[]={2035,0,11452};
            ractivationBy="ANY";
            repeating=1;
            interruptable=1;
            age="UNKNOWN";
            name="trading_post2";
            expCond="(player distance trading_post2) < 80;";
            expActiv="inSafeZone = true;";
            expDesactiv="inSafeZone = false;";
        class Effects
        {
        };
    };
};

EXPLINATION:

class Sensors
{
items=2; //number of items must be sequential
class Item0
{
position[]={11471,0,11333}; //position on the map x,z,y
ractivationBy="ANY"; //what sets it off
repeating=1; //too complicated
interruptable=1; //same as above :p
age="UNKNOWN"; //un-important but keep it
name="trading_post1"; //must be uniqe
expCond="(player distance trading_post1) < 80;"; //same as name //change distance
expActiv="inSafeZone = true;"; //leave
expDesactiv="inSafeZone = false;"; //leave
class Effects
{
};
};

Lastly you must find this in your init.sqf!

Code:
if (!isDedicated) then {
    //Auto Refuel
    [] execVM "scripts\kh_actions.sqf";
 
    //Conduct map operations
    0 fadeSound 0;
    waitUntil {!isNil "dayz_loadScreenMsg"};
    dayz_loadScreenMsg = (localize "STR_AUTHENTICATING");
 
    //Run the player monitor
    _id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
    _playerMonitor = [] execVM "\z\addons\dayz_code\system\player_monitor.sqf"; //old monitor
 
    //[] execVM "\z\addons\dayz_code\system\antihack.sqf";

Add this at the bottom!

Code:
    //Safe Zone
    [] execVM "scripts\safezone.sqf";
And your done with the Initial Install For Safe zones!

Tutorial For map Markers
First you Must Have this setup EXACTLY!​
Add this at the end of markers inside the mission.sqm:
Code:
class Item7
        {
            position[]={2035,0,11452};
            name="trading_post2_marker";
            text="Telpor Villiage Outpost"; //Currently Not working, working on a fix!
            markerType="ELLIPSE";
            type="Empty";
            colorName="ColorGreen";
            a=80; //same as sensors Radius
            b=80; //same as sensors Radius
        };

Next Change This

Code:
items=7;

To This

Code:
items=8; // must be sequential

Thanks to all those who helped get this working!
 
Back
Top