Advertisement
corbuhh

Infi SafeZones

Apr 26th, 2014
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.91 KB | None | 0 0
  1. fnc_infiSTAR_SafeZone =
  2. {
  3. _infiSZ =
  4. [
  5. [[6325.6772,7807.7412],200,true]
  6. ,[[4063.4226,11664.19],200,true]
  7. ,[[11447.472,11364.504],200,true]
  8. ,[[1606.6443,7803.5156],150,true]
  9. ,[[12944.227,12766.889],150,true]
  10. ,[[12060.471,12638.533],350,true]
  11. ,[[4058.42,10792.62],20,false]
  12. ,[[13532.4,6356.52],60,false]
  13. ,[[13466.8,5439.51],60,false]
  14. ,[[7998.39,2899.04],60,false]
  15. ,[[4359.92,2259.39],60,false]
  16. ,[[3708.5974,5970.499],315,true]
  17. ,[[13642.55,2880.3267],315,false]
  18. ];
  19. if (isServer) exitWith
  20. {
  21. _signs = true;
  22. {
  23. _center = _x select 0;
  24. _radius = _x select 1;
  25. _lSign = _x select 2;
  26. if (_signs && _lSign) then
  27. {
  28. for '_i' from 0 to 360 step (270 / _radius)*2 do
  29. {
  30. _location = [(_center select 0) + ((cos _i) * _radius), (_center select 1) + ((sin _i) * _radius),0];
  31. _dir = ((_center select 0) - (_location select 0)) atan2 ((_center select 1) - (_location select 1));
  32.  
  33. _object = createVehicle ['SignM_FARP_Winchester_EP1', _location, [], 0, 'CAN_COLLIDE'];
  34. _object setDir _dir;
  35. _object setVehicleInit 'this setObjectTexture [0, ''Addons\SafeZones\sign.paa''];';
  36. };
  37. };
  38. } forEach _infiSZ;
  39. };
  40. waitUntil { !isNil 'dayz_animalCheck' };
  41. if (isNil 'inSafezone') then {inSafezone = false;};
  42. [_infiSZ] spawn {
  43. _infiSZ = _this select 0;
  44. startSafeZone =
  45. {
  46. if (isNil 'outNow') then
  47. {
  48. hint 'You entered a Safe Zone!';
  49. taskHint ['You entered a Safe Zone!', [0,1,0,1], 'taskDone'];
  50. inNow = nil;
  51. outNow = true;
  52. };
  53. player_fired = { deleteVehicle (nearestObject [_this select 0,_this select 4]); };
  54. player_zombieCheck = {};
  55. fnc_usec_damageHandler = {};
  56. fnc_usec_unconscious = {};
  57. object_monitorGear = {};
  58. player removeAllEventHandlers 'handleDamage';
  59. player addEventHandler ['handleDamage', {false}];
  60. player allowDamage false;
  61. if (vehicle player != player) then
  62. {
  63. _vehObj = vehicle player;
  64. _vehObj removeAllEventHandlers 'Fired';
  65. _vehObj addEventHandler ['Fired', {_this call player_fired;}];
  66. };
  67. };
  68. endSafeZone =
  69. {
  70. if (isNil 'inNow') then
  71. {
  72. hint 'You left the Safe Zone!';
  73. taskHint ['You left the Safe Zone!', [1,0,0.1,1], 'taskFailed'];
  74. inNow = true;
  75. outNow = nil;
  76. };
  77. player_fired = compile preprocessFileLineNumbers '\z\addons\dayz_code\compile\player_fired.sqf';
  78. player_zombieCheck = compile preprocessFileLineNumbers '\z\addons\dayz_code\compile\player_zombieCheck.sqf';
  79. fnc_usec_damageHandler = compile preprocessFileLineNumbers '\z\addons\dayz_code\compile\fn_damageHandler.sqf';
  80. fnc_usec_unconscious = compile preprocessFileLineNumbers '\z\addons\dayz_code\compile\fn_unconscious.sqf';
  81. object_monitorGear = compile preprocessFileLineNumbers '\z\addons\dayz_code\compile\object_monitorGear.sqf';
  82. player allowDamage true;
  83. player removeAllEventHandlers 'HandleDamage';
  84. player addeventhandler ['HandleDamage',{_this call fnc_usec_damageHandler;} ];
  85. };
  86. while {1 == 1} do
  87. {
  88. _state = false;
  89. _obj = vehicle player;
  90. {
  91. _z = _x select 0;
  92. _r = _x select 1;
  93. if (_obj distance _z < _r) exitWith {_state = true;};
  94. } forEach _infiSZ;
  95. if (_state) then
  96. {
  97. inSafeZone = true;
  98. call startSafeZone;
  99.  
  100. {
  101. if (!isNull _x) then
  102. {
  103. if !(isPlayer _x) then
  104. {
  105. deletevehicle _x;
  106. };
  107. };
  108. } forEach (_obj nearEntities ['zZombie_Base',15]);
  109. }
  110. else
  111. {
  112. inSafeZone = false;
  113. };
  114. _plr = player;
  115. sleep 2;
  116. if (!(inSafeZone) || (_plr != player)) then
  117. {
  118. call endSafeZone;
  119. };
  120. };
  121. };
  122. [] spawn {
  123. while {1 == 1} do
  124. {
  125. if (inSafezone) then
  126. {
  127. _cnt = {isPlayer _x && _x != player} count (player nearEntities [['CAManBase'], 2]);
  128. if ((_cnt > 0) && (!isNull (findDisplay 106))) then
  129. {
  130. (findDisplay 106) closedisplay 0;
  131. _log = format['%1 You are not allowed to open Gear while near another player!',name player];
  132. cutText [_log,'PLAIN'];
  133. hint _log;
  134. };
  135. }
  136. else
  137. {
  138. sleep 2;
  139. };
  140. sleep 0.1;
  141. };
  142. };
  143. };
  144. [] spawn fnc_infiSTAR_SafeZone;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement