Forum Jump :

Author Message


Posts: 3
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2013-11-25 10:19        
     
Hi there,

I have made a few CTf maps which all work fine except there is no spawn protection. What i need is a script which stops people shooting into and out of spawn. My maps already have something that stops people entering spawn but it still possible to kill in and out of it.


Any suggestions welcome.


Author Message

Br.  



Posts: 43
Rank:


Level: Member

Country: fr
Location:
Occupation:
Age:
In-game name: Br.

 
#2 Posted at 2013-11-25 19:59        
     
Hi karlos,
i've made a script, it's a spawn protection.
You must place 2 markers called "BASE OPFOR" and "BASE BLUFOR" then for each client you must call this script.
Default distance is 800 you can change these values.

//--- Spawn Protection ---//
#define SAFETY_ZONES	[["BASE OPFOR", 800],["BASE BLUFOR", 800]]
#define MESSAGE			"DO NOT SHOOT in the base"
SPAWN_Restriction=["APERSBoundingMine_Range_Ammo","ATMine_Range_Ammo","DemoCharge_Remote_Ammo","SatchelCharge_Remote_Ammo","SLAMDirectionalMine_Wire_Ammo","APERSTripMine_Wire_Ammo","APERSMine_Range_Ammo","GrenadeHand","smokeshell","F_20mm_Green","F_20mm_Red","F_20mm_White","F_20mm_Yellow","F_40mm_Green","F_40mm_Cir","F_40mm_Red","F_40mm_White","F_40mm_Yellow","NLAW_F","R_TBG32V_F","R_PG32V_F","M_Titan_AP","SmokeShellBlue","SmokeShellGreen","SmokeShellOrange","SmokeShellPurple","SmokeShellRed","SmokeShell","SmokeShellYellow","G_40mm_SmokeBlue","G_40mm_SmokeGreen","G_40mm_SmokeOrange","G_40mm_SmokePurple","G_40mm_SmokeRed","G_40mm_Smoke","G_40mm_SmokeYellow","ClaymoreDirectionalMine_Remote_Ammo","mini_Grenade","GrenadeHand_stone","G_40mm_HE","M_NLAW_AT_F","M_Titan_AT"];

waitUntil {!isNull player};

player addEventHandler ["Fired", {
	if ({(_this select 0) distance getMarkerPos (_x select 0) < _x select 1} count SAFETY_ZONES > 0) then
	{
	_type = typeOf(_this select 6);

	if(_type in SPAWN_Restriction)then{
			hint format [" restricted ammo : %1", _type];
			deleteVehicle (_this select 6);
			titleText [MESSAGE, "PLAIN", 3];		
			};
	};
}];

_PlayerInAreas		= [];
_OldPlayerInAreas 	= [];
_TriggerList 	 	= [];
_Debug 				= false;

//--- Initialization for an area ---// 
_MarkerName	 	= "BASE OPFOR";
_Pos			 = getMarkerPos _MarkerName ;
_SpawnProtection = createTrigger ["EmptyDetector",_Pos]; 
_SpawnProtection setTriggerArea [800,800,0,true]; 
_SpawnProtection setTriggerActivation ["ANY","PRESENT",true];
_SpawnProtection setTriggerStatements ["","",""];
_TriggerList set [ count _TriggerList, [_SpawnProtection, EAST]];
//--- Initialization for an area ---//
_MarkerName	 	= "BASE BLUFOR";
_Pos			 = getMarkerPos _MarkerName;
_SpawnProtection = createTrigger ["EmptyDetector",_Pos]; 
_SpawnProtection setTriggerArea [800,800,0,true]; 
_SpawnProtection setTriggerActivation ["ANY","PRESENT",true];
_SpawnProtection setTriggerStatements ["","",""];
_TriggerList set [ count _TriggerList, [_SpawnProtection, WEST]];
sleep 1;
while{true}do{
	{
	_InZoneArea = _x select 0;
	_InZoneArea = list _InZoneArea;
	_SideZone 	= _x select 1;
	{
//--- for infantry ---//
			if(side _x == _SideZone)then{
				_x allowDamage false;
				_PlayerInAreas set [count _PlayerInAreas, _x];
			};	
//--- for vehicle ---//
		if(side _x == _SideZone && ((_x isKindOf  "Air") ||(_x isKindOf  "Car")||(_x isKindOf  "Ship") ||(_x isKindOf  "Tank")||(_x isKindOf  "Helicopter")))then{
			if( count crew _x > 0)then{ 
					_friendlies = false;
					{
						if(side _x == _SideZone)then{_x allowDamage false;_PlayerInAreas set [count _PlayerInAreas, _x];};
					}forEach (crew _x);
				}else{_x allowDamage false;_PlayerInAreas set [count _PlayerInAreas, _x];};
			};
		}forEach _InZoneArea;
//--- Find the player who left the area and setDamage true ---//
		{
			if(!(_x in _PlayerInAreas))then{
				_x allowDamage true;
				if(_Debug)then{hint format ["left the area %1", _x];};
			}else{if(_Debug)then{hint format  ["in the area %1", _x];};};
		}forEach _OldPlayerInAreas;
	}foreach _TriggerList;
//--- refresh index---//
_OldPlayerInAreas = _PlayerInAreas;
_PlayerInAreas = [];
sleep 5;
};

This post was edited by Br. (2013-11-25 20:21, ago)

If knowledge can create problems, it's not through ignorance that we can solve them.
I. Asimov

Advertisement


Author Message


Posts: 3
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#3 Posted at 2013-11-29 15:35        
     
thanks - will give this a go


Author Message

Br.  



Posts: 43
Rank:


Level: Member

Country: fr
Location:
Occupation:
Age:
In-game name: Br.

 
#4 Posted at 2013-12-02 19:35        
     
Hi, karlos send me a private message if you have any difficulties

Br. :-)

If knowledge can create problems, it's not through ignorance that we can solve them.
I. Asimov

Author Message


Posts: 13
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name: Fusion13

 
#5 Posted at 2013-12-02 23:36        
     
I believe I found an easier way to do this, Just make a trigger in the spawn with

On Act:
player allowDamage false;

On Deact:
player allowDamage true;

This post was edited by Fusion13 (2013-12-03 00:38, ago)

I like boobies

Author Message

Br.  



Posts: 43
Rank:


Level: Member

Country: fr
Location:
Occupation:
Age:
In-game name: Br.

 
#6 Posted at 2013-12-07 13:38        
     
# Fusion13 : I believe I found an easier way to do this, Just make a trigger in the spawn with

On Act:
player allowDamage false;

On Deact:
player allowDamage true;

Did you try on a dedicated server?
Trigger is global, so if one player is in the area everyone will be invincible..

If knowledge can create problems, it's not through ignorance that we can solve them.
I. Asimov

Author Message

void  



Posts: 4
Rank:


Level: Member

Country: at
Location:
Occupation:
Age:
In-game name:

 
#7 Posted at 2013-12-08 10:30        
     
Yeah it is, but the player is local
If you want to do this for all you need to

{
_x allowDamage false;
} forEach playableUnit;

I think yours should work fine

This post was edited by void (2013-12-09 07:15, ago)


Author Message


Posts: 17
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 40
In-game name:

 
#8 Posted at 2015-04-01 14:33        
     
I like the simplicity of a trigger in the spawn. I'm going to give it a try.

Will this protect assets too? i.e. empty vics from being blown up by arty or missles fired from outside the "safezone" say by jets etc?

Thanks!

Q