Zeldaboy111

Upgrades GUI ]|[ Skript #436

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