Jump to content

Extended Safezone Script - Working!


Friendly

Recommended Posts

Hey guys, I am still a noob at scripting. Here is a code revamped a little from the Arma 2 Epoch Community to try and help out anyone having problems with extending safezones.

 

-----> I am no longer providing support for this script please get all questions/answers from the community! Peace  B) <-----

 

Video Tutorial thanks to subzerogaming :

https://youtu.be/zbWSwdw0QF4

 

NOTE: Only Works with Infistar Antihack as Epochs Antihack Reverts Allow Damage

 

To allow this to work you must change the follow to false below in your run.sqf that was provided to you by infistar!

/*  revert allowDamage   */ _RAD = false; /* true or false */ /* if you have safezones using "player allowDamage false;" or similar.. set _RAD = false; */
/*  HandleDamage check   */ _HDC = false; /* true or false */ /* *experimental + Epoch only* - probably publicVariableServer spam but no more godmode hackers. */
/*  Revert HandleDamage  */ _RHD = false; /* true or false */ /* Needs to be  false  for Paintball script */
/*  Use EH_Fired check   */ _EHF = false; /* true or false */ /* Some mods revert the EventHandlers by default and can cause problems with this check. Tested on Epoch and AltisLife.  */

Next go to your init.sqf (note: If you do not already have one just create a blank init.sqf file and put the following)

Paste the following code into it.

[] execVM "scripts\safezone.sqf";

If you do not already have a scripts folder then create one or rename the path in the init to wherever you want it to be placed, but for this example we will just use the scripts folder.

Inside of the scripts folder create a new file called safezone.sqf and paste the following into it.

if (isNil "inSafezone") then {
    inSafezone = false;
};
while {
    true
}
do {
    private["_safeZoneDamageEH", "_safeZoneFiredEH"];
    waitUntil {
        inSafeZone
    };
    player allowDamage false;
_safeZoneDamageEH = player addEventhandler["HandleDamage",{false}];
    _safeZoneFiredEH = player addEventHandler ["Fired", {
   deleteVehicle (_this select 6);
systemChat ("You can not fire your weapon in a safe zone.");
    }];
    waitUntil {
        !inSafeZone
    };
    player allowDamage true;
    player removeEventhandler["HandleDamage", _safeZoneDamageEH];
    player removeEventHandler["Fired", _safeZoneFiredEH];
}; 

Next go into your mission.sqm and replace

class Markers
	{
		items = 9;
		class Item0
		{
			position[] = {14939.934,0.053499073,15083.272};
			name = "center";
			type = "Empty";
		};
		class Item1
		{
			position[] = {23600.639,3.19,18000.72};
			name = "respawn_east";
			type = "Empty";
		};
		class Item2
		{
			position[] = {23600.611,3.19,18000.768};
			name = "respawn_west";
			type = "Empty";
		};
	};
}; 

With

class Markers
	{
		items = 9;
		class Item0
		{
			position[] = {14939.934,0.053499073,15083.272};
			name = "center";
			type = "Empty";
		};
		class Item1
		{
			position[] = {23600.639,3.19,18000.72};
			name = "respawn_east";
			type = "Empty";
		};
		class Item2
		{
			position[] = {23600.611,3.19,18000.768};
			name = "respawn_west";
			type = "Empty";
		};
		class Item3
		{
			position[]={6181.6841,83.907509,16876.732};
			name="westsafezone";
			text="Safe Zone";
			type="mil_warning";
			colorName="ColorRed";
		};
		class Item4
		{
			position[]={13334.093,2.2350941,14517.924};
			name="centralspawn";
			markerType="ELLIPSE";
			type="Empty";
			colorName="ColorGreen";
			fillName="Grid";
			a=250;
			b=250;
		};
		class Item5
		{
			position[]={13326.247,2.2928343,14546.686};
			name="centralsafezone";
			text="Safe Zone";
			type="mil_warning";
			colorName="ColorRed";
		};
		class Item6
		{
			position[]={18464.313,23.351175,14263.799};
			name="eastspawn";
			markerType="ELLIPSE";
			type="Empty";
			colorName="ColorGreen";
			fillName="Grid";
			a=250;
			b=250;
		};
		class Item7
		{
			position[]={18461.789,24.769226,14300.033};
			name="eastsafezone";
			text="Safe Zone";
			type="mil_warning";
			colorName="ColorRed";
		};
		class Item8
		{
			position[]={6195.4927,89.220779,16839.254};
			name="westspawn";
			markerType="ELLIPSE";
			type="Empty";
			colorName="ColorGreen";
			fillName="Grid";
			a=250;
			b=250;
		};
	};
	class Sensors
	{
		items=3;
		class Item0
		{
			position[]={18461.789,24.769226,14300.033};
			a=250;
			b=250;
			activationBy="ANY";
			repeating=1;
			interruptable=1;
			age="UNKNOWN";
			name="eastsafezone";
			expCond = "(player distance eastsafezone) < 250;";
			expActiv="hint ""You have entered A Safe Zone! Do not fire in the Safe Zones."";  inSafeZone = true;";
			expDesactiv="hint ""You are leaving the Safe Zone!""; inSafeZone = false;";
			class Effects
			{
			};
		};
		class Item1
		{
			position[]={6181.6841,83.907509,16876.732};
			a=250;
			b=250;
			activationBy="ANY";
			repeating=1;
			interruptable=1;
			age="UNKNOWN";
			name="westsafezone";
			expCond = "(player distance westsafezone) < 250;";
			expActiv="hint ""You have entered A Safe Zone! Do not fire in the Safe Zones.""; inSafeZone = true;";
			expDesactiv="hint ""You are leaving the Safe Zone!""; inSafeZone = false;";
			class Effects
			{
			};
		};
		class Item2
		{
			position[]={13326.247,2.2928343,14546.686};
			a=250;
			b=250;
			activationBy="ANY";
			repeating=1;
			interruptable=1;
			age="UNKNOWN";
			name="centralsafezone";
			expCond = "(player distance centralsafezone) < 250;";
			expActiv="hint ""You have entered A Safe Zone! Do not fire in the Safe Zones.""; inSafeZone = true;";
			expDesactiv="hint ""You are leaving the Safe Zone!""; inSafeZone = false;";
			class Effects
			{
			};
		};
	};
};

  

This should work for all maps, but you will have to change the coordinates of the markers if it is anything but default altis.

 

Battleye:

 

Scripts.txt

 

line 20 or under allowDamage add

!"player allowDamage false;" !"player allowDamage true;"

line 58 or under 7 removeEventHandler add

!"player removeEventhandler["HandleDamage", _safeZoneDamageEH];"

No Longer being updated/responded to as I only play the game now  B)

Link to comment
Share on other sites

Why do that  I do mine all in the mission.sqf 

 

 Example below 

 

class Sensors
{
items=3;
class Item0
{
position[]={10190.044,25.138008,12419.594};
a=150;
b=150;
angle=-130.966;
activationBy="ANY";
repeating=1;
interruptable=1;
age="UNKNOWN";
text="CSpawn";
name="CTrader";
expCond="(vehicle player) in thislist;";
expActiv="titleText [""You Are Now Entering A Save Zone"", ""PLAIN DOWN"", 3]; player allowDamage false; player addEventHandler [""HandleDamage"",{false}];";
expDesactiv="titleText [""You Are Now Leaving A Save Zone"", ""PLAIN DOWN"", 3]; player allowDamage true; player addEventHandler [""HandleDamage"",{true}];";
class Effects
{
};
Link to comment
Share on other sites

 

Why do that  I do mine all in the mission.sqf 

 

 Example below 

 

class Sensors
{
items=3;
class Item0
{
position[]={10190.044,25.138008,12419.594};
a=150;
b=150;
angle=-130.966;
activationBy="ANY";
repeating=1;
interruptable=1;
age="UNKNOWN";
text="CSpawn";
name="CTrader";
expCond="(vehicle player) in thislist;";
expActiv="titleText [""You Are Now Entering A Save Zone"", ""PLAIN DOWN"", 3]; player allowDamage false; player addEventHandler [""HandleDamage"",{false}];";
expDesactiv="titleText [""You Are Now Leaving A Save Zone"", ""PLAIN DOWN"", 3]; player allowDamage true; player addEventHandler [""HandleDamage"",{true}];";
class Effects
{
};

 

this one deletes bullets when they are shot. I just prefer to keep it all in one file and then be called to. Just my personal thoughts. As well as when a player shoots it warns them that they cannot shoot in a safezone. I made the bullets delete because of people shooting from in the safezone out and killing people.

Link to comment
Share on other sites

this is how my safe zones work with Protection Zone

 

 

b_560_95_1.png

 

example

	private ["_objects"];
_objects = [


    ["ProtectionZone_Invisible_F",[23710.1, 16250.1, 0.01]], 
    ["ProtectionZone_Invisible_F",[23710.1, 16225.1, 0.01]], 	
    ["ProtectionZone_Invisible_F",[23710.1, 16200.1, 0.01]],	
    ["ProtectionZone_Invisible_F",[23685.1, 16250.1, 0.01]],
    ["ProtectionZone_Invisible_F",[23685.1, 16225.1, 0.01]],
    ["ProtectionZone_Invisible_F",[23685.1, 16200.1, 0.01]],	
    ["ProtectionZone_Invisible_F",[23660.1, 16250.1, 0.01]], 
    ["ProtectionZone_Invisible_F",[23660.1, 16225.1, 0.01]], 
    ["ProtectionZone_Invisible_F",[23660.1, 16200.1, 0.01]] 
	
];

{
	private ["_obj"];
	_obj = createVehicle [_x select 0, [0,0,0], [], 0, "CAN_COLLIDE"];
	_obj setvectorup [0,0,1];	
	_obj setPosATL (_x select 1);
} foreach _objects;	
Link to comment
Share on other sites

ya the code definately is up for some adjustment. If anyone has tips or already a better safezone script made pls post. This one works perfect from what I can tell so that people don't shoot vehicles or shoot people in the safezone. But I am still a noob when it comes to scripting and it probably has some downsides.

Link to comment
Share on other sites

Everything loaded fine I see no errors or problems but the code does not execute?  No messages and no invuln to bullets.  Any chance infistar is blocking this somehow?  It always seems to be Infistar is the problem for anything I try to add in.

 

infistart not blocking safe zone

Link to comment
Share on other sites

Everything loaded fine I see no errors or problems but the code does not execute?  No messages and no invuln to bullets.  Any chance infistar is blocking this somehow?  It always seems to be Infistar is the problem for anything I try to add in.

can you send me your mission.sqm in a pastebin? That is probably the problem, at least it is going to be the most common... Also are you running this on Altis?

Link to comment
Share on other sites

Everything loaded fine I see no errors or problems but the code does not execute?  No messages and no invuln to bullets.  Any chance infistar is blocking this somehow?  It always seems to be Infistar is the problem for anything I try to add in.

 

Like brunz said... Antihacks clean up Eventhandlers such as this one on normal players and infistar will clean this up. But one way to test if it loaded up is to login as infistar admin and see if it works... It should work for you, just not a normal player.

Link to comment
Share on other sites

Like brunz said... Antihacks clean up Eventhandlers such as this one on normal players and infistar will clean this up. But one way to test if it loaded up is to login as infistar admin and see if it works... It should work for you, just not a normal player.

 

So how do you tell Infistar to leave this code alone and let it execute?

Link to comment
Share on other sites

 

example

	private ["_objects"];
_objects = [


    ["ProtectionZone_Invisible_F",[23710.1, 16250.1, 0.01]], 
    ["ProtectionZone_Invisible_F",[23710.1, 16225.1, 0.01]], 	
    ["ProtectionZone_Invisible_F",[23710.1, 16200.1, 0.01]],	
    ["ProtectionZone_Invisible_F",[23685.1, 16250.1, 0.01]],
    ["ProtectionZone_Invisible_F",[23685.1, 16225.1, 0.01]],
    ["ProtectionZone_Invisible_F",[23685.1, 16200.1, 0.01]],	
    ["ProtectionZone_Invisible_F",[23660.1, 16250.1, 0.01]], 
    ["ProtectionZone_Invisible_F",[23660.1, 16225.1, 0.01]], 
    ["ProtectionZone_Invisible_F",[23660.1, 16200.1, 0.01]] 
	
];

{
	private ["_obj"];
	_obj = createVehicle [_x select 0, [0,0,0], [], 0, "CAN_COLLIDE"];
	_obj setvectorup [0,0,1];	
	_obj setPosATL (_x select 1);
} foreach _objects;	

I'd like to try a protection zone.  Would you be willing to do a full write up on how to accomplish this?

 

Init.sqm change?

Add a script?

Change the mission.sqm?

Link to comment
Share on other sites

I'd like to try a protection zone.  Would you be willing to do a full write up on how to accomplish this?

 

Init.sqm change?

Add a script?

Change the mission.sqm?

example:

 

make file SafeZone.sqf

Add code inside:

	private ["_objects"];
_objects = [
 
 
    ["ProtectionZone_Invisible_F",[23710.1, 16250.1, 0.01]], //safe zone cords with 25m radius
    ["ProtectionZone_Invisible_F",[23710.1, 16225.1, 0.01]], 	
    ["ProtectionZone_Invisible_F",[23710.1, 16200.1, 0.01]],	
    ["ProtectionZone_Invisible_F",[23685.1, 16250.1, 0.01]],
    ["ProtectionZone_Invisible_F",[23685.1, 16225.1, 0.01]],
    ["ProtectionZone_Invisible_F",[23685.1, 16200.1, 0.01]],	
    ["ProtectionZone_Invisible_F",[23660.1, 16250.1, 0.01]], 
    ["ProtectionZone_Invisible_F",[23660.1, 16225.1, 0.01]], 
    ["ProtectionZone_Invisible_F",[23660.1, 16200.1, 0.01]] 
	
];
 
{
	private ["_obj"];
	_obj = createVehicle [_x select 0, [0,0,0], [], 0, "CAN_COLLIDE"];
	_obj setvectorup [0,0,1];	
	_obj setPosATL (_x select 1);
} foreach _objects;	

run it from init.sqf  

[] execVM "SafeZone.sqf";
Link to comment
Share on other sites

in scripts.txt line 58 add !"player removeEventhandler["HandleDamage", _safeZoneDamageEH];"

 

Are you claiming the AH cleanup of event handlers can be solved by adding exceptions in the scripts.txt ?

 

I had to add a slew of BE exceptions just to get a safezone to run, it still only worked for admins.

 

I'd want handle damage and 'fired' to be added/removed without issue on players.

Link to comment
Share on other sites

Are you claiming the AH cleanup of event handlers can be solved by adding exceptions in the scripts.txt ?

 

I had to add a slew of BE exceptions just to get a safezone to run, it still only worked for admins.

 

I'd want handle damage and 'fired' to be added/removed without issue on players.

I kinda gave up after I figured out that the two antihacks messed up the event handlers. I have no idea of what I should do to work around it. And no, battleye is 100% seperate from the antihacks when it comes to that.

Link to comment
Share on other sites

Here is how to make it serverside.

Download pbo file here https://www.dropbox.com/s/5m4qg1ucch116f6/Safe_Zone.pbo?dl=0

Unpack Safe_Zone.pbo and add your safe zone cords inside file init.sqf 

Pack it back to pbo and add to @epochhive\addons

Run it from MPMission init.sqf 

 

[] execVM "\q\addons\Safe_Zone\init.sqf";

 

There is no need any be filters

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