NoHacksJustACow

Skywars Skript

Feb 9th, 2019
3,667
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.91 KB | None | 0 0
  1. # skywars.sk
  2. # Coded by Santio71
  3. # Addons required: InstantRespawn
  4.  
  5. # Note that this code is licenced with GNU General Public License
  6.  
  7. # Original download page: https://raw.githubusercontent.com/SantioMC/Skripts/master/skywars.sk
  8. # Any updates will be uploaded to the link above
  9.  
  10. options:
  11. version: 2.7.5 #DO NOT CHANGE, IT COULD BREAK THE SKRIPT IN THE FUTURE!
  12.  
  13. prefix: &7[&bSkywars&7] &7
  14. signLine: &9[SKYWARS]
  15. permission: skywars.admin
  16. error: &cAn error occurred! Please contact Santio71 to resolve this issue!
  17. invalidArgument: &cIncorrect argument! Please run &9/skywars help &cfor more help!
  18. noPermission: &cYou are not permitted to run this command!
  19.  
  20. on load:
  21. clear {chest::*}
  22. add wooden sword named "&7Wood Sword" to {chest::*} #Feel free to add any more items as you wish!
  23. add 32 oak planks named "&7Wood" to {chest::*} #Adding it more than once, increases its chance of being recieved
  24. add golden apple named "&7Golden Apple" to {chest::*}
  25. add stick named "&7Stick" to {chest::*}
  26. add 2 oak logs named "&7Log" to {chest::*}
  27. add diamond named "&7Diamond" to {chest::*}
  28.  
  29. on load:
  30. wait 1 second
  31. if {lastKnowVersion} is not set:
  32. set {lastKnowVersion} to "{@version}"
  33. if {lastKnowVersion} is not "{@version}":
  34. broadcast "&9Skywars&7 by Santio71 was successfully updated!"
  35. broadcast "&7If you experience bugs, please inform me on github using the issue tracker!"
  36. set {lastKnowVersion} to "{@version}"
  37. command /skywars [<text>] [<text>]:
  38. description: Main command for skywars
  39. aliases: sw, skyw, swars
  40. trigger:
  41. if arg-1 is not set:
  42. send "&9Skywars &7- Designed by Santio71" # Do not change, All skripts are licened with GIT licence
  43. send "&7Want to use this skript? Check it out on my&9 github&7!"
  44. send "&7&oSkywars Version: {@version}"
  45. else if arg-1 is "help" or "h" or "?":
  46. send ""
  47. send "&a/skywars join &7- Join a skywars game"
  48. send "&a/skywars leave &7- Leave a skywars game"
  49. send "&a/skywars list &7- List all skywars games"
  50. send ""
  51. if player has permission "{@permission}":
  52. send "&a/skywars reload &7- Reloads the skript"
  53. send "&a/skywars create <id> &7- Create a new game"
  54. send "&a/skywars remove <id> &7- Delete a game"
  55. send "&a/skywars setspawn <id> &7- Sets a spawnpoint"
  56. send "&a/skywars start <id> &7- Starts a game"
  57. send "&a/skywars stop <id> &7- Stops a game"
  58. send ""
  59. else if arg-1 is "join" or "j" or "play":
  60. if arg-2 is not set:
  61. send "&c/skywars join (game)"
  62. stop
  63. if {ingame.%player%} is set:
  64. send "&cYou are already in a game!"
  65. stop
  66. if {games::%arg-2%::running} is not set:
  67. send "&cThat game is not running!"
  68. stop
  69. if {games::%arg-2%::started} is set:
  70. send "&cThat game already started!"
  71. stop
  72. set {_max} to 0
  73. set {_current} to 0
  74. loop {games::%arg-2%::spawnpoints::*}:
  75. add 1 to {_max}
  76. loop {games::%arg-2%::players::*}:
  77. add 1 to {_current}
  78. if {_current} is {_max}:
  79. send "&cThat game is currently full!"
  80. stop
  81. set {ingame.%player%} to arg-2
  82. send "&aYou joined the queue!"
  83. else if arg-1 is "leave" or "l":
  84. if {ingame.%player%} is not set:
  85. send "&cYou are currently not in a skywars game!"
  86. stop
  87. remove player from {games::%{ingame.%player%}%::players::*}
  88. clear {ingame.%player%}
  89. send "&cYou left the game!"
  90. else if arg-1 is "list" or "games" or "allgames" or "showgames" or "runninggames":
  91. send "&7&m-------------------"
  92. set {_totalGamesRunning} to 0
  93. loop {gamesRunning::*}:
  94. add 1 to {_totalGamesRunning}
  95. send "&7There are currently &9%{_totalGamesRunning}%&7 running games!"
  96. send ""
  97. loop {gamesRunning::*}:
  98. send "&6≫ &7%loop-value% &a&o(RUNNING)"
  99. set {_used::%loop-value%} to true
  100. loop {games::*}:
  101. if {_used::%loop-value%} is not set:
  102. send "&6≫ &7%loop-value%"
  103. send ""
  104. send "&7&m-------------------"
  105. else if arg-1 is "reload" or "rl":
  106. if player does not have permission "{@permission}":
  107. send "{@noPermission}"
  108. stop
  109. send "&7Reloading %script%.sk"
  110. execute console command "skript:sk reload %script%"
  111. send "&aReloaded %script%.sk!"
  112. else if arg-1 is "create" or "new" or "c":
  113. if player does not have permission "{@permission}":
  114. send "{@noPermission}"
  115. stop
  116. if arg-2 is not set:
  117. send "&c/skywars create (name)"
  118. stop
  119. if {games::%arg-2%::exists} is set:
  120. send "&cThat game already exists!"
  121. stop
  122. set {games::%arg-2%::exists} to true
  123. set {games::%arg-2%::countdown} to 0
  124. send "&7Created the game: &9%arg-2%&7!"
  125. else if arg-1 is "remove" or "delete" or "erase" or "r" or "d":
  126. if player does not have permission "{@permission}":
  127. send "{@noPermission}"
  128. stop
  129. if arg-2 is not set:
  130. send "&c/skywars %arg-1% (name)"
  131. stop
  132. if {games::%arg-2%::exists} is not set:
  133. send "&cThat game does not exist!"
  134. stop
  135. clear {games::%arg-2%::countdown}
  136. clear {games::%arg-2%::*}
  137. remove arg-2 from {gamesRunning::*}
  138. send "&7Deleted the game: &9%arg-2%&7!"
  139. else if arg-1 is "setspawn" or "spawnpoint" or "sp" or "ss":
  140. if player does not have permission "{@permission}":
  141. send "{@noPermission}"
  142. stop
  143. if arg-2 is not set:
  144. send "&c/skywars %arg-1% (name)"
  145. stop
  146. if {games::%arg-2%::exists} is not set:
  147. send "&cThat game does not exist!"
  148. stop
  149. add player's location to {games::%arg-2%::spawnpoints::*}
  150. send "&7Added location!"
  151. send "&9%player's location%"
  152. set {_a} to 0
  153. loop {games::%arg-2%::spawnpoints::*}:
  154. add 1 to {_a}
  155. send "&7Total spawnpoints:&9 %{_a}%"
  156. else if arg-1 is "run" or "start" or "begin" or "go":
  157. if player does not have permission "{@permission}":
  158. send "{@noPermission}"
  159. stop
  160. if arg-2 is not set:
  161. send "&c/skywars %arg-1% (name)"
  162. stop
  163. if {games::%arg-2%::exists} is not set:
  164. send "&cThat game does not exist!"
  165. stop
  166. if {games::%arg-2%::running} is set:
  167. send "&cThis game is already running!"
  168. stop
  169. set {games::%arg-2%::running} to true
  170. clear {games::%arg-2%::players::*}
  171. broadcast "{@prefix}The skywars game, &9%arg-2%&7 is now starting! To join, run &9/skywars join %arg-2%&7!"
  172. add arg-2 to {gamesRunning::*}
  173. else if arg-1 is "finish" or "end" or "done" or "stop":
  174. if player does not have permission "{@permission}":
  175. send "{@noPermission}"
  176. stop
  177. if arg-2 is not set:
  178. send "&c/skywars %arg-1% (name)"
  179. stop
  180. if {games::%arg-2%::exists} is not set:
  181. send "&cThat game does not exist!"
  182. stop
  183. if {games::%arg-2%::running} is not set:
  184. if {games::%arg-2%::started} is not set:
  185. send "&cThis game is already stopped!"
  186. stop
  187. loop {games::%arg-2%::players::*}:
  188. clear {ingame.%loop-value%}
  189. loop {built::%loop-value%::*}:
  190. set block at location at loop-value-2 to air #rip tall grass lol
  191. teleport loop-value to {skywars.previousLocation.%loop-value%}
  192. clear {games::%arg-2%::players::*}
  193. clear {games::%arg-2%::running}
  194. clear {games::%arg-2%::countdown}
  195. remove arg-2 from {gamesRunning::*}
  196. clear {games::%arg-2%::started}
  197. loop {restore::*}:
  198. set block at loop-value to chest
  199. clear {restore::*}
  200. broadcast "{@prefix}&9%arg-2%&7 was stopped by &9%player%&7!"
  201. else:
  202. send "{@invalidArgument}"
  203.  
  204. every 1 second:
  205. loop {gamesRunning::*}:
  206. if {games::%loop-value%::countdown} is 1:
  207. broadcast "{@prefix}&9%loop-value%&7 will start in &930 &7seconds!"
  208. if {games::%loop-value%::countdown} is 10:
  209. broadcast "{@prefix}&9%loop-value%&7 will start in &920 &7seconds!"
  210. if {games::%loop-value%::countdown} is 20:
  211. broadcast "{@prefix}&9%loop-value%&7 will start in &910 &7seconds!"
  212. if {games::%loop-value%::countdown} is 25:
  213. broadcast "{@prefix}&9%loop-value%&7 will start in &95 &7seconds!"
  214. if {games::%loop-value%::countdown} is 27:
  215. broadcast "{@prefix}&9%loop-value%&7 will start in &93 &7seconds!"
  216. if {games::%loop-value%::countdown} is 28:
  217. broadcast "{@prefix}&9%loop-value%&7 will start in &92 &7seconds!"
  218. if {games::%loop-value%::countdown} is 29:
  219. broadcast "{@prefix}&9%loop-value%&7 will start in &91 &7seconds!"
  220. if {games::%loop-value%::countdown} is 30:
  221. clear {games::%loop-value%::running}
  222. clear {games::%loop-value%::countdown}
  223. set {games::%loop-value%::ready} to true
  224. set {games::%loop-value%::started} to true
  225. loop all players:
  226. if {ingame.%loop-player%} is set:
  227. add loop-player to {games::%loop-value-1%::players::*}
  228. loop {games::%loop-value%::players::*}:
  229. loop {games::%loop-value-1%::spawnpoints::*}:
  230. if {_done} is not set:
  231. if {used::%loop-value-3%} is not set:
  232. set {skywars.previousLocation.%loop-value-2%} to location of loop-value-2
  233. teleport loop-value-2 to loop-value-3
  234. set {used::%loop-value-3%} to true
  235. set {_done} to true
  236. set {ingame.%loop-value-2%} to loop-value-1
  237. clear {_done}
  238. clear {used::*}
  239. if {games::%loop-value%::running} is set:
  240. set {_players} to 0
  241. loop all players:
  242. if {ingame.%loop-value-2%} is set:
  243. add 1 to {_players}
  244. if {_players} >= 2: #Required amount of players (REMINDER)
  245. if {games::%loop-value%::countdown} is set:
  246. add 1 to {games::%loop-value%::countdown}
  247. stop
  248. else:
  249. set {games::%loop-value%::countdown} to 1
  250. else:
  251. clear {games::%loop-value%::countdown}
  252. clear {_players}
  253. else:
  254. clear {games::%loop-value%::countdown}
  255.  
  256. on rightclick:
  257. event-block is chest
  258. if {ingame.%player%} is set:
  259. if {playerModified.%location of event-block%} is not set:
  260. set {_item} to random object out of {chest::*}
  261. give {_item} to player
  262. set event-block to air
  263. add location of event-block to {restore::*}
  264. cancel event
  265.  
  266. on quit:
  267. if {ingame.%player%} is set:
  268. remove player from {games::%{ingame.%player%}%::players::*}
  269. add player to {lost::*}
  270. add 1 to {stats::skywars::%player%::loses}
  271. broadcast "{@prefix}&a%player%&7 was eliminated!"
  272. clear {ingame.%player%}
  273. on death:
  274. victim is a player
  275. set {_deathPoint} to location of attacker
  276. if {ingame.%victim%} is set:
  277. remove victim from {games::%{ingame.%victim%}%::players::*}
  278. broadcast "&cRemoved!"
  279. clear {games::%{ingame.%victim%}%::players::%victim%}
  280. clear {ingame.%victim%}
  281. add victim to {lost::*}
  282. add 1 to {stats::skywars::%victim%::loses}
  283. broadcast "{@prefix}&a%victim%&7 was eliminated by &a%attacker%&7!"
  284. add 1 to {stats::skywars::%victim%::deaths}
  285. attacker is a player:
  286. add 1 to {stats::skywars::%attacker%::kills}
  287. set victim's gamemode to spectator
  288. wait 2 seconds # Install InstantRespawn for this btw!
  289. teleport victim to {_deathPoint}
  290. every 5 ticks:
  291. loop {gamesRunning::*}:
  292. if {games::%loop-value%::ready} is set:
  293. clear {_p}
  294. loop all players:
  295. if {ingame.%loop-player%} contains loop-value-1:
  296. add 1 to {_p}
  297. set {_lkp} to loop-player
  298. if {_p} is 1:
  299. broadcast "s"
  300. clear {games::%loop-value%::ready}
  301. won({_lkp})
  302.  
  303. on command:
  304. player is a player #Check if it is not console
  305. if {ingame.%player%} is set:
  306. if command is not "hub" or "l" or "lobby" or "r" or "lobby" or "help" or "sw" or "skywars" or "leave":
  307. if player does not have permission "{@permission}":
  308. send "&cYou cannot run %complete command% while playing skywars!"
  309. stop
  310. if command is "leave":
  311. make player execute "skywars leave"
  312. cancel event
  313.  
  314. function won(p: player):
  315. loop {games::%{ingame.%{_p}%}%::players::*}:
  316. teleport loop-value to {skywars.previousLocation.%loop-value%}
  317. loop {lost::*}:
  318. loop {built::%loop-value%::*}:
  319. set block at location at loop-value-2 to air
  320. clear {ingame.%loop-value%}
  321. loop {built::%{_p}%::*}:
  322. set block at location at loop-value to air
  323. loop {restore::*}:
  324. set block at loop-value to chest
  325. clear {restore::*}
  326. clear {lost::*}
  327. remove {ingame.%{_p}%} from {gamesRunning::*}
  328. clear {ingame.%{_p}%}
  329. add 1 to {stats::skywars::%{_p}%::wins}
  330. broadcast "{@prefix}&a%{_p}% &7has won skywars!"
  331.  
  332. on place:
  333. if {ingame.%player%} is set:
  334. add location of event-block to {built::%player%::*}
  335. set {playerModified.%location of event-block%} to true
  336. on break:
  337. if {ingame.%player%} is set:
  338. if {playerModified.%location of event-block%} is not set:
  339. send "&cYou can only break blocks built by players!"
  340. cancel event
  341.  
  342. on rightclick:
  343. event-block is sign
  344. if line 1 contains "[skywars]":
  345. if line 1 is not "&1[SKYWARS]":
  346. if player has permission "{@permission}":
  347. set line 1 to "&1[SKYWARS]"
  348. if line 2 is "" or " ":
  349. set line 2 to "&4(join|leave)"
  350. set line 3 to "&4[name]"
  351. if line 2 is "leave":
  352. set line 2 to "&4LEAVE"
  353. if line 2 is "join":
  354. set line 2 to "&2JOIN"
  355. if line 3 is not "" or " ":
  356. if {games::%line 3%::exists} is set:
  357. set line 3 to "&2%line 3%"
  358. while event-block is sign:
  359. wait 5 ticks #Best not to remove btw lol... ;/
  360. set {_game} to line 3
  361. replace all "&a" with "" in {_game} #Cant forget this! I did forget it...
  362. set {_inGame} to 0
  363. wait a tick
  364. loop {games::%{_game}%::players::*}:
  365. add 1 to {_inGame}
  366. set {_max} to 0
  367. loop {games::%{_game}%::spawnpoints::*}:
  368. add 1 to {_max}
  369. set line 4 to "&f&o(%{_inGame}%|%{_max}%)"
  370. else:
  371. set line 3 to "&cUnknown game!"
  372. else:
  373. send "&cYou cannot place skywars signs!"
  374. else:
  375. if line 2 contains "&c(join|leave)":
  376. send "&cThis skywars sign is not setup probally!"
  377. cancel event
  378. else if line 2 contains "leave":
  379. make player execute "skywars leave"
  380. cancel event
  381. else if line 2 contains "join":
  382. if line 3 is not "" or " ":
  383. set {_g} to line 3
  384. replace all "&2" with "" in {_g} # Bug-fixes ::DDDD
  385. make player execute "skywars join %{_g}%"
  386. cancel event
  387. else:
  388. send "&cThis sign did not specify which game to send you in!"
  389. cancel event
  390. else:
  391. send "&cThis skywars sign is not setup probally!"
  392. cancel event
Advertisement
Add Comment
Please, Sign In to add comment