Advertisement
Guest User

Untitled

a guest
Aug 30th, 2014
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.41 KB | None | 0 0
  1. /*
  2. VEHICLE CLEANUP ZONE
  3. Script by HALV
  4. */
  5. _obj = _this select 0;
  6.  
  7. if (!isServer) exitWith {diag_log "Server_DeleteObjInsafezone.sqf - ERROR: NOT SERVER?"};
  8.  
  9. //\\\\\\\\\\\\\\\\\\\\ Setup Area ////////////////////\\
  10.  
  11. //vehicle types to Check for
  12. _delVeh = ["Air","Landvehicle","Ship","Tank"];
  13.  
  14. //Action to take when vehicle is detected in a [VEHICLE CLEANUP ZONE]
  15. //0 Delete vehicles ingame but keep in database. NOTE: This will stack vehicles in database if not cleaned propper
  16. //1 Tp vehicles outside [VEHICLE CLEANUP ZONE] ("radius" + 50 meter to 4x "radius" from VEHICLE CLEANUP ZONE pos eg: if radius is 100 vehicles are moved 150-400 meter away)
  17. //2 Tp vehicles to a position within 125m of _safespot (remember to set a position below)
  18. //3 will delete vehicles completly from database
  19. _Action = 1;
  20.  
  21. //if _Action = 2 then enter the position you desire here (default is by grozovoy pass around 022010)
  22. _safespot = [2283.19,14255,0];
  23. //how large radius to spread them in this area in meters (default 125m)
  24. _radius = 125;
  25.  
  26. //damaged above this amoun, vehicle is deleted (set to 1 to only delete completely destroyed vehicles)
  27. _dam = 0.90;
  28.  
  29. //if true will delete vehicles matching array below by default
  30. _delbikmot = true;
  31. //if above is true will delete these by default
  32. _defdelar = ["Bicycle","Motorcycle","CSJ_GyroC","CSJ_GyroCover","CSJ_GyroP"];//,"ATV_Base_EP1"
  33.  
  34. //set to true, to unlock vehicles by default when TP'ed
  35. _unlock = true;
  36.  
  37. //log text, this is what you want to look for in the logs, if you need to know something about a moved vehicle
  38. _txt = "[VEHICLE CLEANUP ZONE]";
  39.  
  40. //Update vehicles to the hive, and make sure they are not moved each restart?
  41. _updateHIVE = true;
  42.  
  43. //VEHICLE CLEANUP ZONE's/areas switch choosing the map name for cleanup location purposes
  44. if(isNil "HALV_VEHICLE_CLEANUPZONES")then{
  45. diag_log format["%1: selecting world to cleanup ...",_txt];
  46. _WorldName = toLower format ["%1", worldName];
  47. switch (_WorldName)do {
  48. //NAPF
  49. case "napf":{
  50. // diag_log format["%2: Cleanup zones for napf selected! (check: %1)",_WorldName,_txt]; //logging if right worldname was selected, if uncommented
  51. HALV_VEHICLE_CLEANUPZONES = [
  52. //position //radius //cityname/text
  53. [[8246.3184,15485.867,0], 125, "Trader City Lenzburg"],
  54. [[15506.952,13229.368,0], 125, "Trader city Emmen"],
  55. [[12399.751,5074.5273,0], 125, "Trader City Schratten"],
  56. [[10398.626,8279.4619,0], 125, "Bandit Vendor"],
  57. [[5149.9814,4864.1191,0], 125, "Hero Vendor"],
  58. [[2122.7954,7807.9878,0], 100, "West Wholesaler"],
  59. [[5379.0342,16103.187,0], 100, "North Wholesaler"],
  60. [[6772.8877,16983.27,0], 100, "Nordic Boats"],
  61. [[16839.973,5264.0566,0], 100, "Pauls Boats"],
  62. [[15128.379,16421.879,0], 100, "AWOLs Airfield"]
  63. ];
  64. };
  65. //chernarus
  66. case "chernarus":{
  67. // diag_log format["%2: Cleanup zones for chernarus selected! (check: %1)",_WorldName,_txt]; //logging if right worldname was selected, if uncommented
  68. HALV_VEHICLE_CLEANUPZONES = [
  69. //position radius cityname/text
  70. [[6325.6772,7807.7412,0], 125, "Trader City Stary"],
  71. [[4063.4226,11664.19,0], 125, "Trader City Bash"],
  72. [[11447.472,11364.504,0], 125, "Trader City Klen"],
  73. [[1606.6443,7803.5156,0], 125, "Bandit Camp"],
  74. [[12944.227,12766.889,0], 125, "Hero Camp"],
  75. [[13441.16,5429.3013,0], 100, "Wholesaler East"],
  76. [[4510.7773,10774.518,0], 100, "Aircraft Dealer"],
  77. [[7989.3354,2900.9946,0], 100, "Boat Dealer South"],
  78. [[13532.614,6355.9497,0], 100, "Boat Dealer East"],
  79. [[4361.4937,2259.9526,0], 100, "Wholesaler South"]
  80. ];
  81. };
  82. //tavi
  83. case "tavi":{
  84. // diag_log format["%2: Cleanup zones for tavi selected! (check: %1)",_WorldName,_txt]; //logging if right worldname was selected, if uncommented
  85. HALV_VEHICLE_CLEANUPZONES = [
  86. //position //radius //cityname/text
  87. [[11698.81,15210.121,0], 75, "Trader City Lyepestok"],
  88. [[15309.663,9278.4912,0], 75, "Trader City Sabina"],
  89. [[5538.7354,8762.2695,0], 75, "Trader City Bilgrad"],
  90. [[7376.6084,4296.5879,0], 75, "Trader City Branibor"],
  91. [[10948.426,654.90265,0], 75, "Bandit Vendor"],
  92. [[15587.822,16394.049,0], 75, "Hero Vendor"],
  93. [[16555.732,10159.68,0], 75, "Aircraft Dealer"],
  94. [[6815.0776,8534.1504,0], 75, "Aircraft Dealer 2"],
  95. [[4066.3528,7265.0024,0], 75, "Misc. Vendor"],
  96. [[17497.631,7159.0879,0], 75, "Misc. Vendor 2"],
  97. [[17332.115,12930.239,0], 75, "Boat Dealer"],
  98. [[10570.494,16772.477,0], 75, "Boat Dealer 2"],
  99. [[10698.463,5983.665,0], 75, "Boat Dealer 3"],
  100. [[5419.2437,9503.5479,0], 75, "Boat Dealer 4"],
  101. [[13342.758,8611.9932,0], 75, "Wholesaler"],
  102. [[9859.4209,7471.5684,0], 75, "Wholesaler"] // <-- no comma for last entry
  103. ];
  104. };
  105. /*
  106. //myworldname
  107. case "myworldnameinlowercase":{
  108. // diag_log format["%2: Cleanup zones for myworldnameinlowercase selected! (check: %1)",_WorldName,_txt]; //logging if right worldname was selected, if uncommented
  109. HALV_VEHICLE_CLEANUPZONES = [
  110. //position //radius //cityname/text
  111. [[7839.60,8414.73,381.33], 150, "my custom zone marker"],
  112. [[7839.60,8414.73,381.33], 75, "my custom location"] // <-- no comma for last entry
  113. ];
  114. };
  115. */
  116. //default
  117. default{
  118. diag_log format["%2: Cleanup zones for %1 not availible ...",_WorldName,_txt]; //logging if right worldname was selected, if uncommented
  119. HALV_VEHICLE_CLEANUPZONES = [
  120. //position //radius //cityname/text
  121. [[0,0,0], 1, "DEBUG"]
  122. ];
  123. };
  124. };
  125. };
  126. //\\\\\\\\\\\\\\\\\\\\ End Setup Area ////////////////////\\
  127.  
  128. /////////////// dont touch anything below this line unless you know what you are doing \\\\\\\\\\\\\\\
  129.  
  130. _possiblematch = false;
  131. {if(_obj isKindOf _x)then{_possiblematch=true;};}forEach _delVeh;
  132. if(_possiblematch)then{
  133. {
  134. _Spos = _x select 0;
  135. _Rad = _x select 1;
  136. _name = _x select 2;
  137. _radats = _Rad+50;
  138. _radx4 = _Rad+_Rad+_Rad+_Rad;
  139. if(_obj distance _Spos < _Rad)then{
  140. _defdel = false;
  141. _typeOf = typeOf _obj;
  142. _pos = getpos _obj;
  143. _mags = getmagazinecargo _obj;
  144. _weaps = getweaponcargo _obj;
  145. _packs = getbackpackcargo _obj;
  146. _objID = _obj getVariable["ObjectID","0"];
  147. _objUID = _obj getVariable["ObjectUID","0"];
  148. _objname = (gettext (configFile >> 'CfgVehicles' >> _typeOf >> 'displayName'));
  149. diag_log format["%1: %2 (%3) by %4 @%5 %6 [ID:%7,UID:%8] Cargo: [%9,%10,%11]",_txt,_typeOf,_objname,_name,mapgridposition _pos,_pos,_objID,_objUID,_weaps,_mags,_packs];
  150. if(_delbikmot)then{{if(_obj isKindOf _x)then{_defdel = true};}forEach _defdelar;};
  151. if(_defdel)then{_Action=3;diag_log format["%2: %1 is Model to delete by default!",_typeOf,_txt];};
  152. if(getDammage _obj > _dam)then{_Action=3;diag_log format["%2: %1 too damaged",_typeOf,_txt];};
  153. if(_unlock and !_defdel and (locked _obj))then{_obj setVehicleLock "UNLOCKED";_obj setVariable ["R3F_LOG_disabled",false,true];diag_log format["%2: %1 Un-Locked",_typeOf,_txt];};
  154. switch(_Action)do{
  155. case 0:{deleteVehicle _obj;diag_log format["%2: %1 Deleted, but remains in DB (Dont forget to clean this up)",_typeOf,_txt];};
  156. case 1:{
  157. _newPos = [_Spos, _radats, _radx4, 10, 0, 2000, 0] call BIS_fnc_findSafePos;
  158. _obj setpos _newPos;
  159. //update to HIVE?
  160. if(_updateHIVE)then{
  161. private["_position","_worldspace","_fuel","_key"];
  162. _position = getPosATL _obj;
  163. _worldspace = [
  164. round(direction _obj),
  165. _position
  166. ];
  167. _fuel = fuel _obj;
  168. _key = format["CHILD:305:%1:%2:%3:",_objID,_worldspace,_fuel];
  169. diag_log ("HIVE: WRITE: "+ str(_key));
  170. _key call server_hiveWrite;
  171. };
  172. diag_log format["%6: %5 TP from %1 %2 to %3 %4",_pos,mapgridposition _pos,_newPos,mapgridposition _newPos,_typeOf,_txt];
  173. };
  174. case 2:{
  175. _newPos = [_safespot, 0, _radius, 10, 0, 2000, 0] call BIS_fnc_findSafePos;
  176. _obj setpos _newPos;
  177. //update to HIVE?
  178. if(_updateHIVE)then{
  179. private["_position","_worldspace","_fuel","_key"];
  180. _position = getPosATL _obj;
  181. _worldspace = [
  182. round(direction _obj),
  183. _position
  184. ];
  185. _fuel = fuel _obj;
  186. _key = format["CHILD:305:%1:%2:%3:",_objID,_worldspace,_fuel];
  187. diag_log ("HIVE: WRITE: "+ str(_key));
  188. _key call server_hiveWrite;
  189. };
  190. diag_log format["%6: %5 TP from %1 %2 to %3 %4",_pos,mapgridposition _pos,_newPos,mapgridposition _newPos,_typeOf,_txt];
  191. };
  192. default{_msg = format["%2: %1",_typeOf,_txt];deleteVehicle _obj;[_objID,_objUID,_msg] call server_deleteObj;};
  193. };
  194. };
  195. }forEach HALV_VEHICLE_CLEANUPZONES;
  196. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement