Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.22 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Oxide.Core.Database;
  5. using Oxide.Core.Libraries.Covalence;
  6. using UnityEngine;
  7. using System.Collections;
  8. using Oxide.Core;
  9. using UnityEngine.Scripting;
  10. using System.Linq;
  11.  
  12. namespace Oxide.Plugins
  13. {
  14. [Info("AutomaticEvents", "531devv (531devv@gmail.com)", "1.0.0")]
  15. [Description("Automatic events for Hurtworld.")]
  16.  
  17. class AutomaticEvents : HurtworldPlugin
  18. {
  19. public static GameObject gameObject;
  20.  
  21. void Loaded()
  22. {
  23. timer.Repeat(18000f, 0, () =>
  24. {
  25. var allPlayers = GameManager.Instance.GetSessions().Values.ToList();
  26. if (allPlayers.Count() < 0)
  27. {
  28. hurt.BroadcastChat(null, "Za malo graczy, evencik loteria przepada! :(");
  29. }
  30. else if ((allPlayers.Count() >= 1) && (allPlayers.Count() <= 20))
  31. {
  32. StartLotteryEvent();
  33. }
  34. else if ((allPlayers.Count() >= 20) && (allPlayers.Count() <= 30))
  35. {
  36. StartLotteryEvent();
  37. StartLotteryEvent();
  38. }
  39. else if ((allPlayers.Count() >= 30) && (allPlayers.Count() <= 40))
  40. {
  41. StartLotteryEvent();
  42. StartLotteryEvent();
  43. StartLotteryEvent();
  44. }
  45. else if ((allPlayers.Count() >= 40) && (allPlayers.Count() <= 50))
  46. {
  47. StartLotteryEvent();
  48. StartLotteryEvent();
  49. StartLotteryEvent();
  50. StartLotteryEvent();
  51. }
  52. else if ((allPlayers.Count() >= 50) && (allPlayers.Count() <= 60))
  53. {
  54. StartLotteryEvent();
  55. StartLotteryEvent();
  56. StartLotteryEvent();
  57. StartLotteryEvent();
  58. StartLotteryEvent();
  59. }
  60. else if ((allPlayers.Count() >= 60) && (allPlayers.Count() <= 70))
  61. {
  62. StartLotteryEvent();
  63. StartLotteryEvent();
  64. StartLotteryEvent();
  65. StartLotteryEvent();
  66. StartLotteryEvent();
  67. StartLotteryEvent();
  68. }
  69. else if ((allPlayers.Count() >= 70) && (allPlayers.Count() <= 80))
  70. {
  71. StartLotteryEvent();
  72. StartLotteryEvent();
  73. StartLotteryEvent();
  74. StartLotteryEvent();
  75. StartLotteryEvent();
  76. StartLotteryEvent();
  77. StartLotteryEvent();
  78. }
  79. else if ((allPlayers.Count() >= 80) && (allPlayers.Count() <= 90))
  80. {
  81. StartLotteryEvent();
  82. StartLotteryEvent();
  83. StartLotteryEvent();
  84. StartLotteryEvent();
  85. StartLotteryEvent();
  86. StartLotteryEvent();
  87. StartLotteryEvent();
  88. StartLotteryEvent();
  89. }
  90. else if ((allPlayers.Count() >= 90) && (allPlayers.Count() <= 100))
  91. {
  92. StartLotteryEvent();
  93. StartLotteryEvent();
  94. StartLotteryEvent();
  95. StartLotteryEvent();
  96. StartLotteryEvent();
  97. StartLotteryEvent();
  98. StartLotteryEvent();
  99. StartLotteryEvent();
  100. StartLotteryEvent();
  101. }
  102. });
  103. }
  104.  
  105. void StartLotteryEvent()
  106. {
  107. var ItemMgr = Singleton<GlobalItemManager>.Instance;
  108. var allPlayers = GameManager.Instance.GetSessions().Values.ToList();
  109. if (allPlayers.Count() > 0)
  110. {
  111. int randomInt = UnityEngine.Random.Range(0, allPlayers.Count());
  112. var playerId = allPlayers[randomInt].SteamId;
  113. var playerName = allPlayers[randomInt].Name;
  114. var playerN = Player.FindById(playerId.ToString()).Player;
  115.  
  116. int randomItemInt = UnityEngine.Random.Range(0, 4);
  117.  
  118. ItemMgr.GiveItem(playerN, ItemMgr.GetItem(231), 1);
  119. Puts("Lottery Event starting..");
  120. hurt.BroadcastChat(null, "<color=#33FF33>[Loteria Event]</color>: " + playerName + " wygral <color=#FF0000>1 Detonator!</color>");
  121. }
  122. }
  123.  
  124. void StartAlbinoEvent()
  125. {
  126. SpawnObject("AITokarAlbinoServer", -3319, 197, -1506);
  127. SpawnObject("AITokarAlbinoServer", -2308, 195, -997);
  128. SpawnObject("AITokarAlbinoServer", 1486, 192, -1946);
  129. SpawnObject("AITokarAlbinoServer", 1170, 192, -3366);
  130. SpawnObject("AITokarAlbinoServer", -2605, 170, 1626);
  131. SpawnObject("AITokarAlbinoServer", -1250, 172, 1185);
  132.  
  133. Puts("Albino event starting..");
  134.  
  135. hurt.BroadcastChat(null, "<color=#3399CC>Albinosy</color> <color=#008080ff>wykluwają się co godzinę na hangarach !</color>");
  136. }
  137.  
  138. [ChatCommand("loteria")]
  139. void lotteryEvent(PlayerSession player, string command, string[] args)
  140. {
  141. if (player.IsAdmin)
  142. {
  143. var allPlayers = GameManager.Instance.GetSessions().Values.ToList();
  144. if (allPlayers.Count() < 0)
  145. {
  146. hurt.BroadcastChat(null, "Za malo graczy, evencik przepada! :(");
  147. }
  148. else if ((allPlayers.Count() >= 1) && (allPlayers.Count() <= 20))
  149. {
  150. StartLotteryEvent();
  151. }
  152. else if ((allPlayers.Count() >= 20) && (allPlayers.Count() <= 30))
  153. {
  154. StartLotteryEvent();
  155. StartLotteryEvent();
  156. }
  157. else if ((allPlayers.Count() >= 30) && (allPlayers.Count() <= 40))
  158. {
  159. StartLotteryEvent();
  160. StartLotteryEvent();
  161. StartLotteryEvent();
  162. }
  163. else if ((allPlayers.Count() >= 40) && (allPlayers.Count() <= 50))
  164. {
  165. StartLotteryEvent();
  166. StartLotteryEvent();
  167. StartLotteryEvent();
  168. StartLotteryEvent();
  169. }
  170. else if ((allPlayers.Count() >= 50) && (allPlayers.Count() <= 60))
  171. {
  172. StartLotteryEvent();
  173. StartLotteryEvent();
  174. StartLotteryEvent();
  175. StartLotteryEvent();
  176. StartLotteryEvent();
  177. }
  178. else if ((allPlayers.Count() >= 60) && (allPlayers.Count() <= 70))
  179. {
  180. StartLotteryEvent();
  181. StartLotteryEvent();
  182. StartLotteryEvent();
  183. StartLotteryEvent();
  184. StartLotteryEvent();
  185. StartLotteryEvent();
  186. }
  187. else if ((allPlayers.Count() >= 70) && (allPlayers.Count() <= 80))
  188. {
  189. StartLotteryEvent();
  190. StartLotteryEvent();
  191. StartLotteryEvent();
  192. StartLotteryEvent();
  193. StartLotteryEvent();
  194. StartLotteryEvent();
  195. StartLotteryEvent();
  196. }
  197. else if ((allPlayers.Count() >= 80) && (allPlayers.Count() <= 90))
  198. {
  199. StartLotteryEvent();
  200. StartLotteryEvent();
  201. StartLotteryEvent();
  202. StartLotteryEvent();
  203. StartLotteryEvent();
  204. StartLotteryEvent();
  205. StartLotteryEvent();
  206. StartLotteryEvent();
  207. }
  208. else if ((allPlayers.Count() >= 90) && (allPlayers.Count() <= 100))
  209. {
  210. StartLotteryEvent();
  211. StartLotteryEvent();
  212. StartLotteryEvent();
  213. StartLotteryEvent();
  214. StartLotteryEvent();
  215. StartLotteryEvent();
  216. StartLotteryEvent();
  217. StartLotteryEvent();
  218. StartLotteryEvent();
  219. }
  220. }
  221. else
  222. {
  223. hurt.SendChatMessage(player, null, "Nie jesteś adminem !");
  224. }
  225. }
  226.  
  227. [ChatCommand("albinosy")]
  228. void albinoEvent(PlayerSession player, string command, string[] args)
  229. {
  230. if (player.IsAdmin)
  231. {
  232. StartAlbinoEvent();
  233. }
  234. else
  235. {
  236. hurt.SendChatMessage(player, null, "Nie jesteś adminem !");
  237. }
  238. }
  239.  
  240. #region Helpers
  241.  
  242.  
  243. public void SpawnObject(string monster, float x, float y, float z)
  244. {
  245. Vector3 position = new Vector3(x + Core.Random.Range(0, 2),
  246. y + Core.Random.Range(0, 2),
  247. z + Core.Random.Range(0, 1));
  248. RaycastHit hitInfo;
  249. Physics.Raycast(position, Vector3.down, out hitInfo);
  250. {
  251. Quaternion rotation = Quaternion.Euler(0.0f, (float)UnityEngine.Random.Range(0f, 360f), 0.0f);
  252. rotation = Quaternion.FromToRotation(Vector3.down, hitInfo.normal) * rotation;
  253. gameObject = Singleton<HNetworkManager>.Instance.NetInstantiate(monster, hitInfo.point, Quaternion.identity, GameManager.GetSceneTime());
  254. Destroy(gameObject);
  255. }
  256. }
  257.  
  258. void Destroy(GameObject obj)
  259. {
  260. timer.Once(3600, () =>
  261. {
  262. Singleton<HNetworkManager>.Instance.NetDestroy(uLink.NetworkView.Get(obj));
  263. });
  264. }
  265.  
  266. #endregion
  267.  
  268.  
  269. }
  270. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement