Advertisement
Guest User

sellwand

a guest
Sep 1st, 2021
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. options:
  2. ver: 1.0
  3. sellmultiplier: 0.4
  4. sellwand: 1 blaze rod named "&8[&a&lSell&2&lWand&8]"
  5.  
  6. command /sellwand:
  7. trigger:
  8. give player 1 blaze rod named "&8[&a&lSell&2&lWand&8]"
  9.  
  10. on right click:
  11. if name of player's tool = "&8[&a&lSell&2&lWand&8]":
  12. cancel event
  13. if target block = chest:
  14. if distance between player's location and location of target block is less than 5.1:
  15. if player's tool = blaze rod:
  16. set {_a} to line 5 of player's tool's lore
  17. set {_level::*} to {_a} split at "&8> &fDurability: &e"
  18. set {_level} to {_level::2} parsed as a number
  19. set {_amount} to 0
  20. set {_sold} to 0
  21. set {_value} to 0
  22. loop all items in target block's inventory:
  23. set {_item} to 1 of loop-item
  24. if {grow::item::%{_item}%::sell} is set:
  25. if {_level} < 0:
  26. delete player's tool
  27. play sound "item.shield.break" with volume 1 at player for player
  28. stop loop
  29. set {_bashed} to true
  30.  
  31. if {_bashed} != true:
  32. if {_level} < {_amount}:
  33. set {_amount} to {_level}
  34. set {_break} to true
  35.  
  36. set {_amount} to amount of item loop-item
  37. remove loop-item from target block's inventory
  38. add {_amount}*(a rounded {grow::item::%{_item}%::price}*{@sellmultiplier}) to player's balance
  39. add {_amount}*(a rounded {grow::item::%{_item}%::price}*{@sellmultiplier}) to {_value}
  40. add {_amount} to {_sold}
  41. remove {_amount} from {_level}
  42. if {_break} is true:
  43. delete player's tool
  44. play sound "item.shield.break" with volume 1 at player for player
  45. stop loop
  46. else:
  47. add 1 to {_invalid}
  48.  
  49. if {_sold} > 0:
  50. message "%prefix()% Sold &a%easyRead({_sold})% &7items worth &e$%easyRead(a rounded {_value})%"
  51. if {_break} != true:
  52. play sound "entity.player.levelup" with volume 1 at player for player
  53. set line 5 of player's tool's lore to "&8> &fDurability: &e%{_level}%"
  54.  
  55. else:
  56. message "%prefix()% There is nothing you can sell in that chest"
  57. play sound "entity.villager.hurt" with volume 1 at player for player
  58.  
  59. function easyRead(n: number) :: string:
  60.  
  61. set {_n} to "%a rounded {_n}%"
  62. set {_var::*} to {_n} split at ""
  63.  
  64. set {_i} to -1
  65. set {_stuff} to 0
  66. loop {_var::*}:
  67. add 1 to {_i}
  68. set {_lol} to (size of {_var::*}) - {_stuff}
  69. add 1 to {_stuff}
  70. add {_var::%{_lol}%} to {_rtr::*}
  71. if {_i} = 3:
  72. if {_lol} != 1:
  73. add "." to {_rtr::*}
  74. set {_i} to 0
  75.  
  76.  
  77. set {_stuff} to 0
  78. loop size of {_rtr::*}+1 times:
  79. set {_lol} to (size of {_rtr::*})-{_stuff}
  80. add {_rtr::%{_lol}%} to {_rts::*}
  81. add 1 to {_stuff}
  82.  
  83. return join {_rts::*}
  84.  
  85. function prefix() :: string:
  86. return "&2&lGardens"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement