Advertisement
K2Rk1o

Untitled

Dec 23rd, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.87 KB | None | 0 0
  1. #---------------------------------------------------------------------------------------------
  2. options:
  3. prefix: &7[&6Trading&7] &f
  4. command: /trade
  5. aliases: /trading, /trade
  6. usage: &cThe correct command is &l/trade (player) &cmake sure that the user is online.
  7. header: " &5&nYours&r &4&nTheirs"
  8. #The item dividing each side
  9. divider: gray stained glass pane named "&6"
  10. #The item to click and move back a step
  11. cancel: red stained glass pane named "&cClick me to cancel trade"
  12. #state 0 - when the user opens the gui
  13. state0: orange stained glass pane named "&5Click me to accept trade"
  14. #state 1 - when the user is ready to accept
  15. state1: yellow stained glass pane named "&6Click me again to confirm trade"
  16. #state 2 - when the user is ready to accept
  17. state2: green stained glass pane named "&aWaiting on tradee..."
  18. #otherstate is the what the other tradee will see.
  19. #otherstate 0 - when the user opens the gui
  20. otherstate0: orange stained glass pane named "&6Other tradee's state"
  21. #otherstate 1 - when the user is ready to accept
  22. otherstate1: yellow stained glass pane named "&6Waiting for you to accept"
  23. #time before the request expires.
  24. timeout: 2 minutes
  25. #should users in creative be allowed to trade?
  26. trade-creative: false
  27. #should users within a range only be allowed to trade?
  28. trade-range: true
  29. range: 50
  30.  
  31. #Messages
  32. sent: &aTrade request sent to %argument parsed as player%
  33. trade: &6&l%player% &6has requested to make a trade with you. Type &a&l/trade accept &6to accept or &c&l/trade deny &6to deny.
  34. already: &cYou have already requested a trade. To cancel trade type &l/trade cancel
  35. cancelled: &cYou cancelled your trade request.
  36. deny: &cYou denied your trade request.
  37. denied: &cYour trade reqest was denied.
  38. timed-out: &cThe request to %argument parsed as player% has expired.
  39. no-trade: &cYou have no trade requests pending.
  40. close-inventory-trade: &cThe user you were trading with has cancelled the trade.
  41. max-slots: You may only insert up to 20 slots worth of items.
  42. complete: The trade has been successful.
  43. reload: The trading system has been reloaded by the console, all trades refunded.
  44. trade-self: You can't trade with yourself, that's pointless.
  45. no-permission: You don't have the correct permissions to trade with users.
  46. creative: You can't trade when in creative mode.
  47. outofrange: You can't trade with this user because they're too far away, you need to be atleast 10 blocks away.
  48. #---------------------------------------------------------------------------------------------
  49. on script unload:
  50. loop all players:
  51. if name of loop-player's current inventory is {@header}:
  52. loop {trading::temp::slots::*}:
  53. if slot loop-value-2 of loop-player's current inventory is not air:
  54. add slot loop-value-2 of loop-player's current inventory to loop-player's inventory
  55. set slot loop-value-2 of loop-player's current inventory to air
  56. close loop-player's inventory
  57. message "{@prefix}{@reload}" to loop-player
  58. delete {trading::temp::*}
  59. on script load:
  60. wait a tick
  61. set {trading::temp::slots::*} to 0, 1, 2, 3, 9, 10, 11, 12, 18, 19, 20, 21, 27, 28, 29, 30, 36, 37, 38 and 39
  62. command {@command} [<string = "0">]:
  63. aliases: {@aliases}
  64. trigger:
  65. if argument is "0":
  66. message "{@prefix}{@usage}"
  67. else if argument is "accept":
  68. loop all players:
  69. {trading::temp::player::%loop-player%::request} is player
  70. delete {trading::temp::player::%loop-player%::request}
  71. set {_user} to loop-player
  72. exit loop
  73. if {_user} is not set:
  74. message "{@prefix}{@no-trade}"
  75. stop
  76. set {trading::temp::player::%{_user}%::state} and {trading::temp::player::%player%::state} to 0
  77. set {trading::temp::player::%{_user}%::trading} to player
  78. set {trading::temp::player::%player%::trading} to {_user}
  79. set {trading::temp::player::%player%::inventory} to chest inventory with 6 rows named {@header}
  80. set {trading::temp::player::%{_user}%::inventory} to chest inventory with 6 rows named {@header}
  81. set slots integers between 45 and 48 of {trading::temp::player::%player%::inventory} to {@state0}
  82. set slots integers between 50 and 53 of {trading::temp::player::%player%::inventory} to {@otherstate0}
  83. set slots integers between 45 and 48 of {trading::temp::player::%{_user}%::inventory} to {@state0}
  84. set slots integers between 50 and 53 of {trading::temp::player::%{_user}%::inventory} to {@otherstate0}
  85. set slot 48 of {trading::temp::player::%player%::inventory} to {@cancel}
  86. set slot 48 of {trading::temp::player::%{_user}%::inventory} to {@cancel}
  87. set slots 4, 13, 22, 31, 40 and 49 of {trading::temp::player::%player%::inventory} to {@divider}
  88. set slots 4, 13, 22, 31, 40 and 49 of {trading::temp::player::%{_user}%::inventory} to {@divider}
  89. open {trading::temp::player::%player%::inventory} to player
  90. open {trading::temp::player::%{_user}%::inventory} to {_user}
  91. else if argument is "deny":
  92. loop all players:
  93. if {trading::temp::player::%loop-player%::request} is player:
  94. delete {trading::temp::player::%loop-player%::request}
  95. message "{@prefix}{@denied}" to loop-player
  96. set {_found} to true
  97. if {trading::temp::player::%player%::request} and {_found} are not set:
  98. message "{@prefix}{@no-trade}"
  99. else:
  100. message "{@prefix}{@deny}"
  101. delete {trading::temp::player::%player%::request}
  102. else if argument is "cancel":
  103. if {trading::temp::player::%player%::trading} is set:
  104. close player's inventory
  105. else if {trading::temp::player::%player%::request} is not set:
  106. message "{@prefix}{@no-trade}"
  107. stop
  108. delete {trading::temp::player::%player%::request}
  109. message "{@prefix}{@cancelled}"
  110. else if argument parsed as player is online:
  111. if {trading::temp::player::%player%::request} or {trading::temp::player::%player%::trading} is set:
  112. message "{@prefix}{@already}"
  113. stop
  114. if argument parsed as player is player:
  115. message "{@prefix}{@trade-self}"
  116. stop
  117. if gamemode of player is creative:
  118. {@trade-creative} is true
  119. message "{@prefix}{@creative}"
  120. stop
  121. if distance between player and argument parsed as player > {@range}:
  122. {@trade-range} is true
  123. message "{@prefix}{@outofrange}"
  124. stop
  125. message "{@prefix}{@trade}" to argument parsed as player
  126. message "{@prefix}{@sent}"
  127. set {trading::temp::player::%player%::request} to argument parsed as player
  128. while {trading::temp::player::%player%::request} is set:
  129. wait a second
  130. add a second to {_tracker}
  131. if {_tracker} >= {@timeout}:
  132. {trading::temp::player::%player%::request} is set
  133. delete {trading::temp::player::%player%::request}
  134. message "{@prefix}{@timed-out}"
  135. else:
  136. message "{@prefix}{@usage}"
  137. on inventory close:
  138. {trading::temp::player::%player%::state} is set
  139. {trading::temp::player::%player%::state} < 4
  140. set {_user} to {trading::temp::player::%player%::trading}
  141. #Cancels any trades the user may have.
  142. if name of event-inventory is {@header}:
  143. loop {trading::temp::slots::*}:
  144. if slot loop-value of event-inventory is not air:
  145. add slot loop-value of event-inventory to player's inventory
  146. set slot loop-value of event-inventory to air
  147. if slot loop-value of {trading::temp::player::%{_user}%::inventory} is not air:
  148. add slot loop-value of {trading::temp::player::%{_user}%::inventory} to {_user}'s inventory
  149. set slot loop-value of {trading::temp::player::%{_user}%::inventory} to air
  150. delete {trading::temp::player::%{trading::temp::player::%player%::trading}%::*}
  151. message "{@prefix}{@close-inventory-trade}" to {trading::temp::player::%player%::trading}
  152. message "{@prefix}{@cancelled}"
  153. close inventory of {trading::temp::player::%player%::trading}
  154. delete {trading::temp::player::%player%::*}
  155. on inventory click:
  156. if name of current inventory is {@header}:
  157. cancel event
  158. set {_user} to {trading::temp::player::%player%::trading}
  159. if clicked inventory is not the player's inventory:
  160. if clicked slot is between 45 and 48:
  161. play sound "UI_BUTTON_CLICK" with volume 1 with pitch 1 at player's location for player
  162. if clicked slot is 48:
  163. #They want to cancel the trade.
  164. close player's inventory
  165. else:
  166. #They want to accept the trade.
  167. if {trading::temp::player::%player%::state} is 0:
  168. set slots integers between 45 and 48 of {trading::temp::player::%player%::inventory} to {@state2}
  169. set slots integers between 50 and 53 of {trading::temp::player::%{_user}%::inventory} to {@otherstate1}
  170. set slot 48 of {trading::temp::player::%player%::inventory} to {@cancel}
  171. set {trading::temp::player::%player%::state} to 1
  172. if {trading::temp::player::%player%::state} and {trading::temp::player::%{_user}%::state} are 1:
  173. set slots integers between 45 and 48 of {trading::temp::player::%player%::inventory} to {@state1}
  174. set slots integers between 50 and 53 of {trading::temp::player::%player%::inventory} to {@otherstate0}
  175. set slots integers between 45 and 48 of {trading::temp::player::%{_user}%::inventory} to {@state1}
  176. set slots integers between 50 and 53 of {trading::temp::player::%{_user}%::inventory} to {@otherstate0}
  177. set slot 48 of {trading::temp::player::%player%::inventory} to {@cancel}
  178. set slot 48 of {trading::temp::player::%{_user}%::inventory} to {@cancel}
  179. set {trading::temp::player::%{_user}%::state} and {trading::temp::player::%player%::state} to 2
  180. else if {trading::temp::player::%player%::state} is 2:
  181. #Second round of confirming trade.
  182. set slots integers between 45 and 48 of {trading::temp::player::%player%::inventory} to {@state2}
  183. set slots integers between 50 and 53 of {trading::temp::player::%{_user}%::inventory} to {@otherstate1}
  184. set slot 48 of {trading::temp::player::%player%::inventory} to {@cancel}
  185. set {trading::temp::player::%player%::state} to 3
  186. if {trading::temp::player::%player%::state} and {trading::temp::player::%{_user}%::state} are 3:
  187. loop {trading::temp::slots::*}:
  188. if slot loop-value of {trading::temp::player::%player%::inventory} is not air:
  189. add slot loop-value of {trading::temp::player::%player%::inventory} to inventory of {_user}
  190. set slot loop-value of {trading::temp::player::%player%::inventory} to air
  191. if slot loop-value of {trading::temp::player::%{_user}%::inventory} is not air:
  192. add slot loop-value of {trading::temp::player::%{_user}%::inventory} to inventory of player
  193. set slot loop-value of {trading::temp::player::%{_user}%::inventory} to air
  194. delete {trading::temp::player::%player%::*}
  195. delete {trading::temp::player::%{_user}%::*}
  196. message "{@prefix}{@complete}" to player and {_user}
  197. play sound "ENTITY_PLAYER_LEVELUP" with volume 1 with pitch 1 at player's location for player
  198. play sound "ENTITY_PLAYER_LEVELUP" with volume 1 with pitch 1 at {_user}'s location for {_user}
  199. close inventory of player and {_user}
  200. else:
  201. #Gives back the item they have added to the trade.
  202. loop {trading::temp::slots::*}:
  203. loop-value is clicked slot
  204. slot loop-value of current inventory is not air
  205. add slot loop-value of current inventory to player's inventory
  206. set slot loop-value of current inventory to air
  207. set slot loop-value + 5 of {trading::temp::player::%{_user}%::inventory} to air
  208. play sound "ENTITY_EXPERIENCE_ORB_PICKUP" with volume 1 with pitch 1 at player's location for player
  209. stop
  210. else:
  211. #Add item to the trade.
  212. slot clicked slot of clicked inventory is not air
  213. loop {trading::temp::slots::*}:
  214. if slot loop-value of current inventory is air:
  215. set slot loop-value of current inventory to event-item
  216. set slot loop-value + 5 of {trading::temp::player::%{_user}%::inventory} to event-item
  217. play sound "ENTITY_EXPERIENCE_ORB_PICKUP" with volume 1 with pitch 4 at player's location for player
  218. set slot clicked slot of clicked inventory to air
  219. if {trading::temp::player::%player%::state} is not 0:
  220. set {trading::temp::player::%{_user}%::state} and {trading::temp::player::%player%::state} to 0
  221. set slots integers between 45 and 48 of {trading::temp::player::%player%::inventory} to {@state0}
  222. set slots integers between 50 and 53 of {trading::temp::player::%player%::inventory} to {@otherstate0}
  223. set slots integers between 45 and 48 of {trading::temp::player::%{_user}%::inventory} to {@state0}
  224. set slots integers between 50 and 53 of {trading::temp::player::%{_user}%::inventory} to {@otherstate0}
  225. set slot 48 of {trading::temp::player::%player%::inventory} to {@cancel}
  226. set slot 48 of {trading::temp::player::%{_user}%::inventory} to {@cancel}
  227. stop
  228. message "{@prefix}{@max-slots}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement