Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.83 KB | None | 0 0
  1. options:
  2. p: &8[&a&lSell&8]
  3.  
  4.  
  5.  
  6. function sellGUI(p: player, s: text = true):
  7. set {_pU} to uuid of {_p}
  8. loop {SellGui::data::items::*}:
  9. if {SellGui::data::items::%loop-value%::worth} != 0:
  10. if {_s} = "true":
  11. set {_%loop-value%Price} to {SellGui::data::items::%loop-value%::worth} * amount of loop-value parsed as item type of {_p}'s current inventory
  12. add amount of loop-value parsed as item type of {_p}'s current inventory to {_amount}
  13. else if {_s} = "sellall" or "autosell":
  14. set {_%loop-value%Price} to {SellGui::data::items::%loop-value%::worth} * amount of loop-value parsed as item type of {_p}'s inventory
  15. add amount of loop-value parsed as item type of {_p}'s inventory to {_amount}
  16. remove all loop-value parsed as item type from {_p}'s inventory
  17. add {_%loop-value%Price} to {_final}
  18.  
  19.  
  20. if {_final} != 0:
  21. if {_p} has permission "sell.multiplier.4":
  22. if {_multiplier} is not set:
  23. add {_final} * 4 to {_p}'s balance
  24. if {_itemsAmountFinal.%{_p}%} is set:
  25. send "{@p} &aSold &f%{_amount}% &aitems for &f$%{_final} * 4% &8(&f&oMultiplier x4&8)" to {_p}
  26. else:
  27. send "{@p} &aSold &f%{_amount}% &aitems for &f$%{_final} * 4% &8(&f&oMultiplier x4&8)" to {_p}
  28. set {_multiplier} to true
  29. if {_s} = "true":
  30. clear {SellPlants::data::%{_pU}%::canceled}
  31. if {_p} has permission "sell.multiplier.3":
  32. if {_multiplier} is not set:
  33. add {_final} * 3 to {_p}'s balance
  34. if {_itemsAmountFinal.%{_p}%} is set:
  35. send "{@p} &aSold &f%{_amount}% &aitems for &f$%{_final} * 3% &8(&f&oMultiplier x3&8)" to {_p}
  36. else:
  37. send "{@p} &aSold &f%{_amount}% &aitems for &f$%{_final} * 3% &8(&f&oMultiplier x3&8)" to {_p}
  38. set {_multiplier} to true
  39. if {_s} = "true":
  40. clear {SellPlants::data::%{_pU}%::canceled}
  41. if {_p} has permission "sell.multiplier.2":
  42. if {_multiplier} is not set:
  43. add {_final} * 2 to {_p}'s balance
  44. if {_itemsAmountFinal.%{_p}%} is set:
  45. send "{@p} &aSold &f%{_amount}% &aitems for &f$%{_final} * 2% &8(&f&oMultiplier x2&8)" to {_p}
  46. else:
  47. send "{@p} &aSold &f%{_amount}% &aitems for &f$%{_final} * 2% &8(&f&oMultiplier x2&8)" to {_p}
  48. set {_multiplier} to true
  49. if {_s} = "true":
  50. clear {SellPlants::data::%{_pU}%::canceled}
  51. else if {_p} doesn't have permission "sell.multiplier.2" or "sell.multiplier.3" or "sell.multiplier.4":
  52. add {_final} to {_p}'s balance
  53. if {_itemsAmountFinal.%{_p}%} is set:
  54. send "{@p} &aSold &f%{_amount}% &aitems for &f$%{_final}%" to {_p}
  55. else:
  56. send "{@p} &aSold &f%{_amount}% &aitems for &f$%{_final}%" to {_p}
  57. if {_s} = "true":
  58. clear {SellPlants::data::%{_pU}%::canceled}
  59. play "ENTITY_EXPERIENCE_ORB_PICKUP" to {_p}
  60. else:
  61. if {_s} = "true" or "sellall":
  62. send "{@p} &cThere is no items to sell." to {_p}
  63.  
  64. function sellCalc(p: player):
  65. set {_pU} to uuid of {_p}
  66. clear {SellCalc.%{_pU}%}
  67.  
  68. if {_p} has permission "sell.multiplier.4":
  69. if {_multiState} is not set:
  70. set {_multi} to 4
  71. set {_multiState} to true
  72. if {_p} has permission "sell.multiplier.3":
  73. if {_multiState} is not set:
  74. set {_multi} to 3
  75. set {_multiState} to true
  76. if {_p} has permission "sell.multiplier.2":
  77. if {_multiState} is not set:
  78. set {_multi} to 2
  79. set {_multiState} to true
  80. if {_p} doesn't have permission "sell.multiplier.2", "sell.multiplier.3" or "sell.multiplier.4":
  81. if {_multiState} is not set:
  82. set {_multi} to 1
  83. set {_multiState} to true
  84.  
  85. loop {SellGui::data::items::*}:
  86. if {SellGui::data::items::%loop-value%::worth} != 0:
  87. set {_%loop-value%Price} to {SellGui::data::items::%loop-value%::worth} * {_multi} * amount of loop-value parsed as item type of {_p}'s current inventory
  88. add {_%loop-value%Price} to {SellCalc.%{_pU}%}
  89.  
  90. if {SellCalc.%{_pU}%} is set:
  91. if {_multi} != 1:
  92. format gui slot 49 of {_p} with sunflower named "&7Total Price: &a$%{SellCalc.%{_pU}%}% &8(&f&oMultiplier x%{_multi}%&8)" to run function sellCalc({_p})
  93. set lore of slot 49 of {_p}'s current inventory to "&7Click to refresh"
  94. else:
  95. format gui slot 49 of {_p} with sunflower named "&7Total Price: &a$%{SellCalc.%{_pU}%}%" to run function sellCalc({_p})
  96. set lore of slot 49 of {_p}'s current inventory to "&7Click to refresh"
  97.  
  98.  
  99. on break:
  100. if player's inventory doesn't have enough space for 1 of event-item:
  101. if "%{AutoSell::players::*}%" contains "%uuid of player%":
  102. sellGUI(player, "autosell")
  103.  
  104. #if player's inventory doesn't have enough space for 64 of event-block:
  105. #cancel event
  106. #wait a tick
  107. #send player title "&cInventory full" with subtitle "&7Sell your items using &f/sell." for 3 seconds
  108. #play "BLOCK_NOTE_BASS" to player
  109.  
  110.  
  111. command /sellall:
  112. permission: sellall.use
  113. permission message: &cYou don't have enough permissions to do that.
  114. trigger:
  115. sellGUI(player, "sellall")
  116. stop
  117.  
  118. command /autosell [<text=help>] [<text>]:
  119. permission: autosell.use
  120. permission message: &cYou don't have enough permissions to do that.
  121. aliases: autos, asell, autosell
  122. trigger:
  123. if arg-1 is "help":
  124. send " &a&lAutoSell &7- &a&lHelp"
  125. send ""
  126. send " &a/autosell on &8- &7To turn on autoselling."
  127. send " &a/autosell off &8- &7To turn off autoselling."
  128. if player has permission "autosell.list":
  129. send " &e/autosell list &8- &7To see all players with AutoSell ON."
  130. send ""
  131. stop
  132. if arg-1 is "list":
  133. if player has permission "autosell.list":
  134. if {AutoSell::players::*} is set:
  135. loop {AutoSell::players::*}:
  136. add "%offline player from uuid loop-value%" to {_list::*}
  137. send " &a&lAutoSell &7- &a&lList"
  138. send " "
  139. send " &a%{_list::*}%"
  140. send " "
  141. stop
  142. else:
  143. send "{@p} &cThere is no one with AutoSell ON."
  144. stop
  145. else:
  146. send "{@p} &cAre you allowed to do that?"
  147. stop
  148. if arg-1 is "on":
  149. if "%{AutoSell::players::*}%" doesn't contain "%uuid of player%":
  150. add uuid of player to {AutoSell::players::*}
  151. send "{@p} &aAutoSell has been turned ON."
  152. stop
  153. else:
  154. send "{@p} &eAutoSell is already ON."
  155. stop
  156. if arg-1 is "off":
  157. if "%{AutoSell::players::*}%" contains "%uuid of player%":
  158. remove uuid of player from {AutoSell::players::*}
  159. send "{@p} &cAutoSell has been turned OFF."
  160. stop
  161. else:
  162. send "{@p} &eAutoSell is already OFF."
  163. stop
  164. else:
  165. send "{@p} &cNo such argument."
  166. stop
  167.  
  168. command /sell [<text>] [<text>]:
  169. permission: sell.use
  170. permission message: &cYou don't have enough permissions to do that.
  171. trigger:
  172. if arg-1 is "list":
  173. if player has permission "sell.%arg-1%":
  174. if {SellGui::data::items::*} is set:
  175. send " &a&lItems &7- &a&llist"
  176. send ""
  177. loop {SellGui::data::items::*}:
  178. if {SellGui::data::items::%loop-value%::name} is set:
  179. json("%player%", " &f&l##%loop-index% &a%loop-value%||ttp:&7Name: &a%colored {SellGui::data::items::%loop-value%::name}%%nl%&7Worth: &a$%{SellGui::data::items::%loop-value%::worth}%%nl%&7Material: &a%loop-value%")
  180. else:
  181. json("%player%", " &f&l##%loop-index% &a%loop-value%||ttp:&7Worth: &a$%{SellGui::data::items::%loop-value%::worth}%%nl%&7Material: &a%loop-value%")
  182. send ""
  183. stop
  184. else:
  185. send "{@p} &cThere is no items set yet."
  186. stop
  187. else:
  188. send "{@p} &cNo enough permissions to do that."
  189. stop
  190. if arg-1 is "remove":
  191. if player has permission "sell.%arg-1%":
  192. if arg-2 is not set:
  193. if player's tool is not air:
  194. set {_item} to "%type of player's tool%"
  195. if {SellGui::data::items::%{_item}%::worth} is set:
  196. clear {SellGui::data::items::%{_item}%::worth}
  197. remove "%{_item}%" from {SellGui::data::items::*}
  198. send "{@p} &f%{_item}% &aitem worth has been removed from the list."
  199. stop
  200. else:
  201. send "{@p} &cCould not find this item the the list."
  202. stop
  203. else:
  204. send "{@p} &cYou must hold an item to do that."
  205. stop
  206. else if arg-2 is "all":
  207. if {SellGui::data::items::*} is not set:
  208. send "{@p} &cNo items in sell list."
  209. stop
  210. loop {SellGui::data::items::*}:
  211. delete {SellGui::data::items::%loop-value%::worth}
  212. remove loop-value from {SellGui::data::items::*}
  213. send "{@p} &fAll items have been removed from sell list."
  214. stop
  215. else:
  216. send "{@p} &cNo enough permissions to do that."
  217. stop
  218. if arg-1 is "worth":
  219. if player has permission "sell.%arg-1%":
  220. if arg-2 parsed as number is set:
  221. if player's tool is not air:
  222. set {_item} to "%type of player's tool%"
  223. if {SellGui::data::items::%{_item}%::worth} is not set:
  224. add "%{_item}%" to {SellGui::data::items::*}
  225. set {SellGui::data::items::%{_item}%::worth} to arg-2 parsed as number
  226. send "{@p} &aAdded &f%type of player's tool% &aitem to items list and worths &f%arg-2%&a."
  227. stop
  228. else:
  229. set {SellGui::data::items::%{_item}%::worth} to arg-2 parsed as number
  230. send "{@p} &f%type of player's tool% &aitem worth has been set to &f%arg-2%&a."
  231. stop
  232. else:
  233. send "{@p} &cYou must hold an item to do that."
  234. stop
  235. else:
  236. send "{@p} &cWorth must be set."
  237. stop
  238. else:
  239. send "{@p} &cNo enough permissions to do that."
  240. stop
  241.  
  242. if arg-1 is "help":
  243. if player has permission "sell.help":
  244. send " &a&lSell &7- &a&lHelp"
  245. send ""
  246. send " &a/sell &8- &7Open the sell GUI."
  247. send " &a/sell help &8- &7Show this message."
  248. send " &a/sell remove &8- &7While holding a named/unnamed and listed item to remove the worth of it."
  249. send " &a/sell worth <cost> &8- &7While holding a named/unnamed item to register it or change the cost of it."
  250. send " &a/sell list &8- &7Shows a list of all registered items with worths."
  251. send " &a/sellall &8- &7Sell all your items without a gui (quick way)."
  252. send " &a/autosell on/off/list &8- &7Toggle AutoSell feature."
  253. send ""
  254. stop
  255. else:
  256. send "{@p} &cNo enough permissions to do that."
  257. stop
  258. if arg-1 is not set:
  259. clear {SellCalc.%uuid of player%}
  260. set {SellPlants::data::%uuid of player%::canceled} to "return"
  261. open virtual chest with 6 rows named "&a&lSell GUI" to player
  262. format gui slot 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 18, 26, 27, 35, 36, 44, 45, 46, 47, 51, 52 and 53 of player with gray stained glass pane named " "
  263. format gui slot 48 of player with redstone dust named "&c&lCancel" to run:
  264. close player's inventory
  265. set lore of slot 48 of player's current inventory to "&7Return all items!"
  266. format gui slot 49 of player with sunflower named "&7Total Price: &a$0" to run function sellCalc(player)
  267. set lore of slot 49 of player's current inventory to "&7Click to refresh"
  268. format gui slot 50 of player with paper named "&a&lConfirm" to run:
  269. sellGUI(player)
  270. loop integers between 9 and 44:
  271. loop {SellGui::data::items::*}:
  272. if slot loop-number-1 of gui-inventory = loop-value-2 parsed as item type:
  273. format gui slot loop-number-1 of player with air
  274. unformat gui slot loop-number-1 of player
  275. set lore of slot 50 of player's current inventory to "&7Sell all imported items."
  276. else:
  277. send "{@p} &cNo such argument."
  278. stop
  279.  
  280.  
  281. on inventory close:
  282. if name of current inventory of player is "&a&lSell GUI":
  283. if {SellPlants::data::%uuid of player%::canceled} is "return":
  284. clear {SellPlants::data::%uuid of player%::canceled}
  285. loop integers between 10 and 44:
  286. if loop-number is not 17, 18, 19, 26, 27, 35, 36 or 44:
  287. if slot loop-number of player's current inventory is not air:
  288. set {_item} to slot loop-number of player's current inventory
  289. set {_true} to true
  290. if player's inventory has enough space for {_item}:
  291. give player {_item}
  292. else:
  293. drop {_item} at player
  294.  
  295. if {_true} is true:
  296. send "{@p} &aAll Your items has been given back to you." to player
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement