familychicken

maxbuy

Mar 14th, 2022 (edited)
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. options:
  2. shopp: &7[&7&l・&r&7]
  3.  
  4. on join:
  5. set {%player%.maxbuy} to 0
  6. set {%player%.multibuy} to 1
  7.  
  8. function sp(p: player, startp: number, power: number, upgn: number, type: text, max: number, mbuy: number):
  9. loop {_max}+1 times:
  10. if {_max} is not 0:
  11. set {_mbuy} to 2^({_max}-loop-number+1)
  12. set {_cost} to multibuy({_mbuy}, {_startp}, {_power}, {_upgn}, {_p})
  13. if {_type} is "upgrade":
  14. if {%{_p}%.coin} >= {_startp}:
  15. if {%{_p}%.upgrade::%{_upgn}%} is not 1:
  16. remove {_startp} from {%{_p}%.coin}
  17. set {%{_p}%.upgrade::%{_upgn}%} to 1
  18. add {_startp} to {%{_p}%.legacycoin}
  19. message "{@shopp} &f購入に成功しました。" to {_p}
  20. exit loop
  21. else:
  22. message "{@shopp} &7購入済みです。" to {_p}
  23. exit loop
  24. else if {_type} is "buyable":
  25. if {%{_p}%.coin} >= {_cost}:
  26. add {_mbuy} to {_suc}
  27. add {_cost} to {%{_p}%.legacycoin}
  28. remove {_cost} from {%{_p}%.coin}
  29. add {_mbuy} to {%{_p}%.upgrade::%{_upgn}%}
  30. message "{@shopp} &f購入に成功しました。" to {_p} if {_max} is 0
  31. else:
  32. set {_need} to {_cost}-{%{_p}%.coin}
  33. message "{@shopp} &7費用が足りません。 あと &f%nn({_need}, {_p})% &7coins必要です。&8(%{%{_p}%.coin}/{_cost}*100% &8%%)" to {_p} if {_max} is 0
  34. if {_max} is not 0:
  35. if {_suc} > 0:
  36. message "{@shopp} &f購入に成功しました。 &7(&f%{_suc}%&7)" to {_p} if {_mbuy} is 1
  37. else:
  38. set {_need} to {_cost}-{%{_p}%.coin}
  39. message "{@shopp} &7十分なお金を持っていません。 あと &f%nn({_need}, {_p})% &7coins必要です。&8(%{%{_p}%.coin}/{_cost}*100%&8%%)" to {_p}
  40.  
  41.  
  42.  
  43.  
  44. command /setmaxbuy <integer>:
  45. trigger:
  46. if arg-1 >= 0:
  47. if arg-1 is not 0:
  48. set {%player%.maxbuy} to 0
  49. set {%player%.multibuy} to arg-1
  50. message "&7[&8・&7] &7同時購入回数を &f%arg-1% &7にしました。"
  51. if arg-1 is 0:
  52. set {%player%.maxbuy} to 15
  53. message "&7[&8・&7] &7同時購入回数を &fmax &7にしました。"
  54. else:
  55. message "&7[&8・&7] &c正の整数のみ入力可能"
  56.  
  57. function multibuy(mbuy: number, startp: number, power: number, upgn: number, p: player) :: number:
  58. set {_wn} to {_startp}*({_power}^({%{_p}%.upgrade::%{_upgn}%}+{_mbuy})-{_power}^{%{_p}%.upgrade::%{_upgn}%})/({_power}-1)
  59. return {_wn}
  60.  
  61.  
  62. function maxbuy_guicreate(n: number, p: player):
  63. set {_show} to coloured "&7現在の設定: x%{%{_p}%.multibuy}%" if {%{_p}%.maxbuy} is 0
  64. set {_show} to coloured "&7現在の設定: すべて購入" if {%{_p}%.maxbuy} is not 0
  65. set slot {_n} of {_p}'s current inventory to iron nugget named "&8&l・&7同時購入 &fx1" with lore {_show}
  66. set slot {_n}+1 of {_p}'s current inventory to iron ingot named "&8&l・&7同時購入 &fx10" with lore {_show}
  67. set slot {_n}+2 of {_p}'s current inventory to iron block named "&8&l・&7同時購入 &fx100" with lore {_show}
  68. set slot {_n}+3 of {_p}'s current inventory to bone block named "&8&l・&7すべて購入" with lore {_show}
  69.  
  70.  
  71. on i
  72.  
  73.  
  74.  
  75.  
  76.  
Advertisement
Add Comment
Please, Sign In to add comment