Guest User

Untitled

a guest
Sep 7th, 2023
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.20 KB | None | 0 0
  1. using Newtonsoft.Json;
  2. namespace Oxide.Plugins
  3. {
  4. [Info("Health Vehicles", "SwenenzY", "1.1.0")]
  5. [Description("Raises vehicles health.")]
  6. public class HealthVehicles : RustPlugin
  7. {
  8. #region Config
  9.  
  10. private ConfigFile _config;
  11. public class ConfigFile
  12. {
  13. // Mini
  14. [JsonProperty(PropertyName = "Mini start health ( ex : 500 )")]
  15. public float MiniStartHealth;
  16. [JsonProperty(PropertyName = "Mini max health ( ex : 1000 )")]
  17. public float MiniMaxHealth;
  18. // Scrap
  19. [JsonProperty(PropertyName = "Scrap start health ( ex : 500 )")]
  20. public float ScrapStartHealth;
  21. [JsonProperty(PropertyName = "Scrap max health ( ex : 2000 )")]
  22. public float ScrapMaxHealth;
  23. // Balloon
  24. [JsonProperty(PropertyName = "Balloon start health ( ex : 500 )")]
  25. public float BalloonStartHealth;
  26. [JsonProperty(PropertyName = "Balloon max health ( ex : 2000 )")]
  27. public float BalloonMaxHealth;
  28. // rhib
  29. [JsonProperty(PropertyName = "Rhib start health ( ex : 500 )")]
  30. public float RhibStartHealth;
  31. [JsonProperty(PropertyName = "Rhib max health ( ex : 500 )")]
  32. public float RhibMaxHealth;
  33. // rowboat
  34. [JsonProperty(PropertyName = "Rowboat start health ( ex : 400 )")]
  35. public float RowboatStartHealth;
  36. [JsonProperty(PropertyName = "Rowboat max health ( ex : 400 )")]
  37. public float RowboatMaxHealth;
  38. // Tugboat
  39. [JsonProperty(PropertyName = "Tugboat start health ( ex : 400 )")]
  40. public float TugboatStartHealth;
  41. [JsonProperty(PropertyName = "Tugboat max health ( ex : 400 )")]
  42. public float TugboatMaxHealth;
  43. // workcart
  44. [JsonProperty(PropertyName = "Workcart start health ( ex : 1000 )")]
  45. public float WorkcartStartHealth;
  46. [JsonProperty(PropertyName = "Workcart max health ( ex : 1000 )")]
  47. public float WorkcartMaxHealth;
  48. // TrainCar
  49. [JsonProperty(PropertyName = "Traincar start health ( ex : 1000 )")]
  50. public float TraincarStartHealth;
  51. [JsonProperty(PropertyName = "Traincar max health ( ex : 1000 )")]
  52. public float TraincarMaxHealth;
  53. // MagnetCrane
  54. [JsonProperty(PropertyName = "Magnetcrane start health ( ex : 500 )")]
  55. public float MagnetcraneStartHealth;
  56. [JsonProperty(PropertyName = "Magnetcrane max health ( ex : 500 )")]
  57. public float MagnetcraneMaxHealth;
  58. // SubSolo
  59. [JsonProperty(PropertyName = "Submarinesolo start health ( ex : 500 )")]
  60. public float SubmarinesoloStartHealth;
  61. [JsonProperty(PropertyName = "Submarinesolo max health ( ex : 500 )")]
  62. public float SubmarinesoloMaxHealth;
  63. // SubDuo
  64. [JsonProperty(PropertyName = "Submarineduo start health ( ex : 700 )")]
  65. public float SubmarineduoStartHealth;
  66. [JsonProperty(PropertyName = "Submarineduo max health ( ex : 700 )")]
  67. public float SubmarineduoMaxHealth;
  68. // Snowmobile
  69. [JsonProperty(PropertyName = "Snowmobile start health ( ex : 300 )")]
  70. public float SnowmobileStartHealth;
  71. [JsonProperty(PropertyName = "Snowmobile max health ( ex : 300 )")]
  72. public float SnowmobileMaxHealth;
  73. // tomhaSnowmobile
  74. [JsonProperty(PropertyName = "Tomahasnowmobile start health ( ex : 300 )")]
  75. public float TomahasnowmobileStartHealth;
  76. [JsonProperty(PropertyName = "Tomahasnowmobile max health ( ex : 300 )")]
  77. public float TomahasnowmobileMaxHealth;
  78. // Ch47
  79. [JsonProperty(PropertyName = "Ch47 start health ( ex : 2000 )")]
  80. public float Ch47StartHealth;
  81. [JsonProperty(PropertyName = "Ch47 max health ( ex : 2000 )")]
  82. public float Ch47MaxHealth;
  83.  
  84. public static ConfigFile DefaultConfig()
  85. {
  86. return new ConfigFile
  87. {
  88. // Mini
  89. MiniStartHealth = 500f,
  90. MiniMaxHealth = 1000f,
  91. // Scrap
  92. ScrapStartHealth = 500f,
  93. ScrapMaxHealth = 2000f,
  94. // Balloon
  95. BalloonStartHealth = 500f,
  96. BalloonMaxHealth = 2000f,
  97. // Rhib
  98. RhibStartHealth = 500f,
  99. RhibMaxHealth = 2000f,
  100. // Rowboat
  101. RowboatStartHealth = 500f,
  102. RowboatMaxHealth = 2000f,
  103. // Tugboat
  104. TugboatStartHealth = 3000f,
  105. TugboatMaxHealth = 3000f,
  106. // Workcart
  107. WorkcartStartHealth = 500f,
  108. WorkcartMaxHealth = 2000f,
  109. // Workcartabove
  110. TraincarStartHealth = 500f,
  111. TraincarMaxHealth = 2000f,
  112. // Magnetcrane
  113. MagnetcraneStartHealth = 500f,
  114. MagnetcraneMaxHealth = 2000f,
  115. // Subsolo
  116. SubmarinesoloStartHealth = 500f,
  117. SubmarinesoloMaxHealth = 2000f,
  118. // Subduo
  119. SubmarineduoStartHealth = 500f,
  120. SubmarineduoMaxHealth = 2000f,
  121. // snowmobile
  122. SnowmobileStartHealth = 500f,
  123. SnowmobileMaxHealth = 2000f,
  124. // tomhaSnowmobile
  125. TomahasnowmobileStartHealth = 500f,
  126. TomahasnowmobileMaxHealth = 2000f,
  127. // Ch47
  128. Ch47StartHealth = 500f,
  129. Ch47MaxHealth = 2000f,
  130.  
  131. };
  132. }
  133. }
  134. protected override void LoadDefaultConfig() => _config = ConfigFile.DefaultConfig();
  135.  
  136. protected override void LoadConfig()
  137. {
  138. base.LoadConfig();
  139. _config = Config.ReadObject<ConfigFile>();
  140. }
  141. protected override void SaveConfig() => Config.WriteObject(_config);
  142.  
  143. #endregion
  144.  
  145. #region Vehicles
  146.  
  147. #region Mini Copter
  148.  
  149. void OnEntitySpawned(MiniCopter mini)
  150. {
  151. if (mini == null)
  152. {
  153. return;
  154. }
  155.  
  156. mini.SetMaxHealth(_config.MiniMaxHealth);
  157. mini._health = _config.MiniStartHealth;
  158. }
  159.  
  160. #endregion
  161.  
  162. #region Scrap Copter
  163.  
  164. void OnEntitySpawned(ScrapTransportHelicopter scrap)
  165. {
  166. if (scrap == null)
  167. {
  168. return;
  169. }
  170.  
  171. scrap.SetMaxHealth(_config.ScrapMaxHealth);
  172. scrap._health = _config.ScrapStartHealth;
  173.  
  174. }
  175.  
  176. #endregion
  177.  
  178. #region Balloon
  179.  
  180. void OnEntitySpawned(HotAirBalloon balloon)
  181. {
  182. if (balloon == null)
  183. {
  184. return;
  185. }
  186.  
  187. balloon.SetMaxHealth(_config.BalloonMaxHealth);
  188. balloon._health = _config.BalloonStartHealth;
  189.  
  190. }
  191.  
  192. #endregion
  193.  
  194. #region Rhib
  195.  
  196. void OnEntitySpawned(RHIB ib)
  197. {
  198. if (ib == null)
  199. {
  200. return;
  201. }
  202.  
  203. ib.SetMaxHealth(_config.RhibMaxHealth);
  204. ib._health = _config.RhibStartHealth;
  205.  
  206. }
  207.  
  208. #endregion
  209.  
  210. #region Rowboat
  211.  
  212. void OnEntitySpawned(MotorRowboat bt)
  213. {
  214. if (bt == null)
  215. {
  216. return;
  217. }
  218.  
  219. bt.SetMaxHealth(_config.RowboatMaxHealth);
  220. bt._health = _config.RowboatStartHealth;
  221.  
  222. }
  223.  
  224. #endregion
  225.  
  226.  
  227. #region Tugboat
  228.  
  229. void OnEntitySpawned(Tugboat tb)
  230. {
  231. if (tb == null)
  232. {
  233. return;
  234. }
  235.  
  236. tb.SetMaxHealth(_config.TugboatMaxHealth);
  237. tb._health = _config.TugboatStartHealth;
  238.  
  239. }
  240.  
  241. #endregion
  242.  
  243. #region Workcart
  244.  
  245. void OnEntitySpawned(TrainEngine tengine)
  246. {
  247. if (tengine == null)
  248. {
  249. return;
  250. }
  251.  
  252. tengine.SetMaxHealth(_config.WorkcartMaxHealth);
  253. tengine._health = _config.WorkcartStartHealth;
  254.  
  255. }
  256.  
  257. #endregion
  258.  
  259. #region TrainCar
  260.  
  261. void OnEntitySpawned(TrainCar tcar)
  262. {
  263. if (tcar == null)
  264. {
  265. return;
  266. }
  267.  
  268. tcar.SetMaxHealth(_config.TraincarMaxHealth);
  269. tcar._health = _config.TraincarStartHealth;
  270.  
  271. }
  272.  
  273. #endregion
  274.  
  275. #region Magnetcrane
  276.  
  277. void OnEntitySpawned(MagnetCrane magnet)
  278. {
  279. if (magnet == null)
  280. {
  281. return;
  282. }
  283.  
  284. magnet.SetMaxHealth(_config.MagnetcraneMaxHealth);
  285. magnet._health = _config.MagnetcraneStartHealth;
  286.  
  287. }
  288.  
  289. #endregion
  290.  
  291. #region Submarinesolo
  292.  
  293. void OnEntitySpawned(BaseSubmarine sms)
  294. {
  295. if (sms == null)
  296. {
  297. return;
  298. }
  299.  
  300. sms.SetMaxHealth(_config.SubmarinesoloMaxHealth);
  301. sms._health = _config.SubmarinesoloStartHealth;
  302.  
  303. }
  304.  
  305. #endregion
  306.  
  307. #region Submarineduo
  308.  
  309. void OnEntitySpawned(SubmarineDuo smd)
  310. {
  311. if (smd == null)
  312. {
  313. return;
  314. }
  315.  
  316. smd.SetMaxHealth(_config.SubmarineduoMaxHealth);
  317. smd._health = _config.SubmarineduoStartHealth;
  318.  
  319. }
  320.  
  321. #endregion
  322.  
  323. #region Snowmobile
  324.  
  325. void OnEntitySpawned(Snowmobile sm)
  326. {
  327. if (sm == null)
  328. {
  329. return;
  330. }
  331.  
  332. sm.SetMaxHealth(_config.SnowmobileMaxHealth);
  333. sm._health = _config.SnowmobileStartHealth;
  334.  
  335. }
  336.  
  337. #endregion
  338.  
  339. // #region Tomahasnowmobile
  340.  
  341. // void OnEntitySpawned(tomahaSnowmobile tsm)
  342. // {
  343. // if (tsm == null)
  344. // {
  345. // return;
  346. // }
  347.  
  348. // tsm.SetMaxHealth(_config.TomahaSnowMobileMaxHealth);
  349. // tsm._health = _config.TomahaSnowMobileStartHealth;
  350.  
  351. // }
  352.  
  353. // #endregion
  354.  
  355. #region Ch47
  356.  
  357.  
  358. void OnEntitySpawned(CH47Helicopter ch)
  359. {
  360. if (ch == null)
  361. {
  362. return;
  363. }
  364.  
  365. ch.SetMaxHealth(_config.Ch47MaxHealth);
  366. ch._health = _config.Ch47StartHealth;
  367.  
  368. }
  369.  
  370.  
  371. #endregion
  372.  
  373.  
  374.  
  375.  
  376.  
  377. #endregion
  378. }
  379. }
Advertisement
Add Comment
Please, Sign In to add comment