Zeldaboy111

Upgrades GUI ]|[ Skript #437

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