Advertisement
Guest User

NSZ

a guest
Aug 29th, 2015
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. private ["_eh1","_inArea","_pos","_unit","_zone1","_zone2","_dis"];
  2.  
  3. _unit = _this select 0;
  4.  
  5. _zone1 = getMarkerPos "zone1"; // marker name for the areas you want to protect
  6. _zone2 = getMarkerPos "zone2";
  7. _dis = 200; // distance from area safe zone starts
  8.  
  9.  
  10.  
  11. if ((_zone1 distance _unit > _dis) or (_zone2 distance _unit > _dis)) then { //check if unit is in zone when script starts
  12. _inArea = false;
  13. }else{
  14. _inArea = true;
  15. _eh1 = _unit addEventHandler ["fired", {deleteVehicle (_this select 6);}];
  16. };
  17.  
  18.  
  19.  
  20. while {true} do {
  21.  
  22.  
  23. if (((_zone1 distance _unit < _dis) or (_zone2 distance _unit < _dis)) && (!_inArea)) then { // check if unit enters
  24.  
  25. _eh1 = _unit addEventHandler ["fired", {deleteVehicle (_this select 6);}];
  26. _inArea = true;
  27. hint "safe zone";
  28. };
  29.  
  30.  
  31. if (((_zone1 distance _unit > _dis) or (_zone2 distance _unit > _dis)) && (_inArea)) then { // check if unit exits
  32.  
  33. _unit removeEventHandler ["fired", _eh1];
  34. _inArea = false;
  35. hint "You just left the safe zone";
  36. };
  37.  
  38. sleep 5;
  39.  
  40. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement