Advertisement
chatasma

Minigames Framework Base [Skript]

Feb 18th, 2019
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.09 KB | None | 0 0
  1. on load:
  2. if {joincounter} is not set:
  3. set {joincounter} to 0
  4. set {matchcounter} to 0
  5. resetGameCore()
  6. set {_gopts::disp} to "&6The Bridges"
  7. set {_gopts::maxqueue} to 999
  8. set {_gopts::minqueue} to 2
  9. set {_gopts::qc} to "&d"
  10. initGames("bridges", 1, {_gopts::*})
  11. loop all players:
  12. resetPlayerData(loop-player)
  13.  
  14. on join:
  15. set {_res} to isNew(player)
  16. set {_append} to ""
  17. if {_res} is true:
  18. add 1 to {joincounter}
  19. set {_append} to " &d[NEW]"
  20. set {_msg} to "&8[&a+&8] &7%player%%{_append}%"
  21. set join message to {_msg}
  22. resetPlayerData(player)
  23.  
  24. function isNew(p: player) :: boolean:
  25. set {_yeet} to false
  26. set {_uuid} to uuid of {_p}
  27. if {leplayer::%{_uuid}%} is not set:
  28. set {_yeet} to true
  29. return {_yeet}
  30.  
  31. function resetPlayerData(p: player):
  32. set {_uuid} to uuid of {_p}
  33. if {leplayer::%{_uuid}%} is not set:
  34. set {leplayer::%{_uuid}%} to {_p}
  35. set {leplayer::%{_uuid}%::coins} to 0
  36. set {leplayer::%{_uuid}%::xp} to 0
  37. if {player::%{_p}%} is not set:
  38. set {player::%{_p}%} to {_uuid}
  39. set {player::%{_p}%::ingame} to 0
  40. delete {player::%{_p}%::gametype}
  41. set {_p} tab name to "&7%{_p}%"
  42.  
  43. function resetGameCore():
  44. clear {games::*}
  45. set {games::repo} to true
  46. set {games::matches} to true
  47.  
  48.  
  49. function initGames(game: text, count: number, gopts: objects):
  50. set {games::repo::%{_game}%} to true
  51. set {games::repo::%{_game}%::disp} to {_gopts::1}
  52. set {games::repo::%{_game}%::maxqueue} to {_gopts::2}
  53. set {games::repo::%{_game}%::minqueue} to {_gopts::3}
  54. set {games::repo::%{_game}%::qc} to {_gopts::4}
  55. set {_start} to 1
  56. while {_start} <= {_count}:
  57. add 1 to {matchcounter}
  58. set {games::matches::match%{_start}%} to true
  59. set {games::matches::match%{_start}%::label} to {matchcounter}
  60. set {games::matches::match%{_start}%::gametype} to {_game}
  61. set {games::matches::match%{_start}%::state} to 0
  62. set {games::matches::match%{_start}%::queued} to true
  63. add 1 to {_start}
  64.  
  65. command /test:
  66. trigger:
  67. queue("bridges", player)
  68.  
  69. function queue(game: text, p: player):
  70. if {player::%{_p}%::gametype} is set:
  71. send "&cYou are already in a game/queue!" to {_p}
  72. singleSound("entity.villager.no", {_p}, 1, 10)
  73. stop
  74. set {_matchnum} to findAvailableMatch({_game})
  75. set {_disp} to {games::repo::%{_game}%::disp}
  76. if {_matchnum} < 0:
  77. send "&cThere are no available matches for %{_disp}%" to {_p}
  78. singleSound("entity.villager.no", {_p}, 1, 10)
  79. stop
  80. add {_p} to {games::matches::match%{_matchnum}%::queued::*}
  81. set {_qc} to {games::repo::%{_game}%::qc}
  82. set {_disp} to {games::repo::%{_game}%::disp}
  83. set {_p} tab name to "%{_qc}%%{_p}%"
  84. set {player::%{_p}%::gametype} to {_game}
  85. set {player::%{_p}%::ingame} to {_matchnum}
  86. send "&7You have &ajoined the queue &7for %{_disp}%!" to {_p}
  87. singleSound("entity.player.levelup", {_p}, 1.4, 10)
  88. pingQueue({_matchnum})
  89.  
  90.  
  91. function pingQueue(matchnum: number):
  92. set {_gametype} to {games::matches::match%{_matchnum}%::gametype}
  93. if {games::matches::match%{_matchnum}%::state} = 0:
  94. if size of {games::matches::match%{_matchnum}%::queued::*} >= {games::repo::%{_gametype}%::minqueue}:
  95. set {games::matches::match%{_matchnum}%::state} to 1
  96. set {_start} to 20
  97. set {_disp} to {games::repo::%{_gametype}%::disp}
  98. loop 20 times:
  99. set {_gamer} to false
  100. if {_start} > 0:
  101. if mod({_start}, 5) = 0:
  102. set {_gamer} to true
  103. else if {_start} <= 5:
  104. set {_gamer} to true
  105. if {_gamer} is true:
  106. set {_app} to "s"
  107. if {_start} = 1:
  108. set {_app} to ""
  109. sendToQueued("%{_disp}% &7will begin in &3%{_start}% &bsecond%{_app}%", {_matchnum})
  110. playToQueued("block.note_block.hat", {_matchnum}, 1, 10)
  111. remove 1 from {_start}
  112. wait 1 second
  113. sendToQueued("%{_disp}% &7will now &bbegin", {_matchnum})
  114. playToQueued("entity.player.levelup", {_matchnum}, 1.4, 10)
  115. if size of {games::matches::match%{_matchnum}%::queued::*} < {games::repo::%{_gametype}%::minqueue}:
  116. sendToQueued("&cNot enough players for %{_disp}%", {_matchnum})
  117. playToQueued("entity.villager.no", {_matchnum}, 1, 10)
  118. set {games::matches::match%{_matchnum}%::state} to 0
  119. stop
  120. set {games::matches::match%{_matchnum}%::state} to 2
  121. disperseGamerMoment({_matchnum})
  122.  
  123. function disperseGamerMoment(matchnum: number):
  124. set {_gametype} to {games::matches::match%{_matchnum}%::gametype}
  125. if {_gametype} is "bridges":
  126. brRun({_matchnum})
  127.  
  128. function findAvailableMatch(game: text) :: number:
  129. loop {games::matches::*}:
  130. if {games::matches::%loop-index%::gametype} is {_game}:
  131. if {games::matches::%loop-index%::state} <= 1:
  132. if size of {games::matches::%loop-index%::queued::*} < {games::repo::%{_game}%::maxqueue}:
  133. return {games::matches::%loop-index%::label}
  134. return -1
  135.  
  136.  
  137. function sendToQueued(msg: text, matchnum: number):
  138. loop {games::matches::match%{_matchnum}%::queued::*}:
  139. send {_msg} to loop-value
  140.  
  141. function playToQueued(sound: text, matchnum: number, pitch: number, volume: number):
  142. multiSound({_sound}, {games::matches::match%{_matchnum}%::queued::*}, {_pitch}, {_volume})
  143.  
  144. function singleSound(sound: text, p: player, pitch: number, volume: number):
  145. play sound "%{_sound}%" with volume {_volume} with pitch {_pitch} at location of {_p} for {_p}
  146.  
  147. function multiSound(sound: text, p: objects, pitch: number, volume: number):
  148. loop {_p::*}:
  149. play sound "%{_sound}%" with volume {_volume} with pitch {_pitch} at location of loop-value for loop-value
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement