Zeldaboy111

Start-issue ]|[ Skript #441

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