Halvhjearne

server_deleteObjInsafezone.sqf

Feb 1st, 2014
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.78 KB | None | 0 0
  1. //Script by HALV
  2. private["_obj","_typeOf","_dist","_delVeh","_safezones","_possiblematch","_Action","_safespot","_dam","_delbikmot","_defdelar"];
  3. _obj = _this select 0;
  4. _typeOf = typeOf _obj;
  5. //vehicle types to Check for
  6. _delVeh = ["Air","Landvehicle","Ship","Tank"];
  7. // Delete/Tp vehicles within this distance from safezone areas
  8. _dist=100;
  9. //Action to take when vehicle is detected in a safezone
  10. //0 Delete vehicles ingame but keep in database. NOTE: This will stack vehicles in database if not cleaned propper
  11. //1 Tp vehicles outside safezone (150-400m from safezone pos)
  12. //2 Tp vehicles to a position within 125m of _safespot (remember to set a position below)
  13. //3 will delete vehicles completly from database
  14. _Action=2;
  15. //if _Action=2 enter a position here (default is by grozovoy pass around 022010)
  16. _safespot=[2283.19,14255,0];
  17. //damaged above this amount will be deleted
  18. _dam=0.90;
  19.  
  20. //if true will delete vehicles matching array below by default
  21. _delbikmot=true;
  22. //if above is true will delete these by default
  23. _defdelar=["Bicycle","Motorcycle","ATV_Base_EP1","CSJ_GyroC","CSJ_GyroCover","CSJ_GyroP"];
  24.  
  25. //safezone areas
  26. _safezones = [
  27. [6325.6772,7807.7412,0],//trader city Stary
  28. [4063.4226,11664.19, 0],//trader city Bash
  29. [11447.472,11364.504,0],//trader city Klen
  30. [1606.6443,7803.5156,0],//Bandit Trader
  31. [12944.227,12766.889,0],//Hero Trader
  32. [8110.9663,9246.5137,0],//Old Mansion
  33. [13441.16,5429.3013, 0],//BoatDealerEast
  34. [4510.7773,10774.518,0],//AirVehicles
  35. [7989.3354,2900.9946,0],//BoatDealerSouth
  36. [13532.614,6355.9497,0],//boatTraderEast
  37. [4361.4937,2259.9526,0],//wholesaleSouth
  38. [6711.9756,14201.991,0],//NPC base
  39. [6611.9756,14201.991,0],//NPC base
  40. [6511.9756,14201.991,0] //NPC base
  41. ];
  42.  
  43. ///************ dont touch anything below this line unless you know what you are doing ************///
  44. _possiblematch=false;
  45. {if(_obj isKindOf _x)then{_possiblematch=true;};}forEach _delVeh;
  46. if(_possiblematch)then{
  47.     {
  48.         if(_obj distance _x < _dist)then{
  49. private["_pos","_mags","_weaps","_packs","_objID","_objUID","_Spos","_nearestCity","_textCity","_txt"];
  50.             _Spos       = _x;
  51.             _pos        = getpos _obj;
  52.             _mags       = getmagazinecargo _obj;
  53.             _weaps      = getweaponcargo _obj;
  54.             _packs      = getbackpackcargo _obj;
  55.             _objID      = _obj getVariable["ObjectID","0"];
  56.             _objUID     = _obj getVariable["ObjectUID","0"];
  57.             _textCity   = "Unknown";
  58.             _nearestCity = nearestLocations [_Spos, ["NameCityCapital","NameCity","NameVillage","NameLocal"],1000];
  59.             if (count _nearestCity > 0) then {_textCity = text (_nearestCity select 0)};
  60.             _txt = (gettext (configFile >> 'CfgVehicles' >> _typeOf >> 'displayName'));
  61.             diag_log format["VEHICLE IN SAFEZONE: %1 (%2) @ %3 %4 %5 [ID:%6,UID:%7] Cargo: [%8,%9,%10]",_txt,_typeOf,_textCity,mapgridposition _pos,_pos,_objID,_objUID,_weaps,_mags,_packs];
  62.             if(_delbikmot)then{{if(_obj isKindOf _x)then{_Action=3;diag_log "Model from delete by default detected...";};}forEach _defdelar;};
  63.             if(getDammage _obj > _dam)then{_Action=3;diag_log "Vehicle too damaged";};
  64.             switch(_Action)do{
  65.                 case 0:{
  66.                     deleteVehicle _obj;
  67.                     diag_log "Vehicle delteted, but remains in DB";
  68.                 };
  69.                 case 1:{
  70.                     private["_newPos"];
  71.                     _newPos = [_Spos, 150, 400, 10, 0, 2000, 0] call BIS_fnc_findSafePos;
  72.                     _obj setpos _newPos;
  73.                     diag_log format["Vehicle teleported from %1 %2 to %3 %4",_pos,mapgridposition _pos,_newPos,mapgridposition _newPos];
  74.                 };
  75.                 case 2:{
  76.                     private["_newPos"];
  77.                     _newPos = [_safespot, 0, 125, 10, 0, 2000, 0] call BIS_fnc_findSafePos;
  78.                     _obj setpos _newPos;
  79.                     diag_log format["Vehicle teleported from %1 %2 to %3 %4",_pos,mapgridposition _pos,_newPos,mapgridposition _newPos];
  80.                 };
  81.                 default{
  82.                     deleteVehicle _obj;
  83.                     [_objID,_objUID,"SERVER"] call server_deleteObj;
  84.                 };
  85.             };
  86.         };
  87.     }forEach _safezones;
  88. };
Advertisement
Add Comment
Please, Sign In to add comment