Advertisement
Guest User

safezone.sqf

a guest
Apr 13th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.70 KB | None | 0 0
  1. /*
  2. I can't give credit to the original creator of this script, as I have no idea who it is.
  3. to call the script, create two markers on the map, BASE OPFOR and BASE BLUFOR define the distance in the SAFETY_ZONES ARRAY
  4. and again in the setTriggerArea lines.
  5. call the script in init.sqf with execVM
  6. etc. []execVM 'scripts\safezone.sqf';
  7. cheers mate - js2k6 aka JakeHekesFists[DMD]
  8. */
  9.  
  10.  
  11.  
  12. //--- Spawn Protection ---//
  13. #define SAFETY_ZONES [["BASE OPFOR", 75],["BASE BLUFOR", 75]]
  14. #define MESSAGE "DO NOT SHOOT in the base"
  15. 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"];
  16.  
  17. waitUntil {!isNull player};
  18.  
  19. player addEventHandler ["Fired", {
  20. if ({(_this select 0) distance getMarkerPos (_x select 0) < _x select 1} count SAFETY_ZONES > 0) then
  21. {
  22. _type = typeOf(_this select 6);
  23.  
  24. if(_type in SPAWN_Restriction)then{
  25. hint format [" restricted ammo : %1", _type];
  26. deleteVehicle (_this select 6);
  27. titleText [MESSAGE, "PLAIN", 3];
  28. };
  29. };
  30. }];
  31.  
  32. _PlayerInAreas = [];
  33. _OldPlayerInAreas = [];
  34. _TriggerList = [];
  35. _Debug = false;
  36.  
  37. //--- Initialization for an area ---//
  38. _MarkerName = "BASE OPFOR";
  39. _Pos = getMarkerPos _MarkerName ;
  40. _SpawnProtection = createTrigger ["EmptyDetector",_Pos];
  41. _SpawnProtection setTriggerArea [75,75,0,true];
  42. _SpawnProtection setTriggerActivation ["ANY","PRESENT",true];
  43. _SpawnProtection setTriggerStatements ["","",""];
  44. _TriggerList set [ count _TriggerList, [_SpawnProtection, EAST]];
  45. //--- Initialization for an area ---//
  46. _MarkerName = "BASE BLUFOR";
  47. _Pos = getMarkerPos _MarkerName;
  48. _SpawnProtection = createTrigger ["EmptyDetector",_Pos];
  49. _SpawnProtection setTriggerArea [75,75,0,true];
  50. _SpawnProtection setTriggerActivation ["ANY","PRESENT",true];
  51. _SpawnProtection setTriggerStatements ["","",""];
  52. _TriggerList set [ count _TriggerList, [_SpawnProtection, WEST]];
  53. sleep 1;
  54. while{true}do{
  55. {
  56. _InZoneArea = _x select 0;
  57. _InZoneArea = list _InZoneArea;
  58. _SideZone = _x select 1;
  59. {
  60. //--- for infantry ---//
  61. if(side _x == _SideZone)then{
  62. _x allowDamage false;
  63. _PlayerInAreas set [count _PlayerInAreas, _x];
  64. };
  65. //--- for vehicle ---//
  66. if(side _x == _SideZone && ((_x isKindOf "Air") ||(_x isKindOf "Car")||(_x isKindOf "Ship") ||(_x isKindOf "Tank")||(_x isKindOf "Helicopter")))then{
  67. if( count crew _x > 0)then{
  68. _friendlies = false;
  69. {
  70. if(side _x == _SideZone)then{_x allowDamage false;_PlayerInAreas set [count _PlayerInAreas, _x];};
  71. }forEach (crew _x);
  72. }else{_x allowDamage false;_PlayerInAreas set [count _PlayerInAreas, _x];};
  73. };
  74. }forEach _InZoneArea;
  75. //--- Find the player who left the area and setDamage true ---//
  76. {
  77. if(!(_x in _PlayerInAreas))then{
  78. _x allowDamage true;
  79. if(_Debug)then{hint format ["left the area %1", _x];};
  80. }else{if(_Debug)then{hint format ["in the area %1", _x];};};
  81. }forEach _OldPlayerInAreas;
  82. }foreach _TriggerList;
  83. //--- refresh index---//
  84. _OldPlayerInAreas = _PlayerInAreas;
  85. _PlayerInAreas = [];
  86. sleep 5;
  87. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement