Zeldaboy111

Prestige af! ]|[ Skript #448

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