Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #---------------------------------------------------------------------------------------------
- options:
- prefix: &7[&6Trading&7] &f
- command: /trade
- aliases: /trading, /trade
- usage: &cThe correct command is &l/trade (player) &cmake sure that the user is online.
- header: " &5&nYours&r &4&nTheirs"
- #The item dividing each side
- divider: gray stained glass pane named "&6"
- #The item to click and move back a step
- cancel: red stained glass pane named "&cClick me to cancel trade"
- #state 0 - when the user opens the gui
- state0: orange stained glass pane named "&5Click me to accept trade"
- #state 1 - when the user is ready to accept
- state1: yellow stained glass pane named "&6Click me again to confirm trade"
- #state 2 - when the user is ready to accept
- state2: green stained glass pane named "&aWaiting on tradee..."
- #otherstate is the what the other tradee will see.
- #otherstate 0 - when the user opens the gui
- otherstate0: orange stained glass pane named "&6Other tradee's state"
- #otherstate 1 - when the user is ready to accept
- otherstate1: yellow stained glass pane named "&6Waiting for you to accept"
- #time before the request expires.
- timeout: 2 minutes
- #should users in creative be allowed to trade?
- trade-creative: true
- #should users within a range only be allowed to trade?
- trade-range: true
- range: 10
- #Messages
- sent: &aTrade request sent to %argument parsed as player%
- 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.
- already: &cYou have already requested a trade. To cancel trade type &l/trade cancel
- cancelled: &cYou cancelled your trade request.
- deny: &cYou denied your trade request.
- denied: &cYour trade reqest was denied.
- timed-out: &cThe request to %argument parsed as player% has expired.
- no-trade: &cYou have no trade requests pending.
- close-inventory-trade: &cThe user you were trading with has cancelled the trade.
- max-slots: You may only insert up to 20 slots worth of items.
- complete: The trade has been successful.
- reload: The trading system has been reloaded by the console, all trades refunded.
- trade-self: You can't trade with yourself, that's pointless.
- no-permission: You don't have the correct permissions to trade with users.
- creative: You can't trade when in creative mode.
- outofrange: You can't trade with this user because they're too far away, you need to be atleast 10 blocks away.
- #---------------------------------------------------------------------------------------------
- on script unload:
- loop all players:
- if name of loop-player's current inventory is {@header}:
- loop {trading::temp::slots::*}:
- if slot loop-value-2 of loop-player's current inventory is not air:
- add slot loop-value-2 of loop-player's current inventory to loop-player's inventory
- set slot loop-value-2 of loop-player's current inventory to air
- close loop-player's inventory
- message "{@prefix}{@reload}" to loop-player
- delete {trading::temp::*}
- on script load:
- wait a tick
- 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
- command {@command} [<string = "0">]:
- aliases: {@aliases}
- trigger:
- if argument is "0":
- message "{@prefix}{@usage}"
- else if argument is "accept":
- loop all players:
- {trading::temp::player::%loop-player%::request} is player
- delete {trading::temp::player::%loop-player%::request}
- set {_user} to loop-player
- exit loop
- if {_user} is not set:
- message "{@prefix}{@no-trade}"
- stop
- set {trading::temp::player::%{_user}%::state} and {trading::temp::player::%player%::state} to 0
- set {trading::temp::player::%{_user}%::trading} to player
- set {trading::temp::player::%player%::trading} to {_user}
- set {trading::temp::player::%player%::inventory} to chest inventory with 6 rows named {@header}
- set {trading::temp::player::%{_user}%::inventory} to chest inventory with 6 rows named {@header}
- set slots integers between 45 and 48 of {trading::temp::player::%player%::inventory} to {@state0}
- set slots integers between 50 and 53 of {trading::temp::player::%player%::inventory} to {@otherstate0}
- set slots integers between 45 and 48 of {trading::temp::player::%{_user}%::inventory} to {@state0}
- set slots integers between 50 and 53 of {trading::temp::player::%{_user}%::inventory} to {@otherstate0}
- set slot 48 of {trading::temp::player::%player%::inventory} to {@cancel}
- set slot 48 of {trading::temp::player::%{_user}%::inventory} to {@cancel}
- set slots 4, 13, 22, 31, 40 and 49 of {trading::temp::player::%player%::inventory} to {@divider}
- set slots 4, 13, 22, 31, 40 and 49 of {trading::temp::player::%{_user}%::inventory} to {@divider}
- open {trading::temp::player::%player%::inventory} to player
- open {trading::temp::player::%{_user}%::inventory} to {_user}
- else if argument is "deny":
- loop all players:
- if {trading::temp::player::%loop-player%::request} is player:
- delete {trading::temp::player::%loop-player%::request}
- message "{@prefix}{@denied}" to loop-player
- set {_found} to true
- if {trading::temp::player::%player%::request} and {_found} are not set:
- message "{@prefix}{@no-trade}"
- else:
- message "{@prefix}{@deny}"
- delete {trading::temp::player::%player%::request}
- else if argument is "cancel":
- if {trading::temp::player::%player%::trading} is set:
- close player's inventory
- else if {trading::temp::player::%player%::request} is not set:
- message "{@prefix}{@no-trade}"
- stop
- delete {trading::temp::player::%player%::request}
- message "{@prefix}{@cancelled}"
- else if argument parsed as player is online:
- if {trading::temp::player::%player%::request} or {trading::temp::player::%player%::trading} is set:
- message "{@prefix}{@already}"
- stop
- if argument parsed as player is player:
- message "{@prefix}{@trade-self}"
- stop
- if player has permission "trade.use":
- message "{@prefix}{@no-permission}"
- stop
- if gamemode of player is creative:
- {@trade-creative} is true
- message "{@prefix}{@creative}"
- stop
- if distance between player and argument parsed as player > {@range}:
- {@trade-range} is true
- message "{@prefix}{@outofrange}"
- stop
- message "{@prefix}{@trade}" to argument parsed as player
- message "{@prefix}{@sent}"
- set {trading::temp::player::%player%::request} to argument parsed as player
- while {trading::temp::player::%player%::request} is set:
- wait a second
- add a second to {_tracker}
- if {_tracker} >= {@timeout}:
- {trading::temp::player::%player%::request} is set
- delete {trading::temp::player::%player%::request}
- message "{@prefix}{@timed-out}"
- else:
- message "{@prefix}{@usage}"
- on inventory close:
- {trading::temp::player::%player%::state} is set
- {trading::temp::player::%player%::state} < 4
- set {_user} to {trading::temp::player::%player%::trading}
- #Cancels any trades the user may have.
- if name of event-inventory is {@header}:
- loop {trading::temp::slots::*}:
- if slot loop-value of event-inventory is not air:
- add slot loop-value of event-inventory to player's inventory
- set slot loop-value of event-inventory to air
- if slot loop-value of {trading::temp::player::%{_user}%::inventory} is not air:
- add slot loop-value of {trading::temp::player::%{_user}%::inventory} to {_user}'s inventory
- set slot loop-value of {trading::temp::player::%{_user}%::inventory} to air
- delete {trading::temp::player::%{trading::temp::player::%player%::trading}%::*}
- message "{@prefix}{@close-inventory-trade}" to {trading::temp::player::%player%::trading}
- message "{@prefix}{@cancelled}"
- close inventory of {trading::temp::player::%player%::trading}
- delete {trading::temp::player::%player%::*}
- on inventory click:
- if name of current inventory is {@header}:
- cancel event
- set {_user} to {trading::temp::player::%player%::trading}
- if clicked inventory is not the player's inventory:
- if clicked slot is between 45 and 48:
- play sound "UI_BUTTON_CLICK" with volume 1 with pitch 1 at player's location for player
- if clicked slot is 48:
- #They want to cancel the trade.
- close player's inventory
- else:
- #They want to accept the trade.
- if {trading::temp::player::%player%::state} is 0:
- set slots integers between 45 and 48 of {trading::temp::player::%player%::inventory} to {@state2}
- set slots integers between 50 and 53 of {trading::temp::player::%{_user}%::inventory} to {@otherstate1}
- set slot 48 of {trading::temp::player::%player%::inventory} to {@cancel}
- set {trading::temp::player::%player%::state} to 1
- if {trading::temp::player::%player%::state} and {trading::temp::player::%{_user}%::state} are 1:
- set slots integers between 45 and 48 of {trading::temp::player::%player%::inventory} to {@state1}
- set slots integers between 50 and 53 of {trading::temp::player::%player%::inventory} to {@otherstate0}
- set slots integers between 45 and 48 of {trading::temp::player::%{_user}%::inventory} to {@state1}
- set slots integers between 50 and 53 of {trading::temp::player::%{_user}%::inventory} to {@otherstate0}
- set slot 48 of {trading::temp::player::%player%::inventory} to {@cancel}
- set slot 48 of {trading::temp::player::%{_user}%::inventory} to {@cancel}
- set {trading::temp::player::%{_user}%::state} and {trading::temp::player::%player%::state} to 2
- else if {trading::temp::player::%player%::state} is 2:
- #Second round of confirming trade.
- set slots integers between 45 and 48 of {trading::temp::player::%player%::inventory} to {@state2}
- set slots integers between 50 and 53 of {trading::temp::player::%{_user}%::inventory} to {@otherstate1}
- set slot 48 of {trading::temp::player::%player%::inventory} to {@cancel}
- set {trading::temp::player::%player%::state} to 3
- if {trading::temp::player::%player%::state} and {trading::temp::player::%{_user}%::state} are 3:
- loop {trading::temp::slots::*}:
- if slot loop-value of {trading::temp::player::%player%::inventory} is not air:
- add slot loop-value of {trading::temp::player::%player%::inventory} to inventory of {_user}
- set slot loop-value of {trading::temp::player::%player%::inventory} to air
- if slot loop-value of {trading::temp::player::%{_user}%::inventory} is not air:
- add slot loop-value of {trading::temp::player::%{_user}%::inventory} to inventory of player
- set slot loop-value of {trading::temp::player::%{_user}%::inventory} to air
- delete {trading::temp::player::%player%::*}
- delete {trading::temp::player::%{_user}%::*}
- message "{@prefix}{@complete}" to player and {_user}
- play sound "ENTITY_PLAYER_LEVELUP" with volume 1 with pitch 1 at player's location for player
- play sound "ENTITY_PLAYER_LEVELUP" with volume 1 with pitch 1 at {_user}'s location for {_user}
- close inventory of player and {_user}
- else:
- #Gives back the item they have added to the trade.
- loop {trading::temp::slots::*}:
- loop-value is clicked slot
- slot loop-value of current inventory is not air
- add slot loop-value of current inventory to player's inventory
- set slot loop-value of current inventory to air
- set slot loop-value + 5 of {trading::temp::player::%{_user}%::inventory} to air
- play sound "ENTITY_EXPERIENCE_ORB_PICKUP" with volume 1 with pitch 1 at player's location for player
- stop
- else:
- #Add item to the trade.
- slot clicked slot of clicked inventory is not air
- loop {trading::temp::slots::*}:
- if slot loop-value of current inventory is air:
- set slot loop-value of current inventory to event-item
- set slot loop-value + 5 of {trading::temp::player::%{_user}%::inventory} to event-item
- play sound "ENTITY_EXPERIENCE_ORB_PICKUP" with volume 1 with pitch 4 at player's location for player
- set slot clicked slot of clicked inventory to air
- if {trading::temp::player::%player%::state} is not 0:
- set {trading::temp::player::%{_user}%::state} and {trading::temp::player::%player%::state} to 0
- set slots integers between 45 and 48 of {trading::temp::player::%player%::inventory} to {@state0}
- set slots integers between 50 and 53 of {trading::temp::player::%player%::inventory} to {@otherstate0}
- set slots integers between 45 and 48 of {trading::temp::player::%{_user}%::inventory} to {@state0}
- set slots integers between 50 and 53 of {trading::temp::player::%{_user}%::inventory} to {@otherstate0}
- set slot 48 of {trading::temp::player::%player%::inventory} to {@cancel}
- set slot 48 of {trading::temp::player::%{_user}%::inventory} to {@cancel}
- stop
- message "{@prefix}{@max-slots}"
Add Comment
Please, Sign In to add comment