Jump to content

1.6 Safezone


juandayz

Recommended Posts

I JUST LEAVE THIS ONE CUZ I KNOW YOU GUYS GONNA NEED IT..

 

The very old safezone script by infistar... i was using it in 1.0.5.1  and made some changes to use in 1.6.

Instructions:
    1. Copy paste the code of below into a file called 16_safezone.sqf - save the file.
    2. Paste this 16_safezone.sqf into mpmissioms\instance_11.chernarus\custom\
    3. Open your init.sqf
    4. At the very bottom of the file add this line:  [] execVM "custom\16_safezone.sqf";
    5. Save the init.sqf and restart your server.

    6-WARNING!!! if ure using some kind of mod that allow vehicles with GodMode out of safezones..  then you will need in 16_safezone.sqf change the path for veh_handleDam.sqf by the path that youre using your custom veh_handleDam.sqf

this line:  fnc_veh_handleDam = compile preprocessFileLineNumbers '\z\addons\dayz_code\compile\veh_handleDam.sqf';

    16_safezone.sqf

Spoiler

/*
   by: http://infiSTAR.de || http://DayzAntiHack.com
   *updated on 13.12.2016 by juandayz for epoch 1.6 community
    //all credits for infi   

How i install it?
    1. Copy paste the code of below into a file called 16_safezone.sqf - save the file.
    2. Paste this 16_safezone.sqf into mpmissioms\instance_11.chernarus\custom\
    3. Open your init.sqf
    4. At the very bottom of the file add this line:  [] execVM "custom\16_safezone.sqf";
    5. Save the init.sqf and restart your server.
*/
USE_CANBUILD = false;        // if you don't want to define your own positions
USE_TraderCity = false;    //    if you don't want to define your own positions (Epoch 1.0.5)
USE_POSITIONS = true;    // to use own positions and radius
USE_AI_REMOVER = false;    // use this to remove Missionbots (AI) within 100m of a player if the player is in a SafeZone
USE_AntiSteal = true;    // use this to block opening gear if another player is within 3m!
USE_SPEEDLIMIT = true;    // very secret function, nobody is supposed to find out what it does.
    SPEEDLIMIT = 25;        // Only used if USE_SPEEDLIMIT is true.
USE_SIGNS = false;        // use this to build signs around the SafeZone
LOG_EnterLeave = true;    // This will log to your .rpt when a player enters or leaves a SafeZone! (only works with infiSTAR.de Admintools / AntiHack)
/* You can use USE_CANBUILD or/and (works together) the custom positions below (USE_POSITIONS) [position or zone,radius] */
_infiSZ =
[
    [[6325.6772,7807.7412,0],150,true],//stary
    [[4063.4226,11664.19,0],150,true],//bash
    [[11447.472,11364.504,0],150,true],//klen
    [[1606.6443,7803.5156,0],150,true],//bandit
    [[12944.227,12766.889,0],150,true],//hero
    [[4361.4937,2259.9526,0],50,true],//wholesalerSouth
    [[12060,12640,0],200,true]//air dealear
];

{
	DZE_SafeZonePosArray set [(count DZE_SafeZonePosArray), [(_x select 0), (_x select 1)]];
} forEach _infiSZ;

if (isServer) exitWith


{
    if (USE_SIGNS) then
    {
        {
            _center = _x select 0;
            _radius = _x select 1;
            _lSign = _x select 2;
            if (_lSign) then
            {
                for '_i' from 0 to 360 step (270 / _radius)*2 do
                {
                    _location = [(_center select 0) + ((cos _i) * _radius), (_center select 1) + ((sin _i) * _radius),0];
                    _dir = ((_center select 0) - (_location select 0)) atan2 ((_center select 1) - (_location select 1));
                    _object = createVehicle ['Sign_sphere100cm_EP1', _location, [], 0, 'CAN_COLLIDE'];
                    //    _object = createVehicle ['SignM_FARP_Winchester_EP1', _location, [], 0, 'CAN_COLLIDE'];
                    //    _object setVehicleInit 'this setObjectTexture [0,''Addons\SafeZones\sign.paa''];';
                    _object setDir _dir;
                };
            };
        } forEach _infiSZ;
    };
};
waitUntil {((!isNil 'dayz_animalCheck') || (!isNil 'dayz_medicalH') || (!isNil 'dayz_slowCheck') || (!isNil 'dayz_gui'))};
if (isNil 'inSafeZone') then { inSafeZone = false; } else { if (typename inSafeZone != 'BOOL') then { inSafeZone = false; }; };
[_infiSZ] spawn {
    _infiSZ = _this select 0;
    _startSafeZone =
    {
        if (isNil 'outNow') then
        {
            _msg = 'You entered a Safe Zone!';
            hint _msg;
            taskHint [_msg, [0,1,0,1], 'taskDone'];
            inNow = nil;
            outNow = true;
            
            if (LOG_EnterLeave) then
            {
                PVDZ_send = [player,'SafeZoneState',[1]];
                publicVariableServer 'PVDZ_send';
            };
        };
        player_fired = {
            deleteVehicle (nearestObject [_this select 0,_this select 4]);
            cutText ['You can not fire in a SafeZone!','WHITE IN'];
        };
        //wild_spawnZombies = {};
        zombie_generate = {};
        
        fnc_usec_damageHandler = {};
        player removeAllEventHandlers 'handleDamage';
        player addEventHandler ['handleDamage', {false}];
        player allowDamage false;
        _veh = vehicle player;
        _szs = _veh getVariable ['inSafeZone',0];
        if (_szs == 0) then
        {
            _veh setVariable ['inSafeZone',1,true];
            if (player != _veh) then
            {
                _veh removeAllEventHandlers 'Fired';
                _veh addEventHandler ['Fired', {_this call player_fired;}];
                {
                    _x removeAllEventHandlers 'Fired';
                    _x addEventHandler ['Fired', {_this call player_fired;}];
                } forEach (crew _veh);
                fnc_veh_handleDam = {false};
                _veh removeAllEventHandlers 'HandleDamage';
                _veh addeventhandler ['HandleDamage',{ _this call fnc_veh_handleDam } ];
                _veh allowDamage false;
            };
        };
        _notInSafeZone =
        [
    
            'MAAWS','RPG7V','M136','RPG18','STINGER',
            'MeleeBaseball','MeleeHatchet','MeleeCrowbar','MeleeMachete','MeleeFishingPole','MeleeSledge',
            'MeleeBaseBallBatNails','MeleeBaseBallBatBarbed','MeleeBaseBallBat'
        ];
        _cwep = currentWeapon player;
        if (_cwep in _notInSafeZone) then
        {
            _swep = '';
            {
                if ((getNumber (configFile >> 'CfgWeapons' >> _x >> 'Type')) == 2) exitWith
                {
                    _swep = _x;
                };
            } forEach (weapons player);
            if (_swep == '') then
            {
                player playActionNow 'PutDown';
                _iPos = getPosATL player;
                _radius = 1;
                _removed = ([player,_cwep,1] call BIS_fnc_invRemove);
                if (_removed == 1) then
                {
                    _item = createVehicle ['WeaponHolder', _iPos, [], _radius, 'CAN_COLLIDE'];
                    _item addWeaponCargoGlobal [_cwep,1];
                };
            }
            else
            {
                player selectweapon _swep;
            };
        };
    };
    _endSafeZone =
    {
        if (isNil 'inNow') then
        {
            if (str fnc_usec_damageHandler == '{}') then
            {
                _msg = 'You left the Safe Zone!';
                hint _msg;
                taskHint [_msg, [1,0,0.1,1], 'taskFailed'];
            };
            inNow = true;
            outNow = nil;
            
            if (LOG_EnterLeave) then
            {
                PVDZ_send = [player,'SafeZoneState',[0]];
                publicVariableServer 'PVDZ_send';
            };
        };
        //wild_spawnZombies = compile preprocessFileLineNumbers '\z\addons\dayz_code\compile\wild_spawnZombies.sqf';
        zombie_generate = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\zombie_generate.sqf";
        //
        
        player_fired = {
            _this call compile preprocessFileLineNumbers '\z\addons\dayz_code\compile\player_fired.sqf';
            _unit = _this select 0;
            _weapon = _this select 1;
            _muzzle = _this select 2;
            _mode = _this select 3;
            _ammo = _this select 4;
            _magazine = _this select 5;
            _projectile = _this select 6;
            _screenToWorld = screenToWorld [0.5,0.5];
            _near = _screenToWorld nearEntities ['AllVehicles',100];
            {
                if (isPlayer _x) then
                {
                    _szs = _x getVariable ['inSafeZone',0];
                    if (_szs == 1) then
                    {
                        deleteVehicle (nearestObject [_unit,_ammo]);
                    };
                };
            } forEach _near;
        };
        
        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';
        fnc_veh_handleDam = compile preprocessFileLineNumbers '\z\addons\dayz_code\compile\veh_handleDam.sqf';
        
        _veh = vehicle player;
        _szs = _veh getVariable ['inSafeZone',0];
        if (_szs == 1) then
        {
            _veh setVariable ['inSafeZone',0,true];
            if (player != _veh) then
            {
                _veh removeAllEventHandlers 'HandleDamage';
                _veh addeventhandler ['HandleDamage',{ _this call fnc_veh_handleDam } ];
                _veh allowDamage true;
            };
        };
        
        _end = false;
        if (isNil 'gmadmin') then
        {
            _end = true;
        }
        else
        {
            if (gmadmin == 0) then
            {
                _end = true;
            };
        };
        if (_end) then
        {
            player allowDamage true;
            fnc_usec_damageHandler = compile preprocessFileLineNumbers '\z\addons\dayz_code\compile\fn_damageHandler.sqf';
            player removeAllEventHandlers 'HandleDamage';
            player addeventhandler ['HandleDamage',{_this call fnc_usec_damageHandler;} ];
        };
    };
    while {1 == 1} do
    {
        if (isNil 'inSafeZone') then { inSafeZone = false; } else { if (typename inSafeZone != 'BOOL') then { inSafeZone = false; }; };
        _state = false;
        if (isNil 'USE_POSITIONS') then { USE_POSITIONS = false; } else { if (typename USE_POSITIONS != 'BOOL') then { USE_POSITIONS = false; }; };
        if (USE_POSITIONS) then
        {
            {
                _z = _x select 0;
                _r = _x select 1;
                if ((vehicle player) distance _z < _r) then {_state = true;};
            } forEach _infiSZ;
        };
        if (isNil 'USE_CANBUILD') then { USE_CANBUILD = true; } else { if (typename USE_CANBUILD != 'BOOL') then { USE_CANBUILD = true; }; };
        if (USE_CANBUILD) then
        {
            if (isNil 'canbuild') then { canbuild = true; } else { if (typename canbuild != 'BOOL') then { canbuild = true; }; };
            if (!canbuild) then {_state = true;};
        };
        if (isNil 'USE_TraderCity') then { USE_TraderCity = true; } else { if (typename USE_TraderCity != 'BOOL') then { USE_TraderCity = true; }; };
        if (USE_TraderCity) then
        {
            if (isNil 'isInTraderCity') then { isInTraderCity = false; } else { if (typename isInTraderCity != 'BOOL') then { isInTraderCity = false; }; };
            if (isInTraderCity) then {_state = true;};
        };
        if (_state) then
        {
            inSafeZone = true;
            call _startSafeZone;
            {
                if (!isNull _x) then
                {
                    if !(isPlayer _x) then
                    {
                        deletevehicle _x;
                    };
                };
            } forEach ((vehicle player) nearEntities ['zZombie_Base',50]);
            
            if (isNil 'USE_AI_REMOVER') then { USE_AI_REMOVER = false; } else { if (typename USE_AI_REMOVER != 'BOOL') then { USE_AI_REMOVER = false; }; };
            if (USE_AI_REMOVER) then
            {
                {
                    if ((!isNull group _x) && (getPlayerUID _x == '')) then
                    {
                        deleteVehicle _x;
                    };
                } forEach (player nearEntities ['Man',100]);
            };
        }
        else
        {
            inSafeZone = false;
        };
        uiSleep 2;
        if (!inSafeZone) then
        {
            call _endSafeZone;
        };
    };
};
if ((USE_AntiSteal) || (USE_SPEEDLIMIT)) then
{
    [] spawn {
        _USE_AntiSteal = USE_AntiSteal;
        _USE_SPEEDLIMIT = USE_SPEEDLIMIT;
        _speedlimit = SPEEDLIMIT;
        while {1 == 1} do
        {
            if (inSafezone) then
            {
                if (_USE_AntiSteal) then
                {
                    _cnt = {isPlayer _x && _x != player} count (player nearEntities [['CAManBase'],4]);
                    if ((_cnt > 0) && (!isNull (findDisplay 106))) then
                    {
                        (findDisplay 106) closedisplay 0;
                        closeDialog 0;closeDialog 0;closeDialog 0;
                        _log = format['%1 You are not allowed to open Gear while near another player!',name player];
                        cutText [_log,'PLAIN'];
                        hint _log;
                    };
                };
                if (_USE_SPEEDLIMIT) then
                {
                    _obj = vehicle player;
                    if !(_obj isKindOf 'Plane') then
                    {
                        _speed = abs speed _obj;
                        if ((_obj != player) && (_speed > _speedlimit)) then
                        {
                            _vel = velocity _obj;
                            _x = 0.8;
                            if (_speed > 50) then {_x = 0.1;};
                            _velNew = [(_vel select 0) * _x, (_vel select 1) * _x,(_vel select 2) * _x];
                            _obj SetVelocity _velNew;
                        };
                    };
                };
            }
            else
            {
                uiSleep 2;
            };
            uiSleep .01;
        };
    };
}; 

 

 

 

OPTIONAL:

@BetterDeadThanZed here you got.

REMOVE LOOT FROM TRADER CITIES AND PLOT POLES. (should removes zeds from trader places and poles too)

Spoiler

1-Open your custom compiles.sqf and into !dedicated section paste this call.


player_spawnCheck = compile preprocessFileLineNumbers "dayz_code\compile\player_spawnCheck.sqf";//remove loot from safezones

2-Copy player_spawnCheck.sqf from your \@DayZ_Epoch\addons\dayz_code.pbo\compile\   to mpmissions\your instance\dayz_code\compile\

Spoiler

A-Find:



private ["_isWreck",

add:



"_findNearestPoles","_IsNearPlot",

so its looks:



private ["_isWreck","_findNearestPoles","_IsNearPlot",.............the rest of variables];

B-Find:



if (_canSpawn) then {

change by:



_findNearestPoles = nearestObjects[player, ["Plastic_Pole_EP1_DZ"], DZE_PlotPole select 0];
_IsNearPlot = count (_findNearestPoles);
if (_canSpawn && !isInTraderCity && (_IsNearPlot == 0)) then {

 

 

 

 

Link to comment
Share on other sites

Installed and seems to be working, Except players get these 2 messages when logging in and client rpts are flooded with this as well

 

Warning Message: Script z\addons\dayz_code\compile\wild_spawnZombies.sqf not found
Warning Message: Script z\addons\dayz_code\compile\vehicle_handleDamage.sqf not found

Link to comment
Share on other sites

yup daddy krop  i comment the part of wild zeds

 

   //wild_spawnZombies = {};

 //wild_spawnZombies = compile preprocessFileLineNumbers '\z\addons\dayz_code\compile\wild_spawnZombies.sqf';
 zombie_generate = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\zombie_generate.sqf";
       

also PVDZE_send do not exist anymore . now is PVDZ_send

Link to comment
Share on other sites

39 minutes ago, houst said:

its all scripted on my server...when i enter safezone i get no notification of bein gin safezone and people can still die lol even zeds attack hehehe

 

but ure using the code in main post? or the old code.. cuz i dont have your problem.

check the coords .. its for chernarus map

Spoiler

 [[6325.6772,7807.7412,0],150,true],//stary
    [[4063.4226,11664.19,0],150,true],//bash
    [[11447.472,11364.504,0],150,true],//klen
    [[1606.6443,7803.5156,0],150,true],//bandit
    [[12944.227,12766.889,0],150,true],//hero
    [[4361.4937,2259.9526,0],50,true],//wholesalerSouth
    [[12060,12640,0],200,true]//air dealear

 

Link to comment
Share on other sites

1 hour ago, houst said:

im using it for Sauerland...... might be easier if some1 else has 1 set up for sauerland with the proper co ords...or does anyone know sauerlands cords for each trader??

 

ty

hers the coords for sauderland

			position[]={15487,87,17015};
			name="NeutralTraderCity";


			position[]={24713,409,21741};
			name="FriendlyTraderCity";
			
		
			position[]={11046,179,15669};
			name="HeroVendor";
			
			
			position[]={15350,112,18522};
			name="UnarmedAirVehicles";
			
		
			position[]={2507,271,3870};
			name="SouthWholesaler";
			
			position[]={223,139,22703};
			name="NorthWholesaler";
			
			position[]={16894,0,1781};
			name="BanditVendor";
			
		
			position[]={13176,176,6614};
			name="NeutralTraderCIty2";
		

you need to move middle coords to last place,, see this example:

position[]={15487,87,17015};
 name="NeutralTraderCity";

must be:

15487,17015,87

Link to comment
Share on other sites

4 minutes ago, houst said:

oh ok ill try that

 

here you got

 [[15487,17015,0],150,true],//NeutralTraderCity
    [[24713,21741,0],150,true],//FriendlyTraderCity
    [[11046,15669,0],150,true],//HeroVendor
    [[15350,18522,0],150,true],//UnarmedAirVehicles
    [[2507,3870,0],150,true],//SouthWholesaler
    [[223,22703,0],50,true],//wholesalerSouth
    [[16894,1781,0],150,true],//BanditVendor
	[[13176,6614,0],150,true]//NeutralTraderCIty2
];

 

Link to comment
Share on other sites

Juandayz

it is sorted...thank you very much :)  all zones work :)

 

next on my list is trying to get items added to traders....  you dont by any chance have a trader list with more items listed than what you get as default??

 

ive tried adding my items to 2 different trade rlists i com eacross but i don tsee them in game...

 

 

Link to comment
Share on other sites

36 minutes ago, houst said:

Juandayz

it is sorted...thank you very much :)  all zones work :)

 

next on my list is trying to get items added to traders....  you dont by any chance have a trader list with more items listed than what you get as default??

 

ive tried adding my items to 2 different trade rlists i com eacross but i don tsee them in game...

 

 

take a look here...

for sauderland its the same

Link to comment
Share on other sites

Sorry guys where are you putting this lump of code? I'm only asking because it's commented out

Quote

*/
USE_CANBUILD = false;        // if you don't want to define your own positions
USE_TraderCity = false;    //    if you don't want to define your own positions (Epoch 1.0.5)
USE_POSITIONS = true;    // to use own positions and radius
USE_AI_REMOVER = false;    // use this to remove Missionbots (AI) within 100m of a player if the player is in a SafeZone
USE_AntiSteal = true;    // use this to block opening gear if another player is within 3m!
USE_SPEEDLIMIT = true;    // very secret function, nobody is supposed to find out what it does.
    SPEEDLIMIT = 25;        // Only used if USE_SPEEDLIMIT is true.
