Pavillin Posted March 20, 2016 Report Share Posted March 20, 2016 There are many safezone scripts out there. I'm building a new server and I'm not sure what safezone script is the best. could some people maybe recommend some with their pros/cons Link to comment Share on other sites More sharing options...
1 juandayz Posted March 21, 2016 Report Share Posted March 21, 2016 Spoiler /* by: http://infiSTAR.de || http://DayzAntiHack.com *updated on 24.12.2014 Instructions: 1. Copy paste this pastebin code into a file called SafeZone.sqf - save the file. 2. Now extract your mpmission pbo and put the SafeZone.sqf into the extracted folder. 3. Open the init.sqf of the mpmission. 4. At the bottom of the file add [] execVM 'SafeZone.sqf'; 5. Save the init.sqf, repack your mpmission, upload it to your gameserver and restart your server */ USE_CANBUILD = true; // if you don't want to define your own positions USE_TraderCity = true; // 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 = 20; // Only used if USE_SPEEDLIMIT is true. USE_SIGNS = false; // use this to build signs around the SafeZone LOG_EnterLeave = false; // 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 = [ [[9457.1514,-1.5258789e-005,0],150,true], //central market [[6771.8657,-3.0517578e-005,0],150,true], //antena4 [[11465.639, 11338.997,0],15,true], //church [[7989.3354,0.30462033,0],150,true], //boat dealer [[2012.7314, 2239.406,0],20,true], // stop1 [[1654.3103, 3982.2517,0],20,true], // stop2 [[3172.387, 5504.9888,0],20,true], // stop3 [[5029.77, 6799.0449,0],20,true], // stop4 [[6597.1426, 5993.7129,0],20,true], // stop5 [[7621.1313, 4929.731,0],20,true], // stop6 [[10133.931, 5391.4771,0],20,true], // stop7 [[10250.539, 3179.3486,0],20,true], // stop8 [[8216.2822, 3082.3098,0],20,true] // stop9 ]; 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 = 'Zona Neutral!'; hint _msg; taskHint [_msg, [0,1,0,1], 'taskDone']; inNow = nil; outNow = true; if (LOG_EnterLeave) then { PVDZE_send = [player,'SafeZoneState',[1]]; publicVariableServer 'PVDZE_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); vehicle_handleDamage = {false}; _veh removeAllEventHandlers 'HandleDamage'; _veh addeventhandler ['HandleDamage',{ _this call vehicle_handleDamage } ]; _veh allowDamage false; }; }; _notInSafeZone = [ 'MAAWS','RPG7V','M136','RPG18','STINGER', 'MeleeHatchet_DZE','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 = 'Fuera de la Zona Segura!'; hint _msg; taskHint [_msg, [1,0,0.1,1], 'taskFailed']; }; inNow = true; outNow = nil; if (LOG_EnterLeave) then { PVDZE_send = [player,'SafeZoneState',[0]]; publicVariableServer 'PVDZE_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'; vehicle_handleDamage = compile preprocessFileLineNumbers '\z\addons\dayz_code\compile\vehicle_handleDamage.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 vehicle_handleDamage } ]; _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; }; }; }; i using it. and works fine.(u need change coords for your safezones) an other script to remove vehicles in safezones. Spoiler /* VEHICLE CLEANUP ZONE Script by HALV */ _obj = _this select 0; if (!isServer) exitWith {diag_log "Server_DeleteObjInsafezone.sqf - ERROR: NOT SERVER?"}; //\\\\\\\\\\\\\\\\\\\\ Setup Area ////////////////////\\ //vehicle types to Check for _delVeh = ["Air","Landvehicle","Ship","Tank"]; //Action to take when vehicle is detected in a [VEHICLE CLEANUP ZONE] //0 Delete vehicles ingame but keep in database. NOTE: This will stack vehicles in database if not cleaned propper //1 Tp vehicles outside [VEHICLE CLEANUP ZONE] ("radius" + 10 meter to 4x "radius" from VEHICLE CLEANUP ZONE pos eg: if radius is 100 vehicles are moved 150-400 meter away) //2 Tp vehicles to a position within 125m of _safespot (remember to set a position below) //3 will delete vehicles completly from database _Action = 1; //if _Action = 2 then enter the position you desire here (default is by grozovoy pass around 022010) _safespot = [2283.19,14255,0]; //how large radius to spread them in this area in meters (default 125m) _radius = 125; //damaged above this amoun, vehicle is deleted (set to 1 to only delete completely destroyed vehicles) _dam = 0.90; //if true will delete vehicles matching array below by default _delbikmot = true; //if above is true will delete these by default _defdelar = ["Bicycle","Motorcycle","CSJ_GyroC","CSJ_GyroCover","CSJ_GyroP"];//,"ATV_Base_EP1" //set to true, to unlock vehicles by default when TP'ed _unlock = true; //log text, this is what you want to look for in the logs, if you need to know something about a moved vehicle _txt = "[VEHICLE CLEANUP ZONE]"; //Update vehicles to the hive, and make sure they are not moved each restart? _updateHIVE = true; //VEHICLE CLEANUP ZONE's/areas switch choosing the map name for cleanup location purposes if(isNil "HALV_VEHICLE_CLEANUPZONES")then{ diag_log format["%1: selecting world to cleanup ...",_txt]; _WorldName = toLower format ["%1", worldName]; switch (_WorldName)do { //NAPF case "napf":{ // diag_log format["%2: Cleanup zones for napf selected! (check: %1)",_WorldName,_txt]; //logging if right worldname was selected, if uncommented HALV_VEHICLE_CLEANUPZONES = [ //position //radius //cityname/text [[8246.3184,15485.867,0], 125, "Trader City Lenzburg"], [[15506.952,13229.368,0], 125, "Trader city Emmen"], [[12399.751,5074.5273,0], 125, "Trader City Schratten"], [[10398.626,8279.4619,0], 125, "Bandit Vendor"], [[5149.9814,4864.1191,0], 125, "Hero Vendor"], [[2122.7954,7807.9878,0], 100, "West Wholesaler"], [[5379.0342,16103.187,0], 100, "North Wholesaler"], [[6772.8877,16983.27,0], 100, "Nordic Boats"], [[16839.973,5264.0566,0], 100, "Pauls Boats"], [[15128.379,16421.879,0], 100, "AWOLs Airfield"] ]; }; //chernarus case "chernarus":{ diag_log format["%2: Cleanup zones for chernarus selected! (check: %1)",_WorldName,_txt]; //logging if right worldname was selected, if uncommented HALV_VEHICLE_CLEANUPZONES = [ //position radius cityname/text [[9457.1514,11513.47,0], 125, "Mercado Central"], [[6743.3833,5580.8145,0], 125, "Antena4"] ]; }; //tavi case "tavi":{ // diag_log format["%2: Cleanup zones for tavi selected! (check: %1)",_WorldName,_txt]; //logging if right worldname was selected, if uncommented HALV_VEHICLE_CLEANUPZONES = [ //position //radius //cityname/text [[11698.81,15210.121,0], 75, "Trader City Lyepestok"], [[15309.663,9278.4912,0], 75, "Trader City Sabina"], [[5538.7354,8762.2695,0], 75, "Trader City Bilgrad"], [[7376.6084,4296.5879,0], 75, "Trader City Branibor"], [[10948.426,654.90265,0], 75, "Bandit Vendor"], [[15587.822,16394.049,0], 75, "Hero Vendor"], [[16555.732,10159.68,0], 75, "Aircraft Dealer"], [[6815.0776,8534.1504,0], 75, "Aircraft Dealer 2"], [[4066.3528,7265.0024,0], 75, "Misc. Vendor"], [[17497.631,7159.0879,0], 75, "Misc. Vendor 2"], [[17332.115,12930.239,0], 75, "Boat Dealer"], [[10570.494,16772.477,0], 75, "Boat Dealer 2"], [[10698.463,5983.665,0], 75, "Boat Dealer 3"], [[5419.2437,9503.5479,0], 75, "Boat Dealer 4"], [[13342.758,8611.9932,0], 75, "Wholesaler"], [[9859.4209,7471.5684,0], 75, "Wholesaler"] // <-- no comma for last entry ]; }; /* //myworldname case "myworldnameinlowercase":{ // diag_log format["%2: Cleanup zones for myworldnameinlowercase selected! (check: %1)",_WorldName,_txt]; //logging if right worldname was selected, if uncommented HALV_VEHICLE_CLEANUPZONES = [ //position //radius //cityname/text [[7839.60,8414.73,381.33], 150, "my custom zone marker"], [[7839.60,8414.73,381.33], 75, "my custom location"] // <-- no comma for last entry ]; }; */ //default default{ diag_log format["%2: Cleanup zones for %1 not availible ...",_WorldName,_txt]; //logging if right worldname was selected, if uncommented HALV_VEHICLE_CLEANUPZONES = [ //position //radius //cityname/text [[0,0,0], 1, "DEBUG"] ]; }; }; }; //\\\\\\\\\\\\\\\\\\\\ End Setup Area ////////////////////\\ /////////////// dont touch anything below this line unless you know what you are doing \\\\\\\\\\\\\\\ _possiblematch = false; {if(_obj isKindOf _x)then{_possiblematch=true;};}forEach _delVeh; if(_possiblematch)then{ { _Spos = _x select 0; _Rad = _x select 1; _name = _x select 2; _radats = _Rad+50; _radx4 = _Rad+_Rad+_Rad+_Rad; if(_obj distance _Spos < _Rad)then{ _defdel = false; _typeOf = typeOf _obj; _pos = getpos _obj; _mags = getmagazinecargo _obj; _weaps = getweaponcargo _obj; _packs = getbackpackcargo _obj; _objID = _obj getVariable["ObjectID","0"]; _objUID = _obj getVariable["ObjectUID","0"]; _objname = (gettext (configFile >> 'CfgVehicles' >> _typeOf >> 'displayName')); diag_log format["%1: %2 (%3) by %4 @%5 %6 [ID:%7,UID:%8] Cargo: [%9,%10,%11]",_txt,_typeOf,_objname,_name,mapgridposition _pos,_pos,_objID,_objUID,_weaps,_mags,_packs]; if(_delbikmot)then{{if(_obj isKindOf _x)then{_defdel = true};}forEach _defdelar;}; if(_defdel)then{_Action=3;diag_log format["%2: %1 is Model to delete by default!",_typeOf,_txt];}; if(getDammage _obj > _dam)then{_Action=3;diag_log format["%2: %1 too damaged",_typeOf,_txt];}; if(_unlock and !_defdel and (locked _obj))then{_obj setVehicleLock "UNLOCKED";_obj setVariable ["R3F_LOG_disabled",false,true];diag_log format["%2: %1 Un-Locked",_typeOf,_txt];}; switch(_Action)do{ case 0:{deleteVehicle _obj;diag_log format["%2: %1 Deleted, but remains in DB (Dont forget to clean this up)",_typeOf,_txt];}; case 1:{ _newPos = [_Spos, _radats, _radx4, 10, 0, 2000, 0] call BIS_fnc_findSafePos; _obj setpos _newPos; //update to HIVE? if(_updateHIVE)then{ private["_position","_worldspace","_fuel","_key"]; _position = getPosATL _obj; _worldspace = [ round(direction _obj), _position ]; _fuel = fuel _obj; _key = format["CHILD:305:%1:%2:%3:",_objID,_worldspace,_fuel]; diag_log ("HIVE: WRITE: "+ str(_key)); _key call server_hiveWrite; }; diag_log format["%6: %5 TP from %1 %2 to %3 %4",_pos,mapgridposition _pos,_newPos,mapgridposition _newPos,_typeOf,_txt]; }; case 2:{ _newPos = [_safespot, 0, _radius, 10, 0, 2000, 0] call BIS_fnc_findSafePos; _obj setpos _newPos; //update to HIVE? if(_updateHIVE)then{ private["_position","_worldspace","_fuel","_key"]; _position = getPosATL _obj; _worldspace = [ round(direction _obj), _position ]; _fuel = fuel _obj; _key = format["CHILD:305:%1:%2:%3:",_objID,_worldspace,_fuel]; diag_log ("HIVE: WRITE: "+ str(_key)); _key call server_hiveWrite; }; diag_log format["%6: %5 TP from %1 %2 to %3 %4",_pos,mapgridposition _pos,_newPos,mapgridposition _newPos,_typeOf,_txt]; }; default{_msg = format["%2: %1",_typeOf,_txt];deleteVehicle _obj;[_objID,_objUID,_msg] call server_deleteObj;}; }; }; }forEach HALV_VEHICLE_CLEANUPZONES; }; Pavillin 1 Link to comment Share on other sites More sharing options...
0 kelso000 Posted March 21, 2016 Report Share Posted March 21, 2016 I used infiSTAR's and Donn's as there were things from both that I liked and also got rid of some loops and started using triggers. Both are good though. Link to comment Share on other sites More sharing options...
0 Anthrax Posted March 23, 2016 Report Share Posted March 23, 2016 Nox safe zones. Pros easy peasy. Cons ... Link to comment Share on other sites More sharing options...
0 ckto Posted March 23, 2016 Report Share Posted March 23, 2016 I am using andre's safe zones, its the best for me cause the god mod does't ends right when you leave the zone, Donnovan 1 Link to comment Share on other sites More sharing options...
0 Donnovan Posted April 1, 2016 Report Share Posted April 1, 2016 I did this one. It's the culminance of a long way doing Safezones for Epoch 1.0.5.1. Link to comment Share on other sites More sharing options...
Question
Pavillin
There are many safezone scripts out there. I'm building a new server and I'm not sure what safezone script is the best. could some people maybe recommend some with their pros/cons
Link to comment
Share on other sites
5 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now