Advertisement
Guest User

Shop Skript for MigFarms.minehut.gg

a guest
Dec 6th, 2019
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.41 KB | None | 0 0
  1. command /shop [<text>]:
  2. trigger:
  3. shop_categories(player)
  4.  
  5. function shop_categories(p: player):
  6. create gui with virtual chest with size 3 named "&2&lShop":
  7.  
  8. make gui 10 with grass block named "&aBlocks" with lore "&7Buy It!":
  9. shop_open("blocks", {_p})
  10. make gui 12 with Redstone block named "&cRedstone" with lore "&7Buy It!":
  11. shop_open("Redstone", {_p})
  12. make gui 14 with wheat named "&eFarming" with lore "&7Buy It!":
  13. shop_open("farming", {_p})
  14. make gui 16 with iron hoe named "&fTools" with lore "&7Buy It!":
  15. shop_open("tools", {_p})
  16.  
  17. make gui 0 with black stained glass pane named "&7" with lore "":
  18. make gui 1 with black stained glass pane named "&7" with lore "":
  19. make gui 2 with black stained glass pane named "&7" with lore "":
  20. make gui 3 with black stained glass pane named "&7" with lore "":
  21. make gui 4 with black stained glass pane named "&7" with lore "":
  22. make gui 5 with black stained glass pane named "&7" with lore "":
  23. make gui 6 with black stained glass pane named "&7" with lore "":
  24. make gui 7 with black stained glass pane named "&7" with lore "":
  25. make gui 8 with black stained glass pane named "&7" with lore "":
  26. make gui 9 with black stained glass pane named "&7" with lore "":
  27. make gui 11 with black stained glass pane named "&7" with lore "":
  28. make gui 13 with black stained glass pane named "&7" with lore "":
  29. make gui 15 with black stained glass pane named "&7" with lore "":
  30. make gui 17 with black stained glass pane named "&7" with lore "":
  31. make gui 18 with black stained glass pane named "&7" with lore "":
  32. make gui 19 with black stained glass pane named "&7" with lore "":
  33. make gui 20 with black stained glass pane named "&7" with lore "":
  34. make gui 21 with black stained glass pane named "&7" with lore "":
  35. make gui 22 with black stained glass pane named "&7" with lore "":
  36. make gui 23 with black stained glass pane named "&7" with lore "":
  37. make gui 24 with black stained glass pane named "&7" with lore "":
  38. make gui 25 with black stained glass pane named "&7" with lore "":
  39. make gui 26 with black stained glass pane named "&7" with lore "":
  40.  
  41. open last gui to {_p}
  42.  
  43. function shop_open(name: string, p: player):
  44. if {_name} = "blocks":
  45. create gui with virtual chest with size 6 named "&aBlocks":
  46.  
  47. make gui 0 with grass block named "&fGrass" with lore "&7Price: &6$25 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  48. shop_gui_handle(grass block, 25, 10, gui-click-type, {_p})
  49. make gui 1 with sand named "&fSand" with lore "&7Price: &6$30 &f/ &6$15", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  50. shop_gui_handle(sand, 30, 15, gui-click-type, {_p})
  51. make gui 2 with andesite named "&fAndesite" with lore "&7Price: &6$15 &f/ &6$20", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  52. shop_gui_handle(andesite, 15, 20, gui-click-type, {_p})
  53. make gui 3 with polished andesite named "&fPolished Andesite" with lore "&7Price: &6$20 &f/ &6$25", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  54. shop_gui_handle(polished andesite, 30, 15, gui-click-type, {_p})
  55. make gui 4 with red concrete named "&fRed Concrete" with lore "&7Price: &6$40 &f/ &6$45", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  56. shop_gui_handle(red concrete, 40, 45, gui-click-type, {_p})
  57. make gui 5 with orange concrete named "&fOrange Concrete" with lore "&7Price: &6$40 &f/ &6$45", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  58. shop_gui_handle(orange concrete, 40, 45, gui-click-type, {_p})
  59. make gui 6 with Yellow concrete named "&fYellow Concrete" with lore "&7Price: &6$40 &f/ &6$45", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  60. shop_gui_handle(yellow concrete, 40, 45, gui-click-type, {_p})
  61. make gui 7 with Green concrete named "&fGreen Concrete" with lore "&7Price: &6$40 &f/ &6$45", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  62. shop_gui_handle(green concrete, 40, 45, gui-click-type, {_p})
  63. make gui 8 with light blue concrete named "&fLight Blue Concrete" with lore "&7Price: &6$40 &f/ &6$45", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  64. shop_gui_handle(light blue concrete, 40, 45, gui-click-type, {_p})
  65. make gui 9 with pink concrete named "&fPink Concrete" with lore "&7Price: &6$40 &f/ &6$45", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  66. shop_gui_handle(pink concrete, 40, 45, gui-click-type, {_p})
  67. make gui 10 with purple concrete named "&fPurple Concrete" with lore "&7Price: &6$40 &f/ &6$45", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  68. shop_gui_handle(purple concrete, 40, 45, gui-click-type, {_p})
  69. make gui 11 with lime concrete named "&fLime Concrete" with lore "&7Price: &6$40 &f/ &6$45", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  70. shop_gui_handle(lime concrete, 40, 45, gui-click-type, {_p})
  71. make gui 12 with cyan concrete named "&fCyan Concrete" with lore "&7Price: &6$40 &f/ &6$45", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  72. shop_gui_handle(cyan concrete, 40, 45, gui-click-type, {_p})
  73. make gui 13 with blue concrete named "&fBlue Concrete" with lore "&7Price: &6$40 &f/ &6$45", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  74. shop_gui_handle(blue concrete, 40, 45, gui-click-type, {_p})
  75. make gui 14 with brown concrete named "&fBrown Concrete" with lore "&7Price: &6$40 &f/ &6$45", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  76. shop_gui_handle(brown concrete, 40, 45, gui-click-type, {_p})
  77. make gui 15 with light gray concrete named "&fLight Gray Concrete" with lore "&7Price: &6$40 &f/ &6$45", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  78. shop_gui_handle(light gray concrete, 40, 45, gui-click-type, {_p})
  79. make gui 16 with gray concrete named "&fGray Concrete" with lore "&7Price: &6$40 &f/ &6$45", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  80. shop_gui_handle(gray concrete, 40, 45, gui-click-type, {_p})
  81. make gui 17 with white concrete named "&fWhite Concrete" with lore "&7Price: &6$40 &f/ &6$45", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  82. shop_gui_handle(white concrete, 40, 45, gui-click-type, {_p})
  83. make gui 18 with black concrete named "&fBlack Concrete" with lore "&7Price: &6$40 &f/ &6$45", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  84. shop_gui_handle(black concrete, 40, 45, gui-click-type, {_p})
  85. make gui 19 with magenta concrete named "&fMagenta Concrete" with lore "&7Price: &6$40 &f/ &6$45", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  86. shop_gui_handle(magenta concrete, 40, 45, gui-click-type, {_p})
  87. make gui 20 with white wool named "&fWhite Wool" with lore "&7Price: &6$5 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  88. shop_gui_handle(white wool, 5, 10, gui-click-type, {_p})
  89. make gui 21 with orange wool named "&fOrange Wool" with lore "&7Price: &6$5 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  90. shop_gui_handle(orange wool, 5, 10, gui-click-type, {_p})
  91. make gui 22 with magenta wool named "&fMagenta Wool" with lore "&7Price: &6$5 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  92. shop_gui_handle(magenta wool, 5, 10, gui-click-type, {_p})
  93. make gui 23 with light blue wool named "&fLight Blue Wool" with lore "&7Price: &6$5 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  94. shop_gui_handle(light blue wool, 5, 10, gui-click-type, {_p})
  95. make gui 25 with lime wool named "&fLime Wool" with lore "&7Price: &6$5 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  96. shop_gui_handle(lime wool, 5, 10, gui-click-type, {_p})
  97. make gui 24 with yellow wool named "&fYellow Wool" with lore "&7Price: &6$5 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  98. shop_gui_handle(yellow wool, 5, 10, gui-click-type, {_p})
  99. make gui 26 with pink wool named "&fPink Wool" with lore "&7Price: &6$5 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  100. shop_gui_handle(Pink wool, 5, 10, gui-click-type, {_p})
  101. make gui 27 with gray wool named "&fGray Wool" with lore "&7Price: &6$5 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  102. shop_gui_handle(gray wool, 5, 10, gui-click-type, {_p})
  103. make gui 28 with light gray wool named "&fLight Gray Wool" with lore "&7Price: &6$5 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  104. shop_gui_handle(light gray wool, 5, 10, gui-click-type, {_p})
  105. make gui 29 with glass pane named "&fGlass Pane" with lore "&7Price: &6$10 &f/ &6$15", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  106. shop_gui_handle(glass pane, 10, 15, gui-click-type, {_p})
  107. make gui 30 with white glass pane named "&fWhite Glass Pane" with lore "&7Price: &6$5 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  108. shop_gui_handle(white glass pane, 5, 10, gui-click-type, {_p})
  109. make gui 31 with orange glass pane named "&fOrange Glass Pane" with lore "&7Price: &6$5 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  110. shop_gui_handle(orange glass pane, 5, 10, gui-click-type, {_p})
  111. make gui 32 with yellow glass pane named "&fYellow Glass Pane" with lore "&7Price: &6$5 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  112. shop_gui_handle(yellow glass pane, 5, 10, gui-click-type, {_p})
  113. make gui 33 with green glass pane named "&fGreen Glass Pane" with lore "&7Price: &6$5 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  114. shop_gui_handle(green glass pane, 5, 10, gui-click-type, {_p})
  115. make gui 34 with blue glass pane named "&fBlue Glass Pane" with lore "&7Price: &6$5 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  116. shop_gui_handle(blue glass pane, 5, 10, gui-click-type, {_p})
  117. make gui 35 with pink glass pane named "&fPink Glass Pane" with lore "&7Price: &6$5 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  118. shop_gui_handle(pink glass pane, 5, 10, gui-click-type, {_p})
  119. make gui 36 with black glass pane named "&fBlack Glass Pane" with lore "&7Price: &6$5 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  120. shop_gui_handle(black glass pane, 5, 10, gui-click-type, {_p})
  121. make gui 37 with glass named "&fGlass" with lore "&7Price: &6$10 &f/ &6$15", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  122. shop_gui_handle(glass, 10, 15, gui-click-type, {_p})
  123. make gui 38 with white glass named "&fWhite Glass" with lore "&7Price: &6$5 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  124. shop_gui_handle(white glass, 5, 10, gui-click-type, {_p})
  125. make gui 39 with orange glass named "&fOrange Glass" with lore "&7Price: &6$5 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  126. shop_gui_handle(orange glass pane, 5, 10, gui-click-type, {_p})
  127. make gui 40 with yellow glass named "&fYellow Glass" with lore "&7Price: &6$5 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  128. shop_gui_handle(yellow glass, 5, 10, gui-click-type, {_p})
  129. make gui 41 with green glass named "&fGreen Glass" with lore "&7Price: &6$5 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  130. shop_gui_handle(green glass pane, 5, 10, gui-click-type, {_p})
  131. make gui 42 with blue glass named "&fBlue Glass" with lore "&7Price: &6$5 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  132. shop_gui_handle(blue glass, 5, 10, gui-click-type, {_p})
  133. make gui 43 with pink glass named "&fPink Glass" with lore "&7Price: &6$5 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  134. shop_gui_handle(pink glass, 5, 10, gui-click-type, {_p})
  135. make gui 44 with black glass named "&fBlack Glass " with lore "&7Price: &6$5 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  136. shop_gui_handle(black glass, 5, 10, gui-click-type, {_p})
  137. make gui 45 with quartz block named "&fQuartz Block " with lore "&7Price: &6$100 &f/ &6$105", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  138. shop_gui_handle(quartz block, 100, 105, gui-click-type, {_p})
  139. make gui 46 with quartz slab named "&fQuartz Slab " with lore "&7Price: &6$100 &f/ &6$105", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  140. shop_gui_handle(quartz slab, 100, 105, gui-click-type, {_p})
  141. make gui 47 with quartz pillar named "&fQuartz Pillar " with lore "&7Price: &6$100 &f/ &6$105", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  142. shop_gui_handle(quartz pillar, 110, 115, gui-click-type, {_p})
  143. make gui 48 with quartz stairs named "&fQuartz Stairs " with lore "&7Price: &6$100 &f/ &6$105", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  144. shop_gui_handle(quartz stairs, 110, 115, gui-click-type, {_p})
  145.  
  146.  
  147. make gui 53 with red stained glass pane named "&c< Go back":
  148. shop_categories({_p})
  149.  
  150. else if {_name} = "Redstone":
  151. create gui with virtual chest with size 1 named "&cRedstone":
  152.  
  153. make gui 0 with Redstone dust named "&fRedstone Dust" with lore "&7Price: &6$20 &f/ &6$30", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  154. shop_gui_handle(Redstone dust, 100, 50, gui-click-type, {_p})
  155. make gui 1 with piston named "&fPiston" with lore "&7Price: &6$200 &f/ &6$220", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  156. shop_gui_handle(piston, 200, 220, gui-click-type, {_p})
  157. make gui 2 with sticky piston named "&fSticky Piston" with lore "&7Price: &6$200 &f/ &6$220", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  158. shop_gui_handle(sticky piston, 200, 220, gui-click-type, {_p})
  159. make gui 3 with observer named "&fObserver" with lore "&7Price: &6$1200 &f/ &6$1220", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  160. shop_gui_handle(observer, 1200, 1220, gui-click-type, {_p})
  161. make gui 4 with Redstone repeater named "&fRepeater" with lore "&7Price: &6$320 &f/ &6$325", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  162. shop_gui_handle(Redstone repeater, 320, 325, gui-click-type, {_p})
  163. make gui 5 with Redstone comparator named "&fComparator" with lore "&7Price: &6$320 &f/ &6$325", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  164. shop_gui_handle(Redstone comparator, 320, 325, gui-click-type, {_p})
  165. make gui 6 with hopper named "&fHopper" with lore "&7Price: &6$1200 &f/ &6$1220", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  166. shop_gui_handle(hopper, 1200, 1220, gui-click-type, {_p})
  167. make gui 7 with dispenser named "&fDispenser" with lore "&7Price: &6$1200 &f/ &6$1220", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  168. shop_gui_handle(dispenser, 1200, 1220, gui-click-type, {_p})
  169.  
  170. make gui 8 with red stained glass pane named "&c< Go back":
  171. shop_categories({_p})
  172.  
  173. else if {_name} = "Farming":
  174. create gui with virtual chest with size 1 named "&eFarming":
  175.  
  176. make gui 0 with wheat seeds named "&fWheat Seeds" with lore "&7Price: &6$5 &f/ &6$10", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  177. shop_gui_handle(wheat seeds, 5, 10, gui-click-type, {_p})
  178. make gui 1 with melon seeds named "&fMelon Seeds" with lore "&7Price: &6$120 &f/ &6$130", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  179. shop_gui_handle(melon seeds, 120, 130, gui-click-type, {_p})
  180. make gui 2 with pumpkin seeds named "&fPumpkin Seeds" with lore "&7Price: &6$120 &f/ &6$130", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  181. shop_gui_handle(pumpkin seeds, 120, 130, gui-click-type, {_p})
  182. make gui 3 with cactus named "&fCactus" with lore "&7Price: &6$150 &f/ &6$180", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  183. shop_gui_handle(cactus, 150, 80, gui-click-type, {_p})
  184. make gui 4 with sugar cane named "&fSugar Cane" with lore "&7Price: &6$200 &f/ &6$230", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  185. shop_gui_handle(sugar cane, 200, 230, gui-click-type, {_p})
  186. make gui 5 with water bucket named "&fWater Bucket" with lore "&7Price: &6$120 &f/ &6$130", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  187. shop_gui_handle(water bucket, 120, 130, gui-click-type, {_p})
  188.  
  189. make gui 8 with red stained glass pane named "&c< Go back":
  190. shop_categories({_p})
  191.  
  192. else if {_name} = "Tools":
  193. create gui with virtual chest with size 4 named "&7Tools":
  194.  
  195. make gui 10 with diamond hoe named "&fDiamond Hoe" with lore "&7Price: &6$500 &f/ &6$1000", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  196. shop_gui_handle(Diamond Hoe, 500, 1000, gui-click-type, {_p})
  197. make gui 16 with iron hoe named "&fIron Hoe" with lore "&7Price: &6$250 &f/ &6$500", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  198. shop_gui_handle(Iron Hoe, 250, 500, gui-click-type, {_p})
  199. make gui 19 with diamond pickaxe named "&fDiamond Pickaxe" with lore "&7Price: &6$500 &f/ &6$1000", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  200. shop_gui_handle(Diamond pickaxe, 500, 1000, gui-click-type, {_p})
  201. make gui 25 with iron pickaxe named "&fIron Pickaxe" with lore "&7Price: &6$250 &f/ &6$500", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  202. shop_gui_handle(iron pickaxe, 500, 1000, gui-click-type, {_p})
  203. make gui 13 with cooked beef named "&fSteak" with lore "&7Price: &6$20 &f/ &6$30", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  204. shop_gui_handle(Steak, 20, 30, gui-click-type, {_p})
  205. make gui 22 with cooked beef named "&fSteak" with lore "&7Price: &6$20 &f/ &6$30", " ", "&6Left-click &7to buy." and "&6Right-click &7to sell.":
  206. shop_gui_handle(Steak, 20, 30, gui-click-type, {_p})
  207. else:
  208. stop
  209.  
  210. open last gui to {_p}
  211.  
  212.  
  213. #
  214. #
  215. #
  216. #
  217. #
  218. #
  219.  
  220. function util_formatnumber(value: number) :: string:
  221. set {_chars::*} to "T", "B", "M" and "k"
  222. loop 15, 12, 9 and 3:
  223. add 1 to {_n}
  224.  
  225. if {_value} >= 10^loop-value:
  226. return "%{_value} / 10^loop-value%%{_n}th element of {_chars::*}%"
  227. return "%{_value}%"
  228.  
  229. function shop_gui_handle(i: item, buyprice: number, sellprice: number, click: clicktype, p: player):
  230. if {_click} = left mouse button:
  231. shop_gui_amounts({_i}, {_buyprice}, {_sellprice}, true, {_p})
  232. else if {_click} = right mouse button:
  233. shop_gui_amounts({_i}, {_buyprice}, {_selprice}, false, {_p})
  234.  
  235. function shop_gui_amounts(i: item, buyprice: number, sellprice: number, buy: boolean, p: player):
  236. if {_buy} = true:
  237. set {_name} to "&aBuying"
  238. else:
  239. set {_name} to "&aSelling"
  240. create gui with virtual chest with size 5 named "&aBuying...":
  241.  
  242. make gui 13 with {_i}
  243.  
  244. loop 1, 4, 16, 32 and 64:
  245.  
  246. add 1 to {_n}
  247. set {_amount} to loop-value
  248. if {_buy} = true:
  249. make gui (28 + {_n}) with ({_amount} of {_i}) named "&aBuy x%{_amount}%" with lore "&7Price: &a$%util_formatnumber({_buyprice} * {_amount})%":
  250. shop_buy({_i}, {_amount}, {_buyprice}, {_p})
  251. else:
  252. make gui (28 + {_n}) with ({_amount} of {_i}) named "&aSell x%{_amount}%" with lore "&7Price: &a$%util_formatnumber({_sellprice} * {_amount})%":
  253. shop_sell({_i}, {_amount}, {_sellprice}, {_p})
  254. make gui 40 with (red stained glass pane) named "&c< Go back":
  255. shop_categories({_p})
  256.  
  257. open last gui to {_p}
  258.  
  259. function shop_buy(i: item, n: number, price: number, p: player):
  260. set {_total} to {_n} * {_price}
  261. if {_p}'s balance < {_total}:
  262. send "&3[Shop] &fYou don't have &c$%{_total}% &fto buy that!" to {_p}
  263. else if {_p} can't hold {_n} of {_i}:
  264. send "&3[Shop] &fYou don't have enough &cspace &fin your inventory!" to {_p}
  265. else:
  266. remove {_total} from {_p}'s balance
  267. give {_n} of {_i} to {_p}
  268.  
  269. send "&3[Shop] &fYou bought &a%{_n}% &fof &a%type of {_i}% &ffor &a$%{_total}%&f." to {_p}
  270.  
  271. function shop_sell(i: item, n: number, price: number, p: player):
  272. set {_has} to number of {_i} in {_p}'s inventory
  273. if {_has} = 0:
  274. send "&3[Shop] &fYou don't have &cany items &fto sell!" to {_p}
  275. else:
  276. set {_selling} to min({_n}, number of {_i} in {_p}'s inventory)
  277.  
  278. set {_total} to {_selling} * {_price}
  279.  
  280. remove {_selling} of {_i} from {_p}'s inventory
  281. add {_total} to {_p}'s balance
  282.  
  283. send "&3[Shop} &fYou sold &a%{_selling}% %type of {_i}% &ffor &a$%{_total}%&f!" to {_p}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement