Zeldaboy111

Income fixed! ]|[ Skript #444

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