Zeldaboy111

Upgrades GUI ]|[ Skript #435

Jul 22nd, 2021
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.41 KB | None | 0 0
  1. options:
  2. prefix: &6Tycoon&8:&7
  3. shop: Shop
  4. upgrades: Upgrades
  5. prestigeUpgrades: Prestige Upgrades
  6. upgradesItem: gold nugget named "&eUpgrades"
  7. prestigeUpgradesItem: ghast tear named "&fPrestige Upgrades"
  8.  
  9. function sendBalance():
  10. if {tc.loopingBalance} is true:
  11. stop
  12. set {tc.loopingBalance} to true
  13. while {tc.loopingBalance} is true:
  14. if {tc.stopped} is true:
  15. delete {tc.loopingBalance}
  16. else if size of online players is 0:
  17. delete {tc.loopingBalance}
  18. else:
  19. loop all players:
  20. add {tc.%uuid of loop-player%.income} to {tc.%uuid of loop-player%.balance}
  21. send actionbar "&6Coins&8: &e%{tc.%uuid of loop-player%.balance}%" to loop-player
  22. wait 20 ticks
  23. on join:
  24. if {tc.%uuid of player%.balance} is not set:
  25. set {tc.%uuid of player%.balance} to 0
  26.  
  27. set {tc.%uuid of player%.income} to 1
  28. loop {tc.signList.%uuid of player%::*}:
  29. add {tc.signdata.%loop-value%.income} to {tc.%uuid of player%.income}
  30. sendBalance()
  31.  
  32. on enable:
  33. while {tc.loopingBalance} is true:
  34. wait 10 ticks
  35. if {tc.stopped}:
  36. wait 1 tick
  37. delete {tc.stopped}
  38. sendBalance()
  39.  
  40. on disable:
  41. if {tc.loopingBalance} is true:
  42. set {tc.stopped} to true
  43.  
  44. function setLineData(sign: Location, line: String, firstType: String, secondType: String):
  45. set {_lines::*} to {_line} split at " "
  46. if size of {_lines::*} is not 2:
  47. stop
  48.  
  49. set {_firstValue} to {_lines::1} parsed as an integer
  50. set {_secondValue} to {_lines::2} parsed as an integer
  51. if {_firstValue} is set:
  52. if {_secondValue} is set:
  53. if {_firstValue} > 0:
  54. if {_secondValue} > 0:
  55. set {tc.signdata.%{_sign}%.%{_firstType}%} to {_firstValue}
  56. set {tc.signdata.%{_sign}%.%{_secondType}%} to {_secondValue}
  57.  
  58. function updateSignVariables(sign: Location):
  59. add 1 to {tc.signdata.%{_sign}%.level}
  60. add {tc.signdata.%{_sign}%.costIncrease} to {tc.signdata.%{_sign}%.cost}
  61. add {tc.signdata.%{_sign}%.income} to {tc.signdata.%{_sign}%.income}
  62. if {tc.signdata.%{_sign}%.level} >= {tc.signdata.%{_sign}%.maxLevel}:
  63. set {tc.signdata.%{_sign}%.cost} to -1
  64.  
  65. on sign change:
  66. if line 1 doesn't start with "[T] ":
  67. stop
  68. setLineData(location of event-block, line 4 of event-block, "level", "maxLevel")
  69. setLineData(location of event-block, line 3 of event-block, "cost", "costIncrease")
  70. setLineData(location of event-block, line 2 of event-block, "income", "incomeIncrease")
  71. if {tc.signdata.%location of event-block%.level} >= {tc.signdata.%location of event-block%.maxLevel}:
  72. set {tc.signdata.%location of event-block%.cost} to -1
  73. if {tc.signdata.%location of event-block%.cost} is not set:
  74. stop
  75. set {_l1} to line 1
  76. replace "[T] " in {_l1} with ""
  77. set line 1 to "&6&l%{_l1}%"
  78. set line 2 to ""
  79. if {tc.signdata.%location of event-block%.cost} > -1:
  80. set line 3 to "&eCost&8: &7%{tc.signdata.%location of event-block%.cost}%"
  81. else:
  82. set line 3 to "&eCost&8: &7Max Level"
  83. set line 4 to "&bLevel&8: &7%{tc.signdata.%location of event-block%.level}%"
  84. add location of event-block to {tc.signList.%uuid of player%::*}
  85.  
  86. on right click on sign:
  87. if {tc.signdata.%location of event-block%.cost} is not set:
  88. stop
  89. else if {tc.signdata.%location of event-block%.level} >= {tc.signdata.%location of event-block%.maxLevel}:
  90. play sound "entity.item.break" to player
  91. else if {tc.%uuid of player%.balance} < {tc.signdata.%location of event-block%.cost}:
  92. play sound "entity.item.break" to player
  93. else:
  94. remove {tc.signdata.%location of event-block%.cost} from {tc.%uuid of player%.balance}
  95. updateSignVariables(location of event-block)
  96. add {tc.signdata.%location of event-block%.incomeIncrease} to {tc.%uuid of player%.income}
  97. play sound "entity.player.levelup" to player
  98. if {tc.signdata.%location of event-block%.cost} > -1:
  99. set line 3 to "&eCost&8: &7%{tc.signdata.%location of event-block%.cost}%"
  100. else:
  101. set line 3 to "&eCost&8: &7Max Level"
  102. set line 4 to "&bLevel&8: &7%{tc.signdata.%location of event-block%.level}%"
  103.  
  104. on break of sign:
  105. if {tc.signdata.%location of event-block%.cost} is set:
  106. delete {tc.signdata.%location of event-block%.cost}
  107. delete {tc.signdata.%location of event-block%.costIncrease}
  108. delete {tc.signdata.%location of event-block%.level}
  109. delete {tc.signdata.%location of event-block%.maxLevel}
  110. remove location of event-block from {tc.signList.%uuid of player%::*}
  111.  
  112. command /shop:
  113. trigger:
  114. open chest with 1 rows named "{@shop}" to player
  115. set slot 0 of player's current inventory to {@upgradesItem}
  116. set slot 1 of player's current inventory to {@prestigeUpgradesItem}
  117.  
  118. function openUpgrades(player: Player):
  119. open chest with 3 rows named "{@upgrades}" to {_player}
  120.  
  121. function openPrestigeUpgrades(player: Player):
  122. open chest with 3 rows named "{@prestigeUpgrades}" to {_player}
  123.  
  124.  
  125. function handleShopInventoryClick(player: Player, clicked: Item):
  126. if {_clicked} is {@upgradesItem}:
  127. openUpgrades({_player})
  128. else if {_clicked} is {@prestigeUpgradesItem}:
  129. openPrestigeUpgrades({_player})
  130. else:
  131. stop
  132. play sound "ui.button.click" to {_player}
  133.  
  134.  
  135. on inventory click:
  136. # Fix that inventory click is only cancelled when clicked inside the shop-GUI
  137. if inventory name of clicked inventory is "{@shop}":
  138. cancel event
  139. handleShopInventoryClick(player, event-item)
  140. else if inventory name of clicked inventory is "{@upgrades}":
  141. cancel event
  142. send "UPGRADES"
  143. else if inventory name of clicked inventory is "{@prestigeUpgrades}":
  144. cancel event
  145. send "PRESTIGE UPGRADES"
  146.  
Advertisement
Add Comment
Please, Sign In to add comment