Better Safezone, Maybe

maca134

Well-Known Member
What the script does is give the player godmode within the safe zones and also disables weapons.

Create new file called safezone.sqf and paste this:
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;
};

Then goto your mission.sqm and find the 'Sensors' section and add at the bottom:
Code:
class ItemN
{
position[]={4053.8501,364.76645,11668.645};
activationBy="ANY";
repeating=1;
interruptable=1;
age="UNKNOWN";
name="zonebash_safezone";
expCond="(player distance zonebash_safezone) < 75;";
expActiv="inSafeZone = true;";
expDesactiv="inSafeZone = false;";
class Effects
{
 
};
};
(Were ItemN should be like Item10, if the previous sensor is Item9)
The expCond line, the number 75, this is the distance the safezone triggers
Position, is the position on the map
name needs to be unique and pasted into the expcond line.
The you will need to increment the Items=N line again at the top of the sensors section.


Lastly, open init.sqf and add the following
Code:
[] execVM "safezone.sqf";
to
Code:
if (!isDedicated) then {
//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";
[] execVM "safezone.sqf";
};
If you want to add a marker, you add the following into mission.sqm in the markers section:
Code:
class ItemN
{
    position[]={4053.8501,364.76645,11668.645};
    name="bash_safezone";
    text="Safe Zone";
    markerType="ELLIPSE";
    type="Empty";
    colorName="ColorOrange";
    a=75;
    b=75;
};
Again, you will have to change the relevant bits.
The a and b, set this to the distance set in the sensor, name needs to be unique and set the position to the same as the sensor previously. The you will need to increment the Items=N line again at the top of the markers section.

Hope this help and Im sorry for my poor explanation skill.

BE Filters (Not copy and paste, needs adding to your filters):

Code:
5 setDammage !"safezone.sqf","



Edit:
I have attached the safezone.sqf and my mission.sqm files
 
It looks like you need to move '[] execVM "safezone.sqf";' 1 line down

if (!isDedicated) then {[] 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";
[] execVM "\z\addons\dayz_code\system\antihack.sqf";
"heliCrash" addPublicVariableEventHandler {
_list = nearestObjects [_this select 1, ["CraterLong"], 100];
{deleteVehicle _x;} foreach _list;
};
[] execVM "safezone.sqf";
};

You put it in the event handler
 
Did you also check the syntax in the mission.sqm? The Marker should still work because it isn't dependent on the safezone.sqf, but it won't work
 
Okay so not getting any warning text when coming near it as :
Code:
titleText [format["Entering Safe Zone. Your weapons have been deactivated."],"PLAIN DOWN"]; titleFadeOut 4;
would suggest, but where I placed the safe zone I am getting a red sphere.
 
its possible it isnt work with dayz 1.7.7.1, im currently playin epoch and havnt had chance to test it.
Its next on my list of things to do
 
and after seeing the sphere, I got kicked (client stopped responding) and now I cannot get into my server.
 
It's not a filter issue, I don't use them. 90% of the time they kick innocents, so why use them?
 
I havnt found that, once you have found out were all the kicks happen, you can create exceptions in the filters...

I wouldnt run a server without BE
 
I havnt found that, once you have found out were all the kicks happen, you can create exceptions in the filters...

I wouldnt run a server without BE

It's not running without BE, I just set a large portion of the to only log them. I monitor the logs often, and also have an antihack thats updated weekly. Have only had one hacker, and the anti hack took care of him.
 
1 hacker that you know about ;)

Server isn't popular enough to get many hackers. The day we had him we had our highest pop, 15 people, and it was myself and 2 other admins online. Anti hack popped a warning, and sure enough the logs backed it up. Kicked and banned him as soon as we verified it
 
Let me know if you ever get this working with 1.7.7.1 :) until then will go back to the original safezone.sqf
 
No luck getting this or the other safezone for that matter working on 1.7.71. The ones that restrict weapons don't work for me, but the one that just warns them for 10 seconds then kills them works just fine.

It does seem to keep zombies from attacking me but god mode isn't on and weapons work fine.
 
No luck getting this or the other safezone for that matter working on 1.7.71. The ones that restrict weapons don't work for me, but the one that just warns them for 10 seconds then kills them works just fine.

It does seem to keep zombies from attacking me but god mode isn't on and weapons work fine.

He did say that he had not tested this on Chernarus 1.7.7.1 ;)
 
He did say that he had not tested this on Chernarus 1.7.7.1 ;)

my bad if it sounded like I was complaining, just stating my experience for the good of anyone else trying themselves. I'm sure, like most other scripts, there's just a few things done differently now and the script needs to be adjusted to match. Wish I was good enough to help out
 
Back
Top