Zeldaboy111

Script af! ]|[ Skript #450

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