USE_SIGNS = false;        // use this to build signs around the SafeZone
LOG_EnterLeave = true;    // This will log to your .rpt when a player enters or leaves a SafeZone! (only works with infiSTAR.de Admintools / AntiHack)
/* You can use USE_CANBUILD or/and (works together) the custom positions below (USE_POSITIONS) [position or zone,radius] */

Its ok scrub that I miss read, been converting scripts for way to long now

Cheers

Link to comment
Share on other sites

On 14.12.2016 at 1:20 AM, juandayz said:

this is the very old safezone script by infistar... i was using it in 1.0.5.1  and made some changes to use in 1.6-

 i test everthing i can alone... so please test with other player to verify if everything is running  well. tnks to @wagnermelo remake it was his idea.

Thank you! Working.

Link to comment
Share on other sites

  • 2 weeks later...
7 minutes ago, Tullerusk said:

Didnt work for me.

sfq.pngPut the safezone.sfq in here.

init.pngAnd added the line at the very bottom of this init.sqf

 

Restarted server, logged in, nothing changed.

safezones works with coords... for example if u wanna use a safezone in an specific place then you need define here your coords.

_infiSZ =
[
    [[6325.6772,7807.7412,0],150,true],//stary
    [[4063.4226,11664.19,0],150,true],//bash
    [[11447.472,11364.504,0],150,true],//klen
    [[1606.6443,7803.5156,0],150,true],//bandit
    [[12944.227,12766.889,0],150,true],//hero
    [[4361.4937,2259.9526,0],50,true],//wholesalerSouth
    [[12060,12640,0],200,true]//air dealear
];

this coords are seted for chernarus11 map. so you need entry your coords.

you can find it in your mission.sqm  (mpmissions\your instance\ )

in class sensor sections.

heres my coords into mission.sqm

class Sensors
	{
		items=6;
#define TRGDEF a=100;b=100;activationBy="WEST";repeating=1;interruptable=1;age="UNKNOWN";class Effects{};
		class Item0
		{
			position[]={6325,304,7807};
			TRGDEF
			name="zonestary";
			expCond="(player distance zonestary) < 100;";
			expActiv="[""trader city Stary"",true,""enter""] call player_traderCity;";
			expDesactiv="[""trader city Stary"",true,""leave""] call player_traderCity;";
		};
		class Item1
		{
			position[]={4063,365,11664};
			TRGDEF
			name="zonebash";
			expCond="(player distance zonebash) < 100;";
			expActiv="[""trader city Bash"",true,""enter""] call player_traderCity;";
			expDesactiv="[""trader city Bash"",true,""leave""] call player_traderCity;";
		};
		class Item2
		{
			position[]={11447,317,11364};
			TRGDEF
			name="zoneklen";
			expCond="(player distance zoneklen) < 100;";
			expActiv="[""trader city Klen"",true,""enter""] call player_traderCity;";
			expDesactiv="[""trader city Klen"",true,""leave""] call player_traderCity;";
		};
		class Item3
		{
			position[]={1606,289,7803};
			TRGDEF
			name="zonebandit";
			expCond="(player distance zonebandit) < 100;";
			expActiv="[""Bandit Trader"",false,""enter""] call player_traderCity;";
			expDesactiv="[""Bandit Trader"",false,""leave""] call player_traderCity;";
		};
		class Item4
		{
			position[]={12944,210,12766};
			TRGDEF
			name="zonehero";
			expCond="(player distance zonehero) < 100;";
			expActiv="[""Hero Trader"",false,""enter""] call player_traderCity;";
			expDesactiv="[""Hero Trader"",false,""leave""] call player_traderCity;";
		};
		class Item5
		{
			position[]={12060,158,12638}; 
			TRGDEF
			name="zoneaircraft";
			expCond="(player distance zoneaircraft) < 100;";
			expActiv="[""Aircraft Trader"",false,""enter""] call player_traderCity;";
			expDesactiv="[""Aircraft Trader"",false,""leave""] call player_traderCity;";
		};
	};
};

take a look on each position []  this giving you the coords. but you need move the last coord to the center, and the center coord at last.

example:

6325,304,7807

6325,7807,304

 

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