Skip to content

Instantly share code, notes, and snippets.

@galek
Created March 23, 2018 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save galek/47cab2f8aa3143dbd83f2aafb814f637 to your computer and use it in GitHub Desktop.
Save galek/47cab2f8aa3143dbd83f2aafb814f637 to your computer and use it in GitHub Desktop.
//--- Spawn Protection ---//
#define SAFETY_ZONES [["respawn_east", 400],["respawn_west", 400]]
#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"];
if (isDedicated) exitWith {};
waitUntil {!isNull player};
waitUntil {time > 0};
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];
};
deleteVehicle (_this select 6); titleText ["Firing/Grenades Disabled in a safe zone!", "PLAIN", 3]; titleFadeOut 1;
};
}];
_PlayerInAreas = [];
_OldPlayerInAreas = [];
_TriggerList = [];
_Debug = false;
//--- Initialization for an area ---//
_MarkerName = "respawn_east";
_Pos = getMarkerPos _MarkerName ;
_SpawnProtection = createTrigger ["EmptyDetector",_Pos];
_SpawnProtection setTriggerArea [400,400,0,true];
_SpawnProtection setTriggerActivation ["ANY","PRESENT",true];
_SpawnProtection setTriggerStatements ["","",""];
_TriggerList set [ count _TriggerList, [_SpawnProtection, EAST]];
//--- Initialization for an area ---//
_MarkerName = "respawn_west";
_Pos = getMarkerPos _MarkerName;
_SpawnProtection = createTrigger ["EmptyDetector",_Pos];
_SpawnProtection setTriggerArea [400,400,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;
_x removeEventHandler ["fired", 0];
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;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment