Jump to content
  • 0

Extended Safezone Script...WIP


Friendly

Question

This is part of the code that was worked on by the past arma 2 community, not 100% sure who fully created it or if everyone contributed. Please try and tell me what may be the problem as when I leave the safezones the god mode still remains but the msg saying I left the safezone works.

 

init.sqf

[] execVM "safezone.sqf";

Safezone.sqf

if (isNil "inSafezone") then {
    inSafezone = false;
};
	while {true} do {
		waitUntil { inSafeZone };
			player allowDamage false;
			player removeAllEventhandlers "HandleDamage";
			player addEventhandler ["HandleDamage", {false}];
			SafezoneFiredEvent = player addEventHandler ["Fired", {titleText ["You can not fire your weapon in a safe zone.","PLAIN DOWN"]; titleFadeOut 4;}];
		waitUntil { !inSafeZone };
			player allowDamage true;
			player addeventhandler ['HandleDamage',{_this call HandleDamage;} ];
			player removeEventHandler ["Fired", SafezoneFiredEvent];
};

mission.sqm

class Sensors
	{
		items=3;
		class Item0
		{
			position[]={18459.535,23.616171,14277.782};
			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[]={6195.4927,89.220779,16839.254};
			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[]={13334.093,2.2350941,14517.924};
			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
			{
			};
		};		
	};
};
Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

#1.

Remove the "handleDamage" EH the same way, You remove the "fired" EH (see the spoiler).

#2.

Use local variables when ever possible.

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", {titleText ["You can not fire your weapon in a safe zone.","PLAIN DOWN"]; titleFadeOut 4;}];		waitUntil { !inSafeZone };			player allowDamage true;			player removeEventhandler ["HandleDamage", _safeZoneDamageEH];			player removeEventHandler ["Fired", _safeZoneFiredEH];};

Edit

I'm on my mobile and somehow it messes up with the code...

Greez KiloSwiss

Link to comment
Share on other sites

  • 0

#1.

Remove the "handleDamage" EH the same way, You remove the "fired" EH (see the spoiler).

#2.

Use local variables when ever possible.

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", {titleText ["You can not fire your weapon in a safe zone.","PLAIN DOWN"]; titleFadeOut 4;}];		waitUntil { !inSafeZone };			player allowDamage true;			player removeEventhandler ["HandleDamage", _safeZoneDamageEH];			player removeEventHandler ["Fired", _safeZoneFiredEH];};

Edit

I'm on my mobile and somehow it messes up with the code...

Greez KiloSwiss

 

Ok will be testing it a  little bit more on my test server.

Link to comment
Share on other sites

  • 0

#1.

Remove the "handleDamage" EH the same way, You remove the "fired" EH (see the spoiler).

#2.

Use local variables when ever possible.

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", {titleText ["You can not fire your weapon in a safe zone.","PLAIN DOWN"]; titleFadeOut 4;}];		waitUntil { !inSafeZone };			player allowDamage true;			player removeEventhandler ["HandleDamage", _safeZoneDamageEH];			player removeEventHandler ["Fired", _safeZoneFiredEH];};

Edit

I'm on my mobile and somehow it messes up with the code...

Greez KiloSwiss

 

isn't seeming to work.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...