Untitled
raw download clone
TEXT
views 30
,
size 16654 b
on script load:
	add 10 to {tradingslots::*}
	add 11 to {tradingslots::*}
	add 12 to {tradingslots::*}
	add 19 to {tradingslots::*}
	add 20 to {tradingslots::*}
	add 21 to {tradingslots::*}
command /trade [<text>] [<player>]:
	trigger:
		if arg-1 is not set:
			send " " to player
			send "&b---------------" to player
			send "&6Use &c/trade (accept/deny) (player) &6to accept or deny a player's trade request" to player
			send "&6Use &c/trade invite (player) &6to send a player a trade request" to player
			send "&b---------------" to player
			send " " to player
		else:
			if arg-1 = "help":
				send " " to player
				send "&b---------------" to player
				send "&6Use &c/trade (accept/deny) (player) &6to accept or deny a player's trade request" to player
				send "&6Use &c/trade invite (player) &6to send a player a trade request" to player
				send "&b---------------" to player
				send " " to player
			if arg-1 = "invite":
				if arg-2 is set:
					if arg-2  = player:
						send "&6You can't invite yourself to trade!" to player
					else:
						if {tradereq::%uuid of arg-2%::*} does not contain player's uuid:
							if {tradereq::%uuid of player%::*} does not contain uuid of arg-2:
								send "&c%arg-2% &6has been invited to trade" to player
								send "&c%player% &6has invited you to trade" to arg-2
								send "&6Use &c/trade accept %player% &6 to accept" to arg-2
								add player's uuid to {tradereq::%uuid of arg-2%::*}
							else:
								send "&c%arg-2% &6has already invited you to trade!" to player
								send "&6Use &c/trade accept &c%arg-2% &6to accept their trade request" to player
						else:
							send "&6You have already invited &c%arg-2% &6to trade!" to player
				else:
					send " " to player
					send "&b---------------" to player
					send "&6Use &c/trade (accept/deny) (player) &6to accept or deny a player's trade request" to player
					send "&6Use &c/trade invite (player) &6to send a player a trade request" to player
					send "&b---------------" to player
					send " " to player
			if arg-1 = "accept":
				if arg-2 is not set:
					send " " to player
					send "&b---------------" to player
					send "&6Use &c/trade (accept/deny) (player) &6to accept or deny a player's trade request" to player
					send "&6Use &c/trade invite (player) &6to send a player a trade request" to player
					send "&b---------------" to player
					send " " to player
				else:
					if {tradereq::%uuid of player%::*} contains uuid of arg-2:
						send "&6Accepted &c%arg-2%&c's &6trade request" to player
						send "&c%player% &6has accepted your trade invite!" to arg-2
						remove uuid of arg-2 from {tradereq::%uuid of player%::*}
						trading(player, arg-2)
						set {trading::%uuid of player%} to "p1"
						set {trading::%uuid of arg-2%} to "p2"
						set {tradingw::%uuid of player%} to arg-2
						set {tradingw::%uuid of arg-2%} to player
					else:
						send "&c%arg-2% &6hasn't invited you to trade!"
			if arg-1 = "deny":
				if arg-2 is not set:
					send " " to player
					send "&b---------------" to player
					send "&6Use &c/trade (accept/deny) (player) &6to accept or deny a player's trade request" to player
					send "&6Use &c/trade invite (player) &6to send a player a trade request" to player
					send "&b---------------" to player
					send " " to player
				else:
					if {tradereq::%uuid of player%::*} contains uuid of arg-2:
						send "&6Denied &c%arg-2%&c's &6trade request" to player
						send "&c%player% &6has denied your trade invite!" to arg-2
						remove uuid of arg-2 from {tradereq::%uuid of player%::*}
					else:
						send "&c%arg-2% &6hasn't invited you to trade!"
on inventory click:
	if {trading::%uuid of player%} = "p1":
		if {tradingslots::*} contains event-slot:
			set {_eventslot} to event-slot
			updateP2(player, {tradingw::%uuid of player%}, {_eventslot})
			updateP1(player, {tradingw::%uuid of player%}, {_eventslot})
			format gui slot 39 of player with gray dye named "&7&lAccept trade with %{tradingw::%uuid of player%}%" to run function acceptTradeP1(player, {tradingw::%uuid of player%})
			format gui slot 41 of {tradingw::%uuid of player%} with gray dye named "&7&l%player% &7&lhas not accepted yet"
			format gui slot 39 of {tradingw::%uuid of player%} with gray dye named "&7&lAccept trade with %player%" to run function acceptTradeP2(player, {tradingw::%uuid of player%})
			format gui slot 41 of player with gray dye named "&7&l%{tradingw::%uuid of player%}% &7&lhas not accepted yet"
#			if {accepted::%uuid of player%} = true:
	else if {trading::%uuid of player%} = "p2":
		if {tradingslots::*} contains event-slot:
			set {_eventslot} to event-slot
			updateP2({tradingw::%uuid of player%}, player, {_eventslot})
			updateP1({tradingw::%uuid of player%}, player, {_eventslot})
			format gui slot 39 of player with gray dye named "&7&lAccept trade with %{tradingw::%uuid of player%}%" to run function acceptTradeP2({tradingw::%uuid of player%}, player)
			format gui slot 41 of {tradingw::%uuid of player%} with gray dye named "&7&l%player% &7&lhas not accepted yet"
			format gui slot 39 of {tradingw::%uuid of player%} with gray dye named "&7&lAccept trade with %player%" to run function acceptTradeP1({tradingw::%uuid of player%}, player)
			format gui slot 41 of player with gray dye named "&7&l%{tradingw::%{_up1}%}% &7&lhas not accepted yet"
#			if {accepted::%uuid of player%} = true:
on inventory close:
	if {trading::%uuid of player%} = "p1":
		tradeClosed(player, {tradingw::%uuid of player%})
	else:
		if {trading::%uuid of player%} = "p2":
			tradeClosed({tradingw::%uuid of player%}, player)
#function onInventoryClose(p1: player, p2: player):
	#notin yet
	#set {_up1} to uuid of {_p1}
	#set {_tp1} to {trading::%{_up1}%}
	#set {tradingw::%{_up1}%} to {_p2}
	#set {_up2} to uuid of {_p2}
	#set {_tp2} to {trading::%{_up2}%}
		#set {tradingw::%{_up2}%} to {_p1}
		#send "&6Your trade with &c%{_p2}% &6has ended!" to {_p1}
		#send "&6Your trade with &c%{_p1}% &6has ended!" to {_p2}
		#clear {_tp1}
		#clear {tradingw::%{_up1}%}
	#clear {_tp2}
	#clear {tradingw::%{_up2}%}
		#close {_p1}'s inventory
		#close {_p2}'s inventory
function trading(p1: player, p2: player):
	send "&6Loading trade screen" to {_p1}
	send "&6Trade screen loading" to {_p2}
	close {_p1}'s inventory
	close {_p2}'s inventory
	open virtual chest inventory with size 5 named "Trade with %{_p2}%" to {_p1}
	open virtual chest inventory with size 5 named "Trade with %{_p1}%" to {_p2}
	set {_up1} to uuid of {_p1}
	set {_tp1} to {trading::%{_up1}%}
	#clear {_tp1}
	#set {_tp1} to "p1"
	set {tradingw::%{_up1}%} to {_p2}
	set {_up2} to uuid of {_p2}
	set {_tp2} to {trading::%{_up2}%}
	#clear {_tp2}
	#set {_tp2} to "p2"
	set {tradingw::%{_up2}%} to {_p1}
	set {trading::%{_up1}%} to "p1"
	set {trading::%{_up2}%} to "p2"
	set {accepted::%{_up1}%} to false
	set {accepted::%{_up2}%} to false
	format gui slot integers between 14 and 16 of {_p1} and {_p2} with light gray stained glass pane named " "
	format gui slot integers between 23 and 25 of {_p1} and {_p2} with light gray stained glass pane named " "
	format gui slot integers between 0 and 8 of {_p1} and {_p2} with black stained glass pane named " "
	format gui slot 9,13, and 17 of {_p1} and {_p2} with black stained glass pane named " "
	format gui slot 18,22, and 26 of {_p1} and {_p2} with black stained glass pane named " "
	format gui slot integers between 27 and 44 of {_p1} and {_p2} with black stained glass pane named " "
	acceptDenyTrade({_p1}, {_p2})
	#while {trading::%{_up2}%} = "p2":
		#set {_p2t1} to slot 10 of {_p2}
		#format gui slot 14 of {_p1} with {_p2t1}
		#wait 1 second
function acceptDenyTrade(p1: player, p2: player):
	set {_up1} to uuid of {_p1}
	set {_up2} to uuid of {_p2}
	format gui slot 41 of {_p1} with gray dye named "&7&l%{tradingw::%{_up1}%}% &7&lhas not accepted yet"
	format gui slot 39 of {_p1} with gray dye named "&7&lAccept trade with %{tradingw::%{_up1}%}%" to run function acceptTradeP1({_p1}, {_p2})
	format gui slot 41 of {_p2} with gray dye named "&7&l%{tradingw::%{_up2}%}% &7&lhas not accepted yet"
	format gui slot 39 of {_p2} with gray dye named "&7&lAccept trade with %{tradingw::%{_up2}%}%" to run function acceptTradeP2({_p1}, {_p2})
	format gui slot 44 of {_p1} and {_p2} with red stained glass pane named "&c&lCancel trade" to run:
		tradeClosed({_p1}, {_p2})
		#give
		#give
		#give
		#give
		#give
		#give
		#give
		#give
		#give
		#give
		#give
		#give
function acceptTradeP1(p1: player, p2: player):
	set {_up1} to uuid of {_p1}
	set {_up2} to uuid of {_p2}
	send "%{accepted::%{_up1}%}%" to {_p1}
	if {accepted::%{_up1}%} = false:
		format gui slot 39 of {_p1} with lime dye named "&7&lAccepted trade with %{tradingw::%{_up1}%}%" to run function acceptTradeP1({_p1}, {_p2})
		format gui slot 41 of {_p2} with lime dye named "&7&l%{tradingw::%{_up2}%}% &7&lhas accepted!"
		set {accepted::%{_up1}%} to true
		if {accepted::%{_up2}%} = true:
			tradeAccepted({_p1}, {_p2})
	else if {accepted::%{_up1}%} = true:
		format gui slot 39 of {_p1} with gray dye named "&7&lAccept trade with %{tradingw::%{_up2}%}%" to run function acceptTradeP1({_p1}, {_p2})
		format gui slot 41 of {_p2} with gray dye named "&7&l%{tradingw::%{_up2}%}% &7&lhas not accepted yet"
		set {accepted::%{_up1}%} to false
function acceptTradeP2(p1: player, p2: player):
	set {_up1} to uuid of {_p1}
	set {_up2} to uuid of {_p2}
	send "%{accepted::%{_up2}%}%" to {_p2}
	if {accepted::%{_up2}%} = false:
		format gui slot 39 of {_p2} with lime dye named "&7&lAccepted trade with %{tradingw::%{_up2}%}%" to run function acceptTradeP2({_p1}, {_p2})
		format gui slot 41 of {_p1} with lime dye named "&7&l%{tradingw::%{_up1}%}% &7&lhas accepted!"
		set {accepted::%{_up2}%} to true
		if {accepted::%{_up1}%} = true:
			tradeAccepted({_p1}, {_p2})
	else if {accepted::%{_up2}%} = true:
		format gui slot 39 of {_p2} with gray dye named "&7&lAccept trade with %{tradingw::%{_up2}%}%" to run function acceptTradeP2({_p1}, {_p2})
		format gui slot 41 of {_p1} with gray dye named "&7&l%{tradingw::%{_up1}%}% &7&lhas not accepted yet"
		set {accepted::%{_up2}%} to false
function tradeClosed(p1: player, p2: player):
	set {_up1} to uuid of {_p1}
	set {_up2} to uuid of {_p2}
	if {trading::%{_up1}%} = "p1":
		if {trading::%{_up2}%} = "p2":
			set {_tw2} to uuid of {tradingw::%{_up2}%}
			clear {trading::%{_up2}%}
			clear {trading::%{_tw2}%}
			wait 1 tick
			close {_p2}'s inventory
			close {_p1}'s inventory
			loop {getback::%{_up1}%::*}:
				give {_p1} loop-value
			loop {getback::%{_up2}%::*}:
				give {_p2} loop-value
			delete {getback::%{_up1}%::*}
			delete {getback::%{_up2}%::*}
			send "&6Your trade with &c%{tradingw::%{_up2}%}% &6has ended!" to {_p2}
			send "&6Your trade with &c%{_p2}% &6has ended!" to {tradingw::%{_up2}%}
			#set {_tw1} to uuid of {tradingw::%{_up1}%}
			clear {trading::%{_up1}%}
			clear {trading::%{_tw1}%}
function updateP2(p1: player, p2: player, ev: number):
	#send "P1 has change their trade" to {_p2}
	updateTrade({_p1}, {_p2})
	set {_up1} to uuid of {_p1}
	set {_up2} to uuid of {_p2}
	set {accepted::%{_up1}%} to false
	set {accepted::%{_up2}%} to false
	format gui slot 39 of {_p1} with gray dye named "&7&lAccept trade with %{tradingw::%{_up1}%}%" to run function acceptTradeP1({_p1}, {_p2})
	format gui slot 41 of {_p2} with gray dye named "&7&l%{tradingw::%{_up2}%}% &7&lhas not accepted yet"
	format gui slot 39 of {_p2} with gray dye named "&7&lAccept trade with %{tradingw::%{_up2}%}%" to run function acceptTradeP2({_p1}, {_p2})
	format gui slot 41 of {_p1} with gray dye named "&7&l%{tradingw::%{_up1}%}% &7&lhas not accepted yet"
	updateTrade({_p1}, {_p2})
function updateP1(p1: player, p2: player, ev: number):
	#send "P2 has change their trade" to {_p1}
	updateTrade({_p1}, {_p2})
	set {_up1} to uuid of {_p1}
	set {_up2} to uuid of {_p2}
	set {accepted::%{_up1}%} to false
	set {accepted::%{_up2}%} to false
	format gui slot 39 of {_p1} with gray dye named "&7&lAccept trade with %{tradingw::%{_up1}%}%" to run function acceptTradeP1({_p1}, {_p2})
	format gui slot 41 of {_p2} with gray dye named "&7&l%{tradingw::%{_up2}%}% &7&lhas not accepted yet"
	format gui slot 39 of {_p2} with gray dye named "&7&lAccept trade with %{tradingw::%{_up2}%}%" to run function acceptTradeP2({_p1}, {_p2})
	format gui slot 41 of {_p1} with gray dye named "&7&l%{tradingw::%{_up1}%}% &7&lhas not accepted yet"
	updateTrade({_p1}, {_p2})
function updateTrade(p1: player, p2: player):
	set {_up1} to uuid of {_p1}
	set {_up2} to uuid of {_p2}
	set {_p1t1} to slot 10 of {_p1}'s current inventory
	format gui slot 14 of {_p2} with {_p1t1}
	set {_p2t1} to slot 10 of {_p2}'s current inventory
	format gui slot 14 of {_p1} with {_p2t1}
	set {_p1t2} to slot 11 of {_p1}'s current inventory
	format gui slot 15 of {_p2} with {_p1t2}
	set {_p2t2} to slot 11 of {_p2}'s current inventory
	format gui slot 15 of {_p1} with {_p2t2}
	set {_p1t3} to slot 12 of {_p1}'s current inventory
	format gui slot 16 of {_p2} with {_p1t3}
	set {_p2t3} to slot 12 of {_p2}'s current inventory
	format gui slot 16 of {_p1} with {_p2t3}
	set {_p1t4} to slot 19 of {_p1}'s current inventory
	format gui slot 23 of {_p2} with {_p1t4}
	set {_p2t4} to slot 19 of {_p2}'s current inventory
	format gui slot 23 of {_p1} with {_p2t4}
	set {_p1t5} to slot 20 of {_p1}'s current inventory
	format gui slot 24 of {_p2} with {_p1t5}
	set {_p2t5} to slot 20 of {_p2}'s current inventory
	format gui slot 24 of {_p1} with {_p2t5}
	set {_p1t6} to slot 21 of {_p1}'s current inventory
	format gui slot 25 of {_p2} with {_p1t6}
	set {_p2t6} to slot 21 of {_p2}'s current inventory
	format gui slot 25 of {_p1} with {_p2t6}
	clear {getback::%{_up1}%::*}
	clear {getback::%{_up2}%::*}
	add {_p1t1} to {getback::%{_up1}%::*}
	add {_p1t2} to {getback::%{_up1}%::*}
	add {_p1t3} to {getback::%{_up1}%::*}
	add {_p1t4} to {getback::%{_up1}%::*}
	add {_p1t5} to {getback::%{_up1}%::*}
	add {_p1t6} to {getback::%{_up1}%::*}
	add {_p2t1} to {getback::%{_up2}%::*}
	add {_p2t2} to {getback::%{_up2}%::*}
	add {_p2t3} to {getback::%{_up2}%::*}
	add {_p2t4} to {getback::%{_up2}%::*}
	add {_p2t5} to {getback::%{_up2}%::*}
	add {_p2t6} to {getback::%{_up2}%::*}
	set {accepted::%{_up1}%} to false
	set {accepted::%{_up2}%} to false
	format gui slot 39 of {_p1} with gray dye named "&7&lAccept trade with %{tradingw::%{_up1}%}%" to run function acceptTradeP1({_p1}, {_p2})
	format gui slot 41 of {_p2} with gray dye named "&7&l%{tradingw::%{_up2}%}% &7&lhas not accepted yet"
	format gui slot 39 of {_p2} with gray dye named "&7&lAccept trade with %{tradingw::%{_up2}%}%" to run function acceptTradeP2({_p1}, {_p2})
	format gui slot 41 of {_p1} with gray dye named "&7&l%{tradingw::%{_up1}%}% &7&lhas not accepted yet"
#	updateP1({_p1}, {_p2})
#	updateP2({_p1}, {_p2})
#	if {accepted::%{_up1}%} = true:
#		set {accepted::%{_up1}%} to false
#		format gui slot 39 of {_p1} with gray dye named "&7&lAccept trade with %{tradingw::%{_up1}%}%" to run function acceptTradeP1({_p1}, {_p2})
#		format gui slot 41 of {_p2} with gray dye named "&7&l%{tradingw::%{_up2}%}% &7&lhas not accepted yet"
#		if {accepted::%{_up2}%} = false:
#			format gui slot 41 of {_p1} with gray dye named "&7&l%{tradingw::%{_up1}%}% &7&lhas not accepted yet"
#		else if {accepted::%{_up2}%} = true:
#			tradeAccepted({_p1}, {_p2}) 
#	if {accepted::%{_up2}%} = true:
#		set {accepted::%{_up2}%} to false
#		format gui slot 39 of {_p2} with gray dye named "&7&lAccept trade with %{tradingw::%{_up2}%}%" to run function acceptTradeP2({_p1}, {_p2})
#		format gui slot 41 of {_p1} with gray dye named "&7&l%{tradingw::%{_up1}%}% &7&lhas not accepted yet"
#		if {accepted::%{_up1}%} = false:
#			format gui slot 41 of {_p2} with gray dye named "&7&l%{tradingw::%{_up2}%}% &7&lhas not accepted yet"
#		else if {accepted::%{_up1}%} = true:
#			tradeAccepted({_p1}, {_p2})
function tradeAccepted(p1: player, p2: player):
	set {_up1} to uuid of {_p1}
	set {_up2} to uuid of {_p2}
	send "Trade A" to {_p1} and {_p2}
	loop {getback::%{_up2}%::*}:
		give {_p1} loop-value
	loop {getback::%{_up1}%::*}:
		give {_p2} loop-value
	delete {giveback::%{_up1}%::*}
	delete {giveback::%{_up2}%::*}
	clear {trading::%{_up1}%}
	clear {trading::%{_up2}%}
	close {_p1}'s inventory
	close {_p2}'s inventory
close fullscreen
Login or Register to edit or fork this paste. It's free.