Warning: Undefined variable $http_response_header in /var/www/html/new/skunity/library/skUnity/Util/HTTP.php on line 95

UE_Economy.sk

Created by Unknown

Just so you know, we don't know the file format for every file. If it's just a bunch of random characters, it's probably a .zip or .jar.


every 1 second:
	loop all players:
		balcheck(loop-player)
		
function balcheck(p: Player):
	if {balance.list::%{_p}%} is not set:
		set {_p}'s balance to {ue.config::economy.starting-balance}
		set {_value} to "%{_p}'s balance%"
		replace all " Dollars" with "" in {_value}
		replace all " Dollar" with "" in {_value}
		replace all "," with "" in {_value}
		set {_value} to {_value} parsed as a number
		set {balance.list::%{_p}%} to {_value}
	if {_p}'s balance is not {balance.list::%{_p}%}:
		set {_value} to "%{_p}'s balance%"
		replace all " Dollars" with "" in {_value}
		replace all " Dollar" with "" in {_value}
		replace all "," with "" in {_value}
		set {_value} to {_value} parsed as a number
		set {balance.list::%{_p}%} to {_value}

function baljoinleave(p: Player):
	if {balance.list::%{_p}%} is not set:
		set {_p}'s balance to {ue.config::economy.starting-balance}
		set {_value} to "%{_p}'s balance%"
		replace all " Dollars" with "" in {_value}
		replace all " Dollar" with "" in {_value}
		replace all "," with "" in {_value}
		set {_value} to {_value} parsed as a number
		set {balance.list::%{_p}%} to {_value}
	if {_p}'s balance is not {balance.list::%{_p}%}:
		set {_p}'s balance to {balance.list::%{_p}%}

on join:
	baljoinleave(player)

on quit:
	baljoinleave(player)

function baltop(p: Player, page: Number):
	set {_ballist::*} to {balance.list::*}
	set {_pnum} to 1
	while (size of {_ballist::*}) > 0:
		delete {_high}
		loop {_ballist::*}:
			wait 0.1 tick
			if {_high} is not set:
				set {_high} to loop-value
			else if loop-value > {_high}:
				set {_high} to loop-value
		add {_high} to {_balsort::*}
		loop {_ballist::*}:
			wait 0.1 tick
			if {_high} = loop-value:
				remove loop-value from {_ballist::*}
	set {_posNum} to 1
	loop {_balsort::*}:
		loop {allplayer.list::*}:
			if loop-value-1 = {balance.list::%loop-value-2%}:
				set {_name} to loop-value-2
				set {_val} to loop-value-1
				set {_valround} to rounded {_val}
				if {balance.list::%loop-value-2%} is set:
					set {_baltop-with-zero} to {ue.msg::baltop.position-with-zero}
					set {_baltop-without-zero} to {ue.msg::baltop.position-without-zero}
					replace all "{position}" in {_baltop-with-zero} with "%{_posNum}%"
					replace all "{player}" in {_baltop-with-zero} with "%{_name}%"
					set {_v} to regex replace "(?<=\d)(?=(\d{3})+(?!\d))" with "," in "%{_val}%"
					replace all "{balance}" in {_baltop-with-zero} with "%{_v}%"
					replace all "{position}" in {_baltop-without-zero} with "%{_posNum}%"
					replace all "{player}" in {_baltop-without-zero} with "%{_name}%"
					replace all "{balance}" in {_baltop-without-zero} with "%{_v}%"
					if {_val}/{_valround} = 1:
						set {_msg} to "%{_baltop-with-zero}%"
					else: 
						set {_msg} to "%{_baltop-without-zero}%"
					add 1 to {_posNum} 
					if size of {_baltop.%{_pnum}%::*} < 9:
						add {_msg} to {_baltop.%{_pnum}%::*}
					else if size of {_baltop.%{_pnum}%::*} = 9:
						add {_msg} to {_baltop.%{_pnum}%::*}
						add 1 to {_pnum}
	if {_baltop.%{_page}%::*} is not set:
		message "%{ue.msg::1-important.prefix}% %{ue.msg::baltop.page-not-exist}%" to {_p}
		stop
	set {_baltop-banner} to {ue.msg::baltop.banner}
	replace all "{arg-1}" in {_baltop-banner} with "%{_page}%"
	message "%{_baltop-banner}%" to {_p}
	loop {_baltop.%{_page}%::*}:
		#set {_l} to loop-value parsed as text
		message "%loop-value%" to {_p}
		#regex replace "(?<=\d)(?=(\d{3})+(?!\d))" with "," in {_l}
		#message "%{_l}%" to {_p}

function ecoMenu(p: Player):
	message "&7&m-----&8[&9&lEco Commands&8]&7&m-----" to {_p}	
	message "&3/eco give <player> <amount>" to {_p}
	message "&3/eco take <player> <amount>" to {_p}
	message "&3/eco set <player> <amount>" to {_p}
	message "&3/eco reset <player>" to {_p}
	message "&7&m------------------------" to {_p}

function econNeverOnline(p: Player, offline: OfflinePlayer):
	set {_economy-never-been-online} to {ue.msg::economy.never-been-online}
	replace all "{arg-1}" in {_economy-never-been-online} with "%{_offline}%"
	message "%{ue.msg::1-important.prefix}% %{_economy-never-been-online}%" to {_p}

function balance(p: OfflinePlayer) :: String:
	set {_val} to {balance.list::%{_p}%}
	set {_valround} to rounded {_val}
	if {_val}/{_valround} = 1:
		set {_bal-with-zero} to {ue.msg::balance.bal-with-zero}
		replace all "{arg-1}" in {_bal-with-zero} with "%{_p}%"
		replace all "{balance}" in {_bal-with-zero} with "%{balance.list::%{_p}%}%"
		set {_msg} to "%{ue.msg::1-important.prefix}% %{_bal-with-zero}%"
		return {_msg}
	else: 
		set {_bal-without-zero} to {ue.msg::balance.bal-without-zero}
		replace all "{arg-1}" in {_bal-without-zero} with "%{_p}%"
		replace all "{balance}" in {_bal-without-zero} with "%{balance.list::%{_p}%}%"
		set {_msg} to "%{ue.msg::1-important.prefix}% %{_bal-without-zero}%"
		return {_msg}

command /balance [<offlineplayer=%player%>]:
	aliases: /bal, /money
	description: Check the balance of a player
	permission message: &3&lUE&8&l» &cYou do not have permission to use this command
	permission: ue.economy.balance
	usage: /balance <player>
	trigger:
		if arg 1 = player:
			if player doesn't have permission "ue.economy.balance":
				message "&3&lUE&8&l» &cYou do not have permission to use this command"
				stop
		else if player doesn't have permission "ue.economy.balance.others":
			message "&3&lUE&8&l» &cYou do not have permission to use this command"
			stop
		if {balance.list::%arg 1%} is set:
			message "%balance(arg 1)%"
		else:
			econNeverOnline(player, arg 1)

command /baltop [<integer=1>]:
	aliases: /balancetop
	permission: ue.economy.baltop
	permission message: &3&lUE&8&l» &cYou do not have permission to use this command
	description: Check top balances on the server
	usage: /baltop <page number>
	trigger:
		baltop(player, arg 1)

command /pay [<offlineplayer>] [<number>]:
	usage: /pay <player> <amount>
	permission: ue.economy.pay
	permission message: &3&lUE&8&l» &cYou do not have permission to use this command
	description: Pay money to other players
	trigger:
		if arg 1 is set:
			if arg 2 is set:
				if {balance.list::%arg 1%} doesn't exist:
					econNeverOnline(player, arg 1)
					stop
				if arg 1 is online:
					if player's balance > arg 2:
						remove arg 2 from {balance.list::%player%}
						add arg 2 to {balance.list::%arg 1%}
						set arg 1's balance to {balance.list::%arg 1%}
						set player's balance to {balance.list::%player%}
						set {_pay-to-sender} to {ue.msg::pay.success-to-sender}
						set {_pay-to-receiver} to {ue.msg::pay.success-to-receiver}
						replace all "{arg-1}" in {_pay-to-sender} with "%arg 1%"
						replace all "{arg-2}" in {_pay-to-sender} with "%arg 2%"
						replace all "{player}" in {_pay-to-receiver} with "%player%"
						replace all "{arg-2}" in {_pay-to-receiver} with "%arg 2%"
						message "%{ue.msg::1-important.prefix}% %{_pay-to-sender}%" to player
						message "%{ue.msg::1-important.prefix}% %{_pay-to-receiver}%" to arg 1
					else:
						message "%{ue.msg::1-important.prefix}% %{ue.msg::economy.insufficient-funds}%"
				else:
					remove arg 2 from player's balance
					add arg 2 to {balance.list::%arg 1%}
					set {_pay-to-sender} to {ue.msg::pay.success-to-sender}
					replace all "{arg-1}" in {_pay-to-sender} with "%arg 1%"
					replace all "{arg-2}" in {_pay-to-sender} with "%arg 2%"
					message "%{ue.msg::1-important.prefix}% %{_pay-to-sender}%" to player
			else:
				message "%{ue.msg::1-important.prefix}% %{ue.msg::pay.proper-usage}%"
		else:
			message "%{ue.msg::1-important.prefix}% %{ue.msg::pay.proper-usage}%"

command /eco [<text>] [<offlineplayer>] [<number>]:
	aliases: /economy
	executable by: players and console
	description: Several Economy Functions
	usage: /eco <give/take/set/clear> <player> <amount>
	trigger:
		if arg 1 is not set:
			ecoMenu(player)
			stop
		if arg 1 is "give" or "add" or "take" or "remove" or "set":
			if arg 2 is not set:
				if arg 3 is not set:
					ecoMenu(player)
					stop
		if arg 1 is "clear" or "reset":
			if arg 2 is not set:
				ecoMenu(player)
				stop
		if arg 1 is "give" or "add":
			if sender has permission "ue.economy.give":
				if arg 2 is set:
					if arg 3 is set:
						if {balance.list::%arg 2%} is set:
							add arg 3 to {balance.list::%arg 2%}
							if {balance.list::%arg 2%} < 0:
								set {balance.list::%arg 2%} to 0
							if arg 2 is not player:
								set {_give-success-to-sender} to {ue.msg::eco.add.success-to-sender}
								replace all "{arg-3}" in {_give-success-to-sender} with "%arg 3%"
								replace all "{arg-2}" in {_give-success-to-sender} with "%arg 2%"
								message "%{ue.msg::1-important.prefix}% %{_give-success-to-sender}%" to player
							if arg 2 is online:
								set {_give-success-to-receiver} to {ue.msg::eco.add.success-to-receiver}
								replace all "{arg-3}" in {_give-success-to-receiver} with "%arg 3%"
								message "%{ue.msg::1-important.prefix}% %{_give-success-to-receiver}%" to arg 2
								set arg 2's balance to {balance.list::%arg 2%}
						else:
							if sender is a player:
								econNeverOnline(player, arg 2)
						stop
			else:
				message "&3&lUE&8&l» &cYou do not have permission to use this command"
				stop

		if arg 1 is "take" or "remove":
			if sender has permission "ue.economy.take":
				if arg 2 is set:
					if arg 3 is set:
						if {balance.list::%arg 2%} is set:
							subtract arg 3 from {balance.list::%arg 2%}
							if {balance.list::%arg 2%} < 0:
								set {balance.list::%arg 2%} to 0
								set {_remove-success-to-sender} to {ue.msg::eco.remove.success-to-sender}
								replace all "{arg-3}" in {_remove-success-to-sender} with "%arg 3%"
								replace all "{arg-2}" in {_remove-success-to-sender} with "%arg 2%"
								message "%{ue.msg::1-important.prefix}% %{_remove-success-to-sender}%" to player
							if arg 2 is online:
								set {_remove-success-to-receiver} to {ue.msg::eco.remove.success-to-receiver}
								replace all "{arg-3}" in {_remove-success-to-receiver} with "%arg 3%"
								message "%{ue.msg::1-important.prefix}% %{_remove-success-to-receiver}%" to arg 2
								set arg 2's balance to {balance.list::%arg 2%}
						else:
							if sender is a player:
								econNeverOnline(player, arg 2)
						stop
			else:
				message "&3&lUE&8&l» &cYou do not have permission to use this command"
				stop

		if arg 1 is "set":
			if sender has permission "ue.economy.set":
				if arg 2 is set:
					if arg 3 is set:
						if {balance.list::%arg 2%} is set:
							set {balance.list::%arg 2%} to arg 3
							if {balance.list::%arg 2%} < 0:
								set {balance.list::%arg 2%} to 0
							if arg 2 is not player:
								set {_eco-set-success-to-sender} to {ue.msg::eco.set.success-to-sender}
								replace all "{arg-2}" in {_eco-set-success-to-sender} with "%arg 2%"
								replace all "{balance}" in {_eco-set-success-to-sender} with "%{balance.list::%arg 2%}%"
								message "%{ue.msg::1-important.prefix}% %{_eco-set-success-to-sender}%" to player
							if arg 2 is online:
								set {_eco-set-success-to-receiver} to {ue.msg::eco.set.success-to-receiver}
								replace all "{balance}" in {_eco-set-success-to-receiver} with "%{balance.list::%arg 2%}%"
								message "%{ue.msg::1-important.prefix}% %{_eco-set-success-to-receiver}%" to arg 2
								set arg 2's balance to {balance.list::%arg 2%}
						else:
							if sender is a player:
								econNeverOnline(player, arg 2)
						stop
			else:
				message "&3&lUE&8&l» &cYou do not have permission to use this command"
				stop

		if arg 1 is "clear" or "reset":
			if sender has permission "ue.economy.reset":
				if arg 2 is set:
					if {balance.list::%arg 2%} is set:
						set {balance.list::%arg 2%} to {ue.config::economy.starting-balance}
						if arg 2 is not player:
							set {_reset-success-to-sender} to {ue.msg::eco.reset.success-to-sender}
							replace all "{arg-2}" in {_reset-success-to-sender} with "%arg 2%"
							message "%{ue.msg::1-important.prefix}% %{_reset-success-to-sender}%" to player
						if arg 2 is online:
							set {_reset-success-to-receiver} to {ue.msg::eco.reset.success-to-receiver}
							replace all "{balance}" in {_reset-success-to-receiver} with "%{balance.list::%arg 2%}%"
							message "%{ue.msg::1-important.prefix}% %{_reset-success-to-receiver}%" to arg 2
							set arg 2's balance to {balance.list::%arg 2%}
					else:
						if sender is a player:
							econNeverOnline(player, arg 2)
					stop
			else:
				message "&3&lUE&8&l» &cYou do not have permission to use this command"
				stop

		else:
			ecoMenu(player)

#Signs

on sign change:
	if line 1 is "[UE]":
		if line 2 is "Sell":
			if player doesn't have permission "ue.signs.create.sell":
				message "%{ue.msg::1-important.no-permission-message}%"
			else:
				set line 1 to "&8[&3UE&8]"
				set line 2 to "&8Right-Click to"
				set line 3 to "&9&lSell Items"
		if line 2 is "Sellall":
			if player doesn't have permission "ue.signs.create.sellall":
				message "%{ue.msg::1-important.no-permission-message}%"
			else:
				set line 1 to "&8[&3UE&8]"
				set line 2 to "&8Right-Click to"
				set line 3 to "&9&lSell All"
	if player has permission "ue.economy.create.buy":
		if line 1 is "[Buy]":
			if line 2 is set:
				if line 3 is set:
					if line 4 is set:
						set {_quantity} to "%uncolored line 2%" parsed as a number
						set {_item} to "%uncolored line 3%"
						set {_price} to "%uncolored line 4%"
						replace all "$" in {_price} with ""
						if {_quantity} is not set:
							set line 1 to "&c[&4ERROR&c]"
							set line 2 to "&cPlease Use a"
							set line 3 to "&cValid Number"
							set line 4 to "&cfor line 2"
							stop
						if {_price} parsed as a number is not set:
							set line 1 to "&c[&4ERROR&c]"
							set line 2 to "&cPlease Use a"
							set line 3 to "&cValid Number"
							set line 4 to "&cfor line 4"
							stop
						set line 1 to "&3---&9[Buy]&3---"
						set line 2 to "&0&l%{_quantity}%"
						set line 3 to "&0&l%{_item}%"
						set {_priceround} to rounded {_price}
						if {_price}/{_priceround} = 1:
							set line 4 to "&0&l$%{_price}%.00"
						else:
							set line 4 to "&0&l$%{_price}%"
	else:
		message "&3&lUE&8&l» &cYou do not have permission to use this command"
		stop
	if player has permission "ue.economy.create.sell":
		if line 1 is "[Sell]":
			if line 2 is set:
				if line 3 is set:
					if line 4 is set:
						set {_quantity} to "%line 2%" parsed as a number
						set {_item} to "%line 3%"
						set {_price} to "%line 4%"
						replace all "$" in {_price} with ""
						if {_quantity} is not set:
							set line 1 to "&c[&4ERROR&c]"
							set line 2 to "&cPlease Use a"
							set line 3 to "&cValid Number"
							set line 4 to "&cfor line 2"
							stop
						if {_price} parsed as a number is not set:
							set line 1 to "&c[&4ERROR&c]"
							set line 2 to "&cPlease Use a"
							set line 3 to "&cValid Number"
							set line 4 to "&cfor line 4"
							stop
						set line 1 to "&3---&9[Sell]&3---"
						set line 2 to "&0&l%{_quantity}%"
						set line 3 to "&0&l%{_item}%"
						set {_priceround} to rounded {_price}
						if {_price}/{_priceround} = 1:
							set line 4 to "&0&l$%{_price}%.00"
						else:
							set line 4 to "&0&l$%{_price}%"
	else:
		message "&3&lUE&8&l» &cYou do not have permission to use this command"
		stop
		

on rightclick on sign:
	if line 1 of clicked block is "&8[&3UE&8]":
		if line 3 of clicked block is "&9&lSell Items":
			if player doesn't have permission "ue.signs.click.sell":
				message "%{ue.msg::1-important.no-permission-message}%"
			else:
				make player execute "/sell" with perm "ue.economy.sell"
		if line 3 of clicked block is "&9&lSell All":
			if player doesn't have permission "ue.signs.click.sellall":
				message "%{ue.msg::1-important.no-permission-message}%"
			else:
				make player execute "/sellall" with perm "ue.economy.sellall"
	if line 1 of clicked block is "&3---&9[Buy]&3---":
		if player doesn't have permission "ue.economy.use.buy":
			message "&3&lUE&8&l» &cYou do not have permission to use this command"
			stop
		set {_quantity} to "%uncolored line 2 of clicked block%" parsed as a number
		set {_orgitem} to "%uncolored line 3 of clicked block%" parsed as an item
		set {_price} to "%uncolored line 4 of clicked block%"
		replace all "$" in {_price} with ""
		set {_price} to {_price} parsed as a number
		if player is sneaking:
			if {balance.list::%player%} >= {_price}/{_quantity}:
				set {_max} to rounded down {balance.list::%player%}/({_price}/{_quantity})
				set {_num} to {_max}
				loop {_max} times:
					set {_item} to "%{_num}% %{_orgitem}%" parsed as item
					if player can hold {_item}:
						give {_item} to player
						set {_sign-buy} to {ue.msg::signs.buy}
						replace all "{item}" in {_sign-buy} with "%{_num}% %{_orgitem}%"
						replace all "{price}" in {_sign-buy} with "%{_num}*({_price}/{_quantity})%"
						message "%{ue.msg::1-important.prefix}% %{_sign-buy}%"
						set {_val} to {_num}*{_price}/{_quantity}
						remove {_val} from {balance.list::%player%}
						set player's balance to {balance.list::%player%}
						stop
					subtract 1 from {_num}
				message "%{ue.msg::1-important.prefix}% %{ue.msg::economy.not-enough-space}%"
			else:
				message "%{ue.msg::1-important.prefix}% %{ue.msg::economy.insufficient-funds}%"
		else:
			set {_item} to "%{_quantity}% %{_orgitem}%" parsed as an item
			if player can hold {_item}:
				if {balance.list::%player%} >= {_price}:
					set {_item} to "%{_quantity}% %{_orgitem}%" parsed as an item
					give {_item} to player
					set {_sign-buy} to {ue.msg::signs.buy}
					replace all "{item}" in {_sign-buy} with "%{_quantity}% %{_orgitem}%"
					replace all "{price}" in {_sign-buy} with "%{_price}%"
					message "%{ue.msg::1-important.prefix}% %{_sign-buy}%"
					remove {_price} from {balance.list::%player%}
					set player's balance to {balance.list::%player%}
					stop

			if {balance.list::%player%} >= {_price}/{_quantity}:
				set {_max} to rounded down {balance.list::%player%}/({_price}/{_quantity})
				set {_num} to {_max}
				loop {_max} times:
					set {_item} to "%{_num}% %{_orgitem}%" parsed as an item
					if player can hold {_item}:
						remove {_num}*({_price}/{_quantity}) from {balance.list::%player%}
						set player's balance to {balance.list::%player%}
						give {_item} to player
						set {_sign-buy} to {ue.msg::signs.buy}
						replace all "{item}" in {_sign-buy} with "%{_item}%"
						replace all "{price}" in {_sign-buy} with "%{_num}*({_price}/{_quantity})%"
						message "%{ue.msg::1-important.prefix}% %{_sign-buy}%"
						stop
					subtract 1 from {_num}
				message "%{ue.msg::1-important.prefix}% %{ue.msg::economy.not-enough-space}%"
			else:
				message "%{ue.msg::1-important.prefix}% %{ue.msg::economy.insufficient-funds}%"

	if line 1 of clicked block is "&3---&9[Sell]&3---":
		if player doesn't have permission "ue.economy.use.sell":
			message "&3&lUE&8&l» &cYou do not have permission to use this command"
			stop
		set {_quantity} to "%uncolored line 2 of clicked block%" parsed as a number
		set {_orgitem} to "%uncolored line 3 of clicked block%" parsed as an item
		set {_price} to "%uncolored line 4 of clicked block%"
		replace all "$" in {_price} with ""
		set {_price} to {_price} parsed as a number
		if player is sneaking:
			if player has 1 of {_orgitem}:
				set {_max} to amount of {_orgitem} in player's inventory
				remove {_max} of {_orgitem} from player's inventory
				set {_sign-sell} to {ue.msg::signs.sell}
				replace all "{item}" in {_sign-sell} with "%{_max}% %{_orgitem}%"
				replace all "{price}" in {_sign-sell} with "%{_max}*({_price}/{_quantity})%"
				message "%{ue.msg::1-important.prefix}% %{_sign-sell}%"
				set {_val} to {_max}*{_price}/{_quantity}
				add {_val} to {balance.list::%player%}
				set player's balance to {balance.list::%player%}
			else:
				message "%{ue.msg::1-important.prefix}% %{ue.msg::economy.not-required-item}%"
		else:
			if player has {_quantity} of {_orgitem}:
				set {_item} to "%{_quantity}% %{_orgitem}%" parsed as an item
				remove {_item} from player's inventory
				set {_sign-sell} to {ue.msg::signs.sell}
				replace all "{item}" in {_sign-sell} with "%{_quantity}% %{_orgitem}%"
				replace all "{price}" in {_sign-sell} with "%{_price}%"
				message "%{ue.msg::1-important.prefix}% %{_sign-sell}%"
				add {_price} to {balance.list::%player%}
				set player's balance to {balance.list::%player%}
			else if player has 1 of {_orgitem}:
				set {_max} to amount of {_orgitem} in player's inventory
				add {_max}*({_price}/{_quantity}) to {balance.list::%player%}
				set player's balance to {balance.list::%player%}
				set {_item} to "%{_max}% %{_orgitem}%" parsed as an item
				remove {_max} of {_orgitem} from player's inventory
				set {_sign-sell} to {ue.msg::signs.sell}
				replace all "{item}" in {_sign-sell} with "%{_quantity}% %{_orgitem}%"
				replace all "{price}" in {_sign-sell} with "%{_max}*({_price}/{_quantity})%"
				message "%{ue.msg::1-important.prefix}% %{_sign-sell}%"
			else:
				message "%{ue.msg::1-important.prefix}% %{ue.msg::economy.not-required-item}%"

function worthGUI(p: Player, page: Number = 1):
	loop {ue.setworth::*}:
		add "%loop-index%" to {_ps::*}
	set {_mxPg} to rounded up (size of {_ps::*}/36)
	if {_mxPg} is less than 1:
		set {_mxPg} to 1
	set {_objects::*} to page {_page} of {_ps::*} with 36 lines
	if {_objects::*} is set:
		set {_rows} to rounded up (size of {_objects::*}/9) + 2
		open virtual chest inventory with size {_rows} named "&8- &9&lWorth &3Pg. &3%{_page}%&8/&3%{_mxPg}% &8-" to {_p}
		make gui slot (integers from 0 to 8) of {_p} with black stained glass pane named "&0" to do nothing
		loop {_objects::*}:
			make gui slot (loop-index parsed as number) + 8 of {_p} with loop-value parsed as an item named "&9%loop-value parsed as an item%" with lore "&7Value: &a$%{ue.setworth::%loop-value%}%" to do nothing
		if {_rows} is between 3 and 6:
			make gui slot (integers from (9 * {_rows}) - 9 to (9 * {_rows}) - 1) of {_p} with black stained glass pane named "&0" to do nothing
		if {_page} > 1:
			make gui slot (9 * {_rows}) - 9 of {_p} with skull of "MHF_ArrowLeft" parsed as offline player named "&c« &4Previous Page" to run function worthGUI({_p}, {_page} - 1)
		if page {_page} + 1 of {_ps::*} with 36 lines is set: #Check if there is values for next pages
			make gui slot 53 of {_p} with skull of "MHF_ArrowRight" parsed as offline player named "&2Next Page &a»" to run function worthGUI({_p}, {_page} + 1)
	else:
		send "%{ue.msg::1-important.prefix}% %{ue.msg::worth.no-values-set}%" to {_p}

command /setworth [<number>]:
	permission: ue.economy.setworth
	permission message: &3&lUE&8&l» &cYou do not have permission to use this command
	aliases: /setvalue, /setprice
	description: Set the value of an item
	trigger:
		if arg 1 is not set:
			message "%{ue.msg::1-important.prefix}% %{ue.msg::setworth.proper-usage}%"
		else if player's tool is air:
			message "%{ue.msg::1-important.prefix}% %{ue.msg::setworth.not-holding-anything}%"
		else if arg 1 < 0:
			message "%{ue.msg::1-important.prefix}% %{ue.msg::setworth.negative-value}%"
		else:
			set {_c} to ""
			if damage of player's tool is not 0:
				set {_c} to ":%damage of player's tool%"
			set {_item} to "%id of player's tool%%{_c}%" parsed as a string
			set {ue.setworth::%{_item}%} to arg 1
			set {_setworth-success} to {ue.msg::setworth.value-set}
			replace all "{tool}" in {_setworth-success} with "%1 of player's tool%"
			replace all "{arg-1}" in {_setworth-success} with "%arg 1%"
			message "%{ue.msg::1-important.prefix}% %{_setworth-success}%"

command /worth [<items>]:
	permission: ue.economy.worth
	permission message: &3&lUE&8&l» &cYou do not have permission to use this command
	aliases: /value, /price
	description: Check the value of an item
	trigger:
		if arg 1 is not set:
			if player's tool is air:
				worthGUI(player,1)
			else:
				set {_c} to ""
				if damage of player's tool is not 0:
					set {_c} to ":%damage of player's tool%"
				set {_item} to "%id of player's tool%%{_c}%" parsed as a string
				if {ue.setworth::%{_item}%} is set:
					set {_worth-value} to {ue.msg::worth.value-set}
					replace all "{item}" in {_worth-value} with "%1 of player's tool%"
					replace all "{value}" in {_worth-value} with "%{ue.setworth::%{_item}%}%"
					message "%{ue.msg::1-important.prefix}% %{_worth-value}%"
				else:
					message "%{ue.msg::1-important.prefix}% %{ue.msg::worth.value-not-set}%"
		else if arg 1 is set:
			loop arguments:
				set {_c} to ":%damage of loop-item%"
				set {_item} to "%id of loop-item%%{_c}%"
				if {ue.setworth::%{_item}%} is set:
					set {_worth-value} to {ue.msg::worth.value-set}
					replace all "{item}" in {_worth-value} with "%arg 1%"
					replace all "{value}" in {_worth-value} with "%{ue.setworth::%{_item}%}%"
					message "%{ue.msg::1-important.prefix}% %{_worth-value}%"	
					stop			
			message "%{ue.msg::1-important.prefix}% %{ue.msg::worth.value-not-set}%"

command /sellall:
	permission: ue.economy.sellall
	permission message: &3&lUE&8&l» &cYou do not have permission to use this command
	description: Sell all items
	trigger:
		loop all items in player's inventory:
			set {_c} to ""
			if damage of loop-item is not 0:
				set {_c} to ":%damage of loop-item%"
			set {_id} to "%id of 1 of loop-item%%{_c}%"
			set {_quantity} to amount of loop-item in player's inventory
			if {ue.setworth::%{_id}%} is set:
				remove {_quantity} of loop-item from player
				add ({ue.setworth::%{_id}%}*{_quantity}) to player's balance
				add ({ue.setworth::%{_id}%}*{_quantity}) to {_earned}
				add {_quantity} to {_totalquantity}
		if {_totalquantity} is set:
			set {_sell-success} to {ue.msg::sell.sold-success}
			replace all "{money}" in {_sell-success} with "%{_earned}%"
			replace all "{amount}" in {_sell-success} with "%{_totalquantity}%"
			message "%{ue.msg::1-important.prefix}% %{_sell-success}%"
		else:
			message "%{ue.msg::1-important.prefix}% %{ue.msg::sellall.no-items-sold}%"

command /sell:
	permission: ue.economy.sell
	permission message: &3&lUE&8&l» &cYou do not have permission to use this command
	description: Sell an item
	trigger:
		set {ue.sell.isopen::%player%} to true
		create a gui with virtual chest with size 5 named "&9Sell Items!"
		open last created gui to player


on inventory close:
	if {ue.sell.isopen::%player%} = true:
		set {ue.sell.isopen::%player%} to false
		loop all items in current inventory of player:
			set {_c} to ""
			if damage of loop-item is not 0:
				set {_c} to ":%damage of loop-item%"
			set {_id} to "%id of 1 of loop-item%%{_c}%"
			set {_quantity} to amount of loop-item in current inventory of player
			if {ue.setworth::%{_id}%} is set:
				remove {_quantity} of loop-item from player
				add ({ue.setworth::%{_id}%}*{_quantity}) to player's balance
				add ({ue.setworth::%{_id}%}*{_quantity}) to {_earned}
				add {_quantity} to {_totalquantity}
			else:
				give loop-item to player
				set {_unsold} to true
		if {_totalquantity} is set:
			set {_sell-success} to {ue.msg::sell.sold-success}
			replace all "{money}" in {_sell-success} with "%{_earned}%"
			replace all "{amount}" in {_sell-success} with "%{_totalquantity}%"
			message "%{ue.msg::1-important.prefix}% %{_sell-success}%"
		if {_unsold} = true:
			message "%{ue.msg::1-important.prefix}% %{ue.msg::sell.unsold-items-returned}%"

on join:
	if {offlineInterest.%uuid of player%} > 0:
		wait 5 seconds
		message "%{ue.msg::1-important.prefix}% &7You earned &a$%{offlineInterest.%uuid of player%}% &7while you were &9offline!"
		add {offlineInterest.%uuid of player%} to {interestEarned.%uuid of player%}
		add {offlineInterest.%uuid of player%} to {bankTotal.%uuid of player%}
		set {offlineInterest.%uuid of player%} to 0

	if {depositTotal.%uuid of player%} is not set:
		set {depositTotal.%uuid of player%} to 0

	if {withdrawalTotal.%uuid of player%} is not set:
		set {withdrawalTotal.%uuid of player%} to 0
	
	if {interestEarned.%uuid of player%} is not set:
		set {interestEarned.%uuid of player%} to 0
	
	if {bankTotal.%uuid of player%} is not set:
		set {bankTotal.%uuid of player%} to 0

	if {offlineInterest.%UUID of player%} is not set:
		set {offlineInterest.%uuid of player%} to 0

on quit:
	delete {ue.bank.deposit.custom-amount.%player%}
	delete {ue.bank.withdrawal.custom-amount.%player%}

on load:
	if {interestNow} is not set:
		set {interestNow} to now

on chat:
	if {ue.bank.deposit.custom-amount.%player%} = true:
		cancel event
		replace all "$" in message with ""
		delete {ue.bank.deposit.custom-amount.%player%}
		if "%message%" parsed as a number is a number:
			bankCode(player, "Deposit", "%message%" parsed as a number)
	if {ue.bank.withdrawal.custom-amount.%player%} = true:
		cancel event
		replace all "$" in message with ""
		delete {ue.bank.withdrawal.custom-amount.%player%}
		if "%message%" parsed as a number is a number:
			bankCode(player, "Withdrawal", "%message%" parsed as a number)

function bankCode(p: Player, type: String, amount: Number):
	set {_UUID} to uuid of {_p}
	if {_type} = "deposit":
		if {_amount} < 0:
			message "%{ue.msg::1-important.prefix}% %{ue.msg::bank.specify-value-about-zero}%" to {_p}
		else if {_amount} <= {balance.list::%{_p}%}:
			add {_amount} to {depositTotal.%{_UUID}%}
			add {_amount} to {bankTotal.%{_UUID}%}
			subtract {_amount} from {_p}'s balance
			set {_balance-to-bank} to {ue.msg::bank.transfer-balance-to-account}
			replace all "{amount}" in {_balance-to-bank} with "%{_amount}%"
			message "%{ue.msg::1-important.prefix}% %{_balance-to-bank}%" to {_p}
		else:
			message "%{ue.msg::1-important.prefix}% %{ue.msg::economy.insufficient-funds}%" to {_p}
	if {_type} = "withdrawal":
		if {_amount} <= 0:
			message "%{ue.msg::1-important.prefix}% %{ue.msg::bank.specify-value-about-zero}%" to {_p}
		else if {_amount} <= {bankTotal.%{_UUID}%}:
			add {_amount} to {withdrawalTotal.%{_UUID}%}
			subtract {_amount} from {bankTotal.%{_UUID}%}
			add {_amount} to {_p}'s balance
			set {_bank-to-balance} to {ue.msg::bank.transfer-account-to-balance}
			replace all "{amount}" in {_bank-to-balance} with "%{_amount}%"
			message "%{ue.msg::1-important.prefix}% %{_bank-to-balance}%" to {_p}
		else:
			message "%{ue.msg::1-important.prefix}% %{ue.msg::economy.insufficient-funds}%" to {_p}
	if {_type} = "chatDeposit":
		set {ue.bank.deposit.custom-amount.%{_p}%} to true
		set {_custom-value} to {ue.msg::bank.custom-value}
		replace all "{amount}" in {_custom-value} with "%{balance.list::%{_p}%}%"
		message "%{ue.msg::1-important.prefix}% %{_custom-value}%" to {_p}
	if {_type} = "chatWithdrawal":
		set {ue.bank.withdrawal.custom-amount.%{_p}%} to true
		set {_custom-value} to {ue.msg::bank.custom-value}
		replace all "{amount}" in {_custom-value} with "%{bankTotal.%{_UUID}%}%"
		message "%{ue.msg::1-important.prefix}% %{_custom-value}%" to {_p}
	if {_type} = "clear":
		set {offlineInterest.%{_UUID}%} to 0
		set {bankTotal.%{_UUID}%} to 0
		set {interestEarned.%{_UUID}%} to 0
		set {withdrawalTotal.%{_UUID}%} to 0
		set {depositTotal.%{_UUID}%} to 0
		message "%{ue.msg::1-important.prefix}% %{ue.msg::bank.reset-self}%" to {_p}


function bankGUI(p: Player, menu: String):
	set {_UUID} to uuid of {_p}
	if {_menu} = "ATM":
		create a gui with virtual chest with size 3 named "&9&lBank ATM":
			make gui slot (integers from 0 to 8) with black stained glass pane named "&0"
			make gui slot (integers from 18 to 26) with black stained glass pane named "&0"
			make gui slot 9 with black stained glass pane named "&0"
			make gui slot 17 with black stained glass pane named "&0"
			make gui slot 10 with diamond named "&c&lWithdrawal":
				bankGUI({_p}, "Withdrawal")
			make gui slot 16 with emerald named "&a&lDeposit":
				bankGUI({_p}, "Deposit")
			make gui slot 13 with chest named "&9&lAccount Standings" with lore "&7&m---------------||&3&lTotal Deposited: &a$%{depositTotal.%{_UUID}%}%||&3&lInterest Earned: &a$%{interestEarned.%{_UUID}%}%||&3&lTotal Withdrawn: &c$%{withdrawalTotal.%{_UUID}%}%||&7&m---------------||&9&lBank Total: &a$%{bankTotal.%{_UUID}%}%"
		open last created gui to {_p}
	if {_menu} = "Withdrawal":
		if {bankTotal.%{_UUID}%} = 0:
			message "%{ue.msg::1-important.prefix}% &4ERROR. &cInsufficient Funds." to {_p}
			close {_p}'s inventory
			stop
		create a gui with virtual chest with size 3 named "&c&lWithdrawal":
			make gui slot (integers from 0 to 8) with black stained glass pane named "&0"
			make gui slot (integers from 18 to 26) with black stained glass pane named "&0"
			make gui slot 9 with black stained glass pane named "&0"
			make gui slot 17 with black stained glass pane named "&0"
			make gui slot 10 with red stained glass pane named "&c&l5%% of Account" with lore "&7&m--------------||&3&lAmount: &a$%0.05*{bankTotal.%{_UUID}%}%":
				bankCode({_p},"Withdrawal", 0.05*{bankTotal.%{_UUID}%})
				close player's inventory
			make gui slot 11 with 2 of red stained glass pane named "&c&l10%% of Account" with lore "&7&m--------------||&3&lAmount: &a$%0.1*{bankTotal.%{_UUID}%}%":
				bankCode({_p},"Withdrawal", 0.1*{bankTotal.%{_UUID}%})
				close player's inventory
			make gui slot 12 with 3 of red stained glass pane named "&c&l25%% of Account" with lore "&7&m--------------||&3&lAmount: &a$%0.25*{bankTotal.%{_UUID}%}%":
				bankCode({_p},"Withdrawal", 0.25*{bankTotal.%{_UUID}%})
				close player's inventory
			make gui slot 13 with 4 of red stained glass pane named "&c&l50%% of Account" with lore "&7&m--------------||&3&lAmount: &a$%0.5*{bankTotal.%{_UUID}%}%":
				bankCode({_p},"Withdrawal", 0.5*{bankTotal.%{_UUID}%})
				close player's inventory
			make gui slot 14 with 5 of red stained glass pane named "&c&l100%% of Account" with lore "&7&m--------------||&3&lAmount: &a$%{bankTotal.%{_UUID}%}%":
				bankCode({_p},"Withdrawal", {bankTotal.%{_UUID}%})
				close player's inventory
			make gui slot 16 with book named "&c&lCustom Amount" with lore "&7&m--------------||&7Click to Input":
				bankCode({_p}, "chatWithdrawal", 0)
				close player's inventory
			make gui slot 25 with emerald named "&a&lDeposit":
				bankGUI({_p}, "Deposit")
			make gui slot 22 with chest named "&9&lAccount Standings" with lore "&7&m---------------||&3&lTotal Deposited: &a$%{depositTotal.%{_UUID}%}%||&3&lInterest Earned: &a$%{interestEarned.%{_UUID}%}%||&3&lTotal Withdrawn: &c$%{withdrawalTotal.%{_UUID}%}%||&7&m---------------||&9&lBank Total: &a$%{bankTotal.%{_UUID}%}%"
		open last created gui to {_p}
	if {_menu} = "Deposit":
		if {balance.list::%{_p}%} = 0:
			message "%{ue.msg::1-important.prefix}% &4ERROR. &cInsufficient Funds." to {_p}
			close {_p}'s inventory
			stop
		create a gui with virtual chest with size 3 named "&a&lDeposit":
			make gui slot (integers from 0 to 8) with black stained glass pane named "&0"
			make gui slot (integers from 18 to 26) with black stained glass pane named "&0"
			make gui slot 9 with black stained glass pane named "&0"
			make gui slot 17 with black stained glass pane named "&0"
			make gui slot 10 with lime stained glass pane named "&a&l5%% of Balance" with lore "&7&m--------------||&3&lAmount: &a$%0.05*{balance.list::%{_p}%}%":
				bankCode({_p},"Deposit", 0.05*{balance.list::%{_p}%})
				close player's inventory
			make gui slot 11 with 2 of lime stained glass pane named "&a&l10%% of Balance" with lore "&7&m--------------||&3&lAmount: &a$%0.1*{balance.list::%{_p}%}%":
				bankCode({_p},"Deposit", 0.1*{balance.list::%{_p}%})
				close player's inventory
			make gui slot 12 with 3 of lime stained glass pane named "&a&l25%% of Balance" with lore "&7&m--------------||&3&lAmount: &a$%0.25*{balance.list::%{_p}%}%":
				bankCode({_p},"Deposit", 0.25*{balance.list::%{_p}%})
				close player's inventory
			make gui slot 13 with 4 of lime stained glass pane named "&a&l50%% of Balance" with lore "&7&m--------------||&3&lAmount: &a$%0.5*{balance.list::%{_p}%}%":
				bankCode({_p},"Deposit", 0.5*{balance.list::%{_p}%})
				close player's inventory
			make gui slot 14 with 5 of lime stained glass pane named "&a&l100%% of Balance" with lore "&7&m--------------||&3&lAmount: &a$%{balance.list::%{_p}%}%":
				bankCode({_p},"Deposit", {balance.list::%{_p}%})
				close player's inventory
			make gui slot 16 with book named "&a&lCustom Amount" with lore "&7&m--------------||&7Click to Input":
				bankCode({_p},"chatDeposit", 0)
				close player's inventory
			make gui slot 19 with diamond named "&c&lWithdrawal":
				bankGUI({_p}, "Withdrawal")
			make gui slot 22 with chest named "&9&lAccount Standings" with lore "&7&m---------------||&3&lTotal Deposited: &a$%{depositTotal.%{_UUID}%}%||&3&lInterest Earned: &a$%{interestEarned.%{_UUID}%}%||&3&lTotal Withdrawn: &c$%{withdrawalTotal.%{_UUID}%}%||&7&m---------------||&9&lBank Total: &a$%{bankTotal.%{_UUID}%}%"
		open last created gui to {_p}

command /account [<offlineplayer=%player%>]:
	permission: ue.economy.bank
	permission message: &3&lUE&8&l» &cYou do not have permission to use this command
	description: Check bank accounts balances
	aliases: /acct, /accts, /accounts
	trigger:
		if {bankTotal.%UUID of arg 1%} is set:
			message "&7&m-----&8[&9&l%arg 1%'s Bank&8]&7&m-----"
			message "&3&lTotal Deposited: &a$%{depositTotal.%uuid of arg 1%}%"
			message "&3&lInterest Earned: &a$%{interestEarned.%uuid of arg 1%}%"
			message "&3&lTotal Withdrawn: &c$%{withdrawalTotal.%uuid of arg 1%}%"
			message "&7&m-------------------"
			message "&9&lBank Total: &a$%{bankTotal.%uuid of arg 1%}%"

command /bank [<text>] [<offlineplayer=%player%>] [<number>]:
	permission: ue.economy.bank
	permission message: &3&lUE&8&l» &cYou do not have permission to use this command
	description: Put money into savings and earn interest!
	trigger:
		if arg 2 is not player:
			if sender doesn't have permission "ue.economy.bank.others":
				message "%{ue.msg::1-important.no-permission-message}%"
		if arg 1 is not set:
			bankGUI(arg 2, "ATM")
		else if arg 1 is "deposit" or "give" or "add":
			if arg 2 is not player:
				message "%{ue.msg::1-important.prefix}% %{ue.msg::bank.only-can-clear}%"
				stop
			if arg 3 is not set:
				bankGUI(arg 2, "Deposit")
			else:
				bankCode(arg 2, "Deposit", arg 3)
		else if arg 1 is "withdraw" or "remove" or "withdrawal":
			if arg 2 is not player:
				message "%{ue.msg::1-important.prefix}% %{ue.msg::bank.only-can-clear}%"
				stop
			if arg 3 is not set:
				bankGUI(arg 2, "Withdrawal")
			else:
				bankCode(arg 2, "Withdrawal", arg 3)
		else if arg 1 is "clear" or "reset":
			bankCode(arg 2, "clear", 0)
			if arg 2 is not player:
				set {_reset-others} to {ue.msg::bank.reset-others}
				replace all "{arg-2}" in {_reset-others} with "%arg 2%"
				message "%{ue.msg::1-important.prefix}% %{_reset-others}%" to player

every 1 minute:
	if difference between {interestNow} and now is greater than or equal to 2 hours:
		set {interestNow} to now
		loop {allplayer.list::*}:
			set {_UUID} to uuid of loop-value
			set {_interestAmount} to {bankTotal.%{_UUID}%}*({ue.config::economy.bank.interest-percent}/100)
			set {_interestAmount} to {_interestAmount} parsed as an number
			if {_interestAmount} > 0:
				if loop-value is online:
					add {_interestAmount} to {interestEarned.%{_UUID}%}
					add {_interestAmount} to {bankTotal.%{_UUID}%}
					message "%{ue.msg::1-important.prefix}% &7You have &9earned &a$%{_interestAmount}% &9in interest." to loop-value
				if loop-value is offline:
					add {_interestAmount} to {offlineInterest.%{_UUID}%}

#Make own sorted function:
#1. While loop (While size of list {_list} >0?)
#2. List with all values
#3. Find highest value in list
#4. Set it as first value in other list
#5. Remove that value from looping list
#6. Go until list is empty

		#List Creator
#		loop {allplayer.list::*}:
#			if loop-value's balance is set:
#				set {_value} to "%loop-value's balance+0%"
#				replace all " Dollars" with "" in {_value}
#				replace all " Dollar" with "" in {_value}
#				set {_value} to {_value} parsed as a number
#				add {_value} to {_ballist::*}