fleft17

Untitled

Sep 14th, 2014
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.22 KB | None | 0 0
  1. # Scatter Skript by Fleft. This is an advanced Skript. Use at your own risk. I am not responsible for any damage caused to servers because of this Skript.
  2.  
  3. # To disable/enable and of these features below, change them to simply "true" or "false.
  4.  
  5. # This was meant to be used in UHC games on www.reddit.com/r/ultrahardcore.
  6.  
  7.  
  8. options:
  9.  
  10.  
  11. #--------------------------------------------------
  12. # Options
  13. #--------------------------------------------------
  14.  
  15. Prefix: &7[&a&oFleft's &d&oScatter&7]
  16. # Prefix for scatter messages
  17.  
  18. ScatterSound: random.pop
  19. # Sound when person is scattered
  20.  
  21. ScatterPitch: 0.5
  22. # Pitch when person is scattered
  23.  
  24. HC: &b
  25. # Chat color when there's **x** seconds, **player**, misc
  26.  
  27. CC: &r
  28. # Main chat color
  29.  
  30.  
  31. Tries: 1001
  32. # Limit to how many times the Skript will attempt to load a given location
  33.  
  34. ChunkLoadTicks: 10
  35. # Time in between each chunk being loaded in ***TICKS***
  36.  
  37. BroadcastLoadedChunks: false
  38. # Broadcast when the command sender automatically loads each chunk
  39.  
  40. BroadcastScatteredPlayers: false
  41. # Broadcast when each individual is scattered
  42.  
  43. BroadcastFoundLocations: false
  44. # Broadcast when each individual location is found by the Skript (Very spammy)
  45.  
  46. LoadGeneratedChunks: true
  47. # Load the generated chunks? Takes longer, but less lag. You absolutely should use this with 30+ players.
  48.  
  49.  
  50.  
  51. #--------------------------------------------------
  52. # Command
  53. #--------------------------------------------------
  54.  
  55. command /sca [<world>] [<integer>] [<text>]:
  56. aliases: /fleftscatter, /flooftscatter
  57. permission: skript.sca
  58. trigger:
  59.  
  60. #--------------------------------------------------
  61. # Arguments
  62. #--------------------------------------------------
  63.  
  64. if arg-1 is not set:
  65. message "{@Prefix}{@CC} /sca <world> <radius> <*/teams/player>"
  66. command "/playsound random.break %command sender% ~ ~ ~ 1 1 1"
  67. stop trigger
  68. else if arg-2 is not set:
  69. message "{@Prefix}{@CC} /sca <world> <radius> <*/teams/player>"
  70. command "/playsound random.break %command sender% ~ ~ ~ 1 1 1"
  71. stop trigger
  72. else if arg-3 is not set:
  73. message "{@Prefix}{@CC} /sca <world> <radius> <*/teams/player>"
  74. command "/playsound random.break %command sender% ~ ~ ~ 1 1 1"
  75. stop trigger
  76.  
  77.  
  78. #--------------------------------------------------
  79. # FFA Scatter
  80. #--------------------------------------------------
  81.  
  82. if arg-3 is "all" or "*":
  83. set {_Scatter.ListOfAllPlayers::*} to all players
  84. set {_Scatter.AmountOfPlayers} to (size of {_Scatter.ListOfAllPlayers::*})
  85. if (size of ({_Scatter.ListOfAllPlayers::*})) is equal to 0:
  86. message "{@Prefix}{@CC} No one can be scattered!"
  87. stop trigger
  88. set {Scatter.DisableChunkUnload} to true
  89. set {_Scatter.world} to arg-1
  90. set {_Scatter.radius} to arg-2
  91. set {_Scatter.mindist} to (({_Scatter.radius}/{_Scatter.AmountOfPlayers})*3.5)
  92. broadcast "{@Prefix}{@CC} Attempting to scatter {@HC}%{_Scatter.AmountOfPlayers}%{@CC} players!"
  93. loop {_Scatter.AmountOfPlayers} times:
  94. loop {@Tries} times:
  95. if loop-number-2 is equal to {@Tries}:
  96. broadcast "{@Prefix}{@CC} Could not scatter %loop-number-1%/%{_Scatter.AmountOfPlayers}%"
  97. broadcast "{@Prefix}{@CC} Some players may have been scattered!"
  98. broadcast "{@Prefix}{@CC} You may want to /tpall!"
  99. command "/fleftscatterbroke random.break"
  100. stop trigger
  101. set {_Scatter.Location.Good} to true
  102. set {_Scatter.SkyLocation} to (the location at ((random integer between (0-{_Scatter.radius}) and ({_Scatter.radius}-1))+0.5), 255, ((random integer between (0-{_Scatter.radius}) and ({_Scatter.radius}-1))+0.5) of the world {_Scatter.world})
  103. loop ((loop-number-1)-1) times:
  104. if {_Scatter.Location.Good} is true:
  105. distance between {_Scatter.SkyLocation} and {_Scatter.FinalLocations.Sky::%loop-number-3%} is less than {_Scatter.mindist}:
  106. delete {_Scatter.Location.Good}
  107. if {_Scatter.Location.Good} is true:
  108. set {_Scatter.GroundLocation} to {_Scatter.SkyLocation}
  109. while (block at {_Scatter.GroundLocation}) is air:
  110. if y-coordinate of {_Scatter.GroundLocation} is less than 5:
  111. delete {_Scatter.Location.Good}
  112. stop loop
  113. set {_Scatter.GroundLocation} to location 1 below {_Scatter.GroundLocation}
  114. if {_Scatter.Location.Good} is true:
  115. if (block at {_Scatter.GroundLocation}) is cactus, water, or lava:
  116. delete {_Scatter.Location.Good}
  117. if {_Scatter.Location.Good} is true:
  118. set {_Scatter.GroundLocation} to (location 1 above {_Scatter.GroundLocation})
  119. add 1 to {_Scatter.GeneratedLocations}
  120. add 1 to {_Scatter.GenerationTime}
  121. add {_Scatter.SkyLocation} to {_Scatter.FinalLocations.Sky::*}
  122. add {_Scatter.GroundLocation} to {_Scatter.FinalLocations.Ground::*}
  123. add {_Scatter.GroundLocation} to {_Scatter.ChunkLoading::*}
  124. if {@BroadcastFoundLocations} is true:
  125. broadcast "{@Prefix}{@CC} Loaded location {@HC}%{_Scatter.GeneratedLocations}%{@CC} / {@HC}%{_Scatter.AmountOfPlayers}%"
  126. execute console command "/fleftscattersound"
  127. wait 1 tick
  128. stop loop
  129. broadcast "{@Prefix}{@CC} All locations found!"
  130. broadcast ""
  131. if {@LoadGeneratedChunks} is true:
  132. broadcast "{@Prefix}{@CC} Loading chunks at each location!"
  133. loop {_Scatter.AmountOfPlayers} times:
  134. command sender is not online:
  135. broadcast "{@Prefix}{@CC} Scatter failed, command sender logged out."
  136. loop all players:
  137. execute console command "/playsound random.break %loop-player % ~ ~ ~ 1 1 1"
  138. stop trigger
  139. else:
  140. add 1 to {_Scatter.LoadedChunks}
  141. set {_Scatter.ChunkLoaderLocation} to a random element out of {_Scatter.ChunkLoading::*}
  142. remove {_Scatter.ChunkLoaderLocation} from {_Scatter.ChunkLoading::*}
  143. teleport (command sender) to {_Scatter.ChunkLoaderLocation}
  144. if {@BroadcastLoadedChunks} is true:
  145. broadcast "{@Prefix}{@CC} Loaded {@HC}%{_Scatter.LoadedChunks}%{@CC}/{@HC}%{_Scatter.AmountOfPlayers}%"
  146. wait {@ChunkLoadTicks} ticks
  147. broadcast "{@Prefix}{@CC} Loading of chunks completed!"
  148. broadcast ""
  149. wait 1 second
  150. loop {_Scatter.AmountOfPlayers} times:
  151. add 1 to {_Scatter.Scattered}
  152. add 1 to {_Scatter.ScatteredTime}
  153. set {_Scatter.FFAPlayer} to a random element out of {_Scatter.ListOfAllPlayers::*}
  154. set {_Scatter.FFAPlayer} to {_Scatter.FFAPlayer} parsed as offlineplayer
  155. remove {_Scatter.FFAPlayer} from {_Scatter.ListOfAllPlayers::*}
  156. set {_Scatter.FinalLocation} to a random element out of {_Scatter.FinalLocations.Ground::*}
  157. remove {_Scatter.FinalLocation} from {_Scatter.FinalLocations.Ground::*}
  158. execute console command "/fleftscattersound"
  159. if {_Scatter.FFAPlayer} is not online:
  160. set {Scatter.schedule::%{_Scatter.FFAPlayer}%} to {_Scatter.FinalLocation}
  161. broadcast "{@Prefix}{@CC} %{_Scatter.FFAPlayer}% - Scheduled Scatter"
  162. else:
  163. if {@BroadcastScatteredPlayers} is true:
  164. broadcast "{@Prefix}{@CC} %{_Scatter.FFAPlayer}% - {@HC}%{_Scatter.Scattered}%{@CC}/{@HC}%{_Scatter.AmountOfPlayers}%"
  165. teleport {_Scatter.FFAPlayer} to {_Scatter.FinalLocation}
  166. wait 1 tick
  167. broadcast ""
  168. broadcast "{@Prefix}{@CC} All players scattered!"
  169. broadcast "{@Prefix}{@CC} Lowest mindist: {@HC}~%{_Scatter.mindist}%{@CC} with radius {@HC}%{_Scatter.radius}%"
  170. delete {Scatter.DisableChunkUnload}
  171.  
  172. #--------------------------------------------------
  173. # Team + Solo Scatter
  174. #--------------------------------------------------
  175.  
  176. else if arg-3 is "team" or "teams":
  177. set {_Scatter.TeamCount} to 0
  178. loop {Teams::*}:
  179. {Team.%loop-value%::*} is set:
  180. increase {_Scatter.TeamCount} by 1
  181. add {_Scatter.TeamCount} to {_Scatter.Teams::*}
  182. set {_Scatter.Team.%{_Scatter.TeamCount}%::*} to {Team.%loop-value%::*}
  183. set {_Scatter.MainPlayer} to a random element out of {Team.%loop-value%::*}
  184. set {_Scatter.MainPlayer} to {_Scatter.MainPlayer} parsed as offlineplayer
  185. add {_Scatter.MainPlayer} to {_Scatter.ListOfAllPlayers::*}
  186. loop all players:
  187. {Teams.InTeam::%loop-player%} is not set:
  188. add (name of loop-player) to {_Scatter.Solos::*}
  189. add (name of loop-player) to {_Scatter.ListOfAllPlayers::*}
  190. set {_Scatter.AmountOfPlayers} to ((size of {_Scatter.Teams::*})+(size of {_Scatter.Solos::*}))
  191. if (size of ({_Scatter.ListOfAllPlayers::*})) is equal to 0:
  192. message "{@Prefix}{@CC} No one can be scattered!"
  193. stop trigger
  194. set {Scatter.DisableChunkUnload} to true
  195. set {_Scatter.world} to arg-1
  196. set {_Scatter.radius} to arg-2
  197. set {_Scatter.mindist} to (({_Scatter.radius}/{_Scatter.AmountOfPlayers})*5)
  198. broadcast "{@Prefix}{@CC} Attempting to scatter {@HC}%(size of ({_Scatter.Teams::*}))%{@CC} teams and {@HC}%(size of ({_Scatter.Solos::*}))%{@CC} solos!"
  199. loop {_Scatter.AmountOfPlayers} times:
  200. loop {@Tries} times:
  201. if loop-number-2 is equal to {@Tries}:
  202. broadcast "{@Prefix}{@CC} Could not scatter %loop-number-1%/%{_Scatter.AmountOfPlayers}%"
  203. broadcast "{@Prefix}{@CC} Some players may have been scattered!"
  204. broadcast "{@Prefix}{@CC} You may want to /tpall!"
  205. command "/fleftscatterbroke random.break"
  206. stop trigger
  207. set {_Scatter.Location.Good} to true
  208. set {_Scatter.SkyLocation} to (the location at ((random integer between (0-{_Scatter.radius}) and ({_Scatter.radius}-1))+0.5), 255, ((random integer between (0-{_Scatter.radius}) and ({_Scatter.radius}-1))+0.5) of the world {_Scatter.world})
  209. loop ((loop-number-1)-1) times:
  210. if {_Scatter.Location.Good} is true:
  211. distance between {_Scatter.SkyLocation} and {_Scatter.FinalLocations.Sky::%loop-number-3%} is less than {_Scatter.mindist}:
  212. delete {_Scatter.Location.Good}
  213. if {_Scatter.Location.Good} is true:
  214. set {_Scatter.GroundLocation} to {_Scatter.SkyLocation}
  215. while (block at {_Scatter.GroundLocation}) is air:
  216. if y-coordinate of {_Scatter.GroundLocation} is less than 5:
  217. delete {_Scatter.Location.Good}
  218. stop loop
  219. set {_Scatter.GroundLocation} to location 1 below {_Scatter.GroundLocation}
  220. if {_Scatter.Location.Good} is true:
  221. if (block at {_Scatter.GroundLocation}) is cactus, water, or lava:
  222. delete {_Scatter.Location.Good}
  223. if {_Scatter.Location.Good} is true:
  224. set {_Scatter.GroundLocation} to (location 1 above {_Scatter.GroundLocation})
  225. add 1 to {_Scatter.GeneratedLocations}
  226. add 1 to {_Scatter.GenerationTime}
  227. add {_Scatter.SkyLocation} to {_Scatter.FinalLocations.Sky::*}
  228. add {_Scatter.GroundLocation} to {_Scatter.FinalLocations.Ground::*}
  229. add {_Scatter.GroundLocation} to {_Scatter.ChunkLoading::*}
  230. if {@BroadcastFoundLocations} is true:
  231. broadcast "{@Prefix}{@CC} Loaded location {@HC}%{_Scatter.GeneratedLocations}%{@CC} / {@HC}%{_Scatter.AmountOfPlayers}%"
  232. execute console command "/fleftscattersound"
  233. wait 1 tick
  234. stop loop
  235. broadcast "{@Prefix}{@CC} All locations found!"
  236. broadcast ""
  237. if {@LoadGeneratedChunks} is true:
  238. broadcast "{@Prefix}{@CC} Loading chunks at each location!"
  239. loop {_Scatter.AmountOfPlayers} times:
  240. command sender is not online:
  241. broadcast "{@Prefix}{@CC} Scatter failed, command sender logged out."
  242. loop all players:
  243. execute console command "/playsound random.break %loop-player % ~ ~ ~ 1 1 1"
  244. stop trigger
  245. else:
  246. add 1 to {_Scatter.LoadedChunks}
  247. set {_Scatter.ChunkLoaderLocation} to a random element out of {_Scatter.ChunkLoading::*}
  248. remove {_Scatter.ChunkLoaderLocation} from {_Scatter.ChunkLoading::*}
  249. teleport (command sender) to {_Scatter.ChunkLoaderLocation}
  250. if {@BroadcastLoadedChunks} is true:
  251. broadcast "{@Prefix}{@CC} Loaded {@HC}%{_Scatter.LoadedChunks}%{@CC}/{@HC}%{_Scatter.AmountOfPlayers}%"
  252. wait {@ChunkLoadTicks} ticks
  253. broadcast "{@Prefix}{@CC} Loading of chunks completed!"
  254. broadcast ""
  255. wait 1 second
  256. loop {_Scatter.Teams::*}:
  257. broadcast "{@Prefix}{@CC} Scattering {@HC}Team %loop-value%{@CC}/{@HC}%(size of ({_Scatter.Teams::*}))%!"
  258. set {_Scatter.FinalLocation.Team} to a random element out of {_Scatter.FinalLocations.Ground::*}
  259. remove {_Scatter.FinalLocation.Team} from {_Scatter.FinalLocations.Ground::*}
  260. loop {Team.%loop-value%::*}:
  261. set {_Scatter.TeamPlayer} to loop-value-2 parsed as offlineplayer
  262. add 1 to {_Scatter.Scattered}
  263. add 1 to {_Scatter.ScatteredTime}
  264. execute console command "/fleftscattersound"
  265. if {_Scatter.TeamPlayer} is not online:
  266. set {Scatter.schedule::%{_Scatter.TeamPlayer}%} to {_Scatter.FinalLocation.Team}
  267. broadcast "{@Prefix}{@HC} - {@CC}%{_Scatter.TeamPlayer}%: Scheduled Scatter"
  268. else:
  269. if {@BroadcastScatteredPlayers} is true:
  270. broadcast "{@Prefix}{@HC} - {@CC}%{_Scatter.TeamPlayer}%"
  271. teleport {_Scatter.TeamPlayer} to {_Scatter.FinalLocation.Team}
  272. wait 1 tick
  273. if {_Scatter.Solos::*} is set:
  274. broadcast ""
  275. broadcast "{@Prefix}{@CC} Scattering solos!"
  276. loop {_Scatter.Solos::*}:
  277. add 1 to {_Scatter.Scattered}
  278. add 1 to {_Scatter.ScatteredTime}
  279. set {_Scatter.FinalLocation.Solo} to a random element out of {_Scatter.FinalLocations.Ground::*}
  280. remove {_Scatter.FinalLocation.Solo} from {_Scatter.FinalLocations.Ground::*}
  281. set {_Scatter.NewSolo} to loop-value parsed as offlineplayer
  282. execute console command "/fleftscattersound"
  283. if {_Scatter.NewSolo} is not online:
  284. broadcast "{@Prefix}{@CC} Scheduled late scatter of {@HC}%{_Scatter.NewSolo}%!"
  285. set {Scatter.schedule::%{_Scatter.NewSolo}%} to {_Scatter.FinalLocation.Solo}
  286. else:
  287. teleport {_Scatter.NewSolo} to {_Scatter.FinalLocation.Solo}
  288. if {@BroadcastScatteredPlayers} is true:
  289. broadcast "{@Prefix}{@HC} SOLO: {@CC}%{_Scatter.NewSolo}%"
  290. wait 1 tick
  291. broadcast ""
  292. broadcast "{@Prefix}{@CC} All teams scattered!"
  293. broadcast "{@Prefix}{@CC} Lowest mindist: {@HC}~%{_Scatter.mindist}%{@CC} with radius {@HC}%{_Scatter.radius}%"
  294. delete {Scatter.DisableChunkUnload}
  295.  
  296. #--------------------------------------------------
  297. # Single Player Scatter
  298. #--------------------------------------------------
  299.  
  300. else:
  301. set {_Scatter.AllPlayers::*} to all players
  302. if {_Scatter.AllPlayers::*} does not contain arg-3:
  303. broadcast "{@Prefix}{@HC} %arg-3%{@CC} is not online!"
  304. command "/fleftscatterbroke random.break"
  305. stop trigger
  306. else:
  307. set {_Scatter.SinglePlayer} to arg-3 parsed as offlineplayer
  308. add {_Scatter.SinglePlayer} to {_Scatter.ListOfAllPlayers::*}
  309. set {_Scatter.AmountOfPlayers} to 1
  310. set {_Scatter.world} to arg-1
  311. set {_Scatter.radius} to arg-2
  312. broadcast "{@Prefix}{@CC} Attempting to scatter {@HC}%arg-3%!"
  313. loop {_Scatter.AmountOfPlayers} times:
  314. loop {@Tries} times:
  315. if loop-number-2 is equal to {@Tries}:
  316. broadcast "{@Prefix}{@CC} Could not scatter {@HC}%arg-3%{@CC}. Try again!"
  317. command "/fleftscatterbroke random.break"
  318. stop trigger
  319. set {_Scatter.Location.Good} to true
  320. set {_Scatter.SkyLocation} to (the location at ((random integer between (0-{_Scatter.radius}) and ({_Scatter.radius}-1))+0.5), 255, ((random integer between (0-{_Scatter.radius}) and ({_Scatter.radius}-1))+0.5) of the world {_Scatter.world})
  321. loop ((loop-number-1)-1) times:
  322. if {_Scatter.Location.Good} is true:
  323. distance between {_Scatter.SkyLocation} and {_Scatter.FinalLocations.Sky::%loop-number-3%} is less than {_Scatter.mindist}:
  324. delete {_Scatter.Location.Good}
  325. if {_Scatter.Location.Good} is true:
  326. set {_Scatter.GroundLocation} to {_Scatter.SkyLocation}
  327. while (block at {_Scatter.GroundLocation}) is air:
  328. if y-coordinate of {_Scatter.GroundLocation} is less than 5:
  329. delete {_Scatter.Location.Good}
  330. stop loop
  331. set {_Scatter.GroundLocation} to location 1 below {_Scatter.GroundLocation}
  332. if {_Scatter.Location.Good} is true:
  333. if (block at {_Scatter.GroundLocation}) is cactus, water, or lava:
  334. delete {_Scatter.Location.Good}
  335. if {_Scatter.Location.Good} is true:
  336. set {_Scatter.GroundLocation} to (location 1 above {_Scatter.GroundLocation})
  337. add 1 to {_Scatter.GeneratedLocations}
  338. add 1 to {_Scatter.GenerationTime}
  339. if {@BroadcastFoundLocations} is true:
  340. broadcast "{@Prefix}{@CC} Loaded location {@HC}%{_Scatter.GeneratedLocations}%{@CC} / {@HC}%{_Scatter.AmountOfPlayers}%"
  341. execute console command "/fleftscattersound"
  342. wait 1 tick
  343. stop loop
  344. broadcast "{@Prefix}{@CC} Location found!"
  345. broadcast ""
  346. wait 1 second
  347. add 1 to {_Scatter.Scattered}
  348. add 1 to {_Scatter.ScatteredTime}
  349. execute console command "/fleftscattersound"
  350. wait 1 tick
  351. if {_Scatter.SinglePlayer} is not online:
  352. set {Scatter.schedule::%{_Scatter.SinglePlayer}%} to {_Scatter.GroundLocation}
  353. broadcast "{@Prefix}{@CC} %{_Scatter.SinglePlayer}% - Scheduled Scatter"
  354. else:
  355. if {@BroadcastScatteredPlayers} is true:
  356. broadcast "{@Prefix}{@CC} %{_Scatter.SinglePlayer}% - {@HC}%{_Scatter.Scattered}%{@CC}/{@HC}%{_Scatter.AmountOfPlayers}%"
  357. teleport {_Scatter.SinglePlayer} to {_Scatter.GroundLocation}
  358. wait 1 tick
  359. broadcast ""
  360. broadcast "{@Prefix}{@HC} %arg-3%{@CC} scattered!"
  361. broadcast "{@Prefix}{@CC} Radius: {@HC}%{_Scatter.radius}%"
  362.  
  363. #--------------------------------------------------
  364. # End of Scatter - Event section (and sound command)
  365. #--------------------------------------------------
  366.  
  367.  
  368. on chunk unload:
  369. {Scatter.DisableChunkUnload} is true:
  370. cancel the event
  371. on login:
  372. {Scatter.schedule::%player%} is set:
  373. wait 1 tick
  374. teleport player to {Scatter.schedule::%player%}
  375. broadcast "{@Prefix}{@HC} %player%{@CC} - scheduled late scatter!"
  376. delete {Scatter.schedule::%player%}
  377. command /fleftscattersound:
  378. permission: skript.sca
  379. trigger:
  380. loop all players:
  381. execute console command "/playsound {@ScatterSound} %loop-player% ~ ~ ~ 1 {@ScatterPitch} 1"
  382. command /fleftscatterbroke <text>:
  383. permission: skript.scatter.playsound
  384. trigger:
  385. loop all players:
  386. command "/playsound %arg 1% %loop-player%"
Add Comment
Please, Sign In to add comment