Crates.sk

Created by novastosha

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.


effect givec %player% crate %string%:
	trigger:
		if {Crates::%expr-2%} is set:
			add expr-2 to {Crates::Inventory::%uuid of expr-1%::*}
effect show crates message to %player% as he got %string%:
	trigger:
		send "&a&lCrate Recieved!" to expr-1
		send " " to expr-1
		send "&7You recieved %{Crates::Name::%expr-2%}% &7Crate!" to expr-1
		send "&7Go Check your inventory" to expr-1
function removeItem(text: text, text2: item, player: player):
	remove {_text2} from {Crates::Items::%{_text}%::*}
	close {_player}'s inventory
	send "&cRemoved %{_text2}% from the crate %{Crates::Name::%{_text}%}%" to {_player}
command admincrates [<text>] [<text>] [<text>]:
	trigger:
		if player has permission "crates.admin":
			if arg 1 is "create":
				if {Crates::%arg 2%} is not set:
					set {Crates::%arg 2%} to arg 2
					send "&aCrate: %arg 2% created!"
				else:
					send "&cThis create exists!"
			if arg 1 is "name":
				if {Crates::%arg 2%} is set:
					set {_name} to arg 3
					replace all "&" in {_name} with "ยง"
					set {Crates::Name::%arg 2%} to {_name}
					set {Crates::NameToRl::%{_name}%} to arg 2
					send "&aSucessfully set the name of the Crate %arg 2% to: %{_name}%"
					
				else:
					send "&cThis crate doesn't exist!"
			if arg 1 is "give":
				set {_player} to arg 2 parsed as player
				if {_player} is online:
					if {Crates::%arg 3%} is set:
						givec {_player} crate arg 3
						send "&cGived the player %{_player}% the crate %arg 3%"
						show crates message to {_player} as he got arg 3
					else:
						send "&cThis crate doesn't exist"
				else:
					send "&cThis player cannot be found"
			if arg 1 is "additem":
				if {Crates::%arg 2%} is set:
					if player's held item is not air:
						add player's held item to {Crates::Items::%arg 2%::*}
						send "&aSucessfully added the item %player's held item% to the Crates!"
				else:
					send "&cThis crate doesn't exist!"
			if arg 1 is "adddaily":
				if {Crates::%arg 2%} is set:
					if {Crates::DailyList::*} does not contain {Crates::%arg 2%}:
						add arg 2 to {Crates::DailyList::*}
						send "&aAdded %arg 2% to the Daily List"
					else:
						send "&cThis crate is in the Daily List"
			if arg 1 is "removedaily":
				if {Crates::%arg 2%} is set:
					if {Crates::DailyList::*} contains {Crates::%arg 2%}:
						remove arg 2 from {Crates::DailyList::*}
						send "&aRemoved %arg 2% from the Daily List!"
					else:
						send "&cThis crate is not in the Daily List"
			if arg 1 is "removeitem":
				if {Crates::%arg 2%} is set:
					open chest with 6 rows named "&cClick the item to remove" to player
					loop all numbers between 0 and 128:
						format gui slot loop-number of player with light gray glass pane named " " to do nothing
					set {_s} to 0
					loop {Crates::Items::%arg 2%::*}:
						format gui slot {_s} of player with loop-value named name of loop-value to run function removeItem(arg 2, loop-value, player)
							
						add 1 to {_s}
				else:
					send "&cThis crate doesn't exist!"
			if arg 1 is "clear":
				clear {Crates::Inventory::%uuid of player%::*}
				send "&aCleared your inventory of crates"
			if arg 1 is "open":
				if {Crates::%arg 2%} is set:
					send "&aForcibly opening the crate: %{Crates::Name::%arg 2%}%"
					openCrate(player, arg 2)
				else:
					send "&cThis crate doesn't exist!"
function openTypeGUI(player: player, text: text):
	close {_player}'s inventory
	open chest with 1 row named "&0The Crate: %{Crates::Name::%{_text}%}%" to {_player}
	format gui slot 1 of {_player} with orange clay named "&6Open Crate!" to run function openCrate({_player}, {_text})
	format gui slot 7 of {_player} with cyan clay named "&3See contents of the Crate %{Crates::Name::%{_text}%}%!" to run function seeCrate({_player}, {_text})
function seeCrate(player: player, text: text):
	close {_player}'s inventory
	open chest with 6 rows named "&7Contents of the Crate: %{Crates::Name::%{_text}%}%" to {_player}
	loop all numbers between 0 and 128:
		format gui slot loop-number of {_player} with light gray glass pane named " " to do nothing
	set {_s} to 0
	loop {Crates::Items::%{_text}%::*}:
		format gui slot {_s} of {_player} with loop-value named name of loop-value to do nothing
		add 1 to {_s}
function openCrate(player: player, text: text):
	close {_player}'s inventory
	open chest with 3 rows named "&7Opening Crate: %{Crates::Name::%{_text}%}%" to {_player}
	loop all numbers between 0 and 128:
		format gui slot loop-number of {_player} with light gray glass pane named " " to do nothing
	if {Crates::Items::%{_text}%::*} is empty:
		send "&cAn Error happend while opening your crate! (Crate Empty exception)" to {_player}
		close {_player}'s inventory
		stop
	loop 60 times:
		wait 3 ticks
		set {random5::%{_player}%} to random element out of {Crates::Items::%{_text}%::*}
		format gui slot 4 of {_player} with {random5::%{_player}%} named name of {random5::%{_player}%}
		set {random12::%{_player}%} to random element out of {Crates::Items::%{_text}%::*}
		format gui slot 12 of {_player} with {random12::%{_player}%} named name of {random12::%{_player}%}
		set {random14::%{_player}%} to random element out of {Crates::Items::%{_text}%::*}
		format gui slot 14 of {_player} with {random14::%{_player}%} named name of {random14::%{_player}%}
	set {_random} to random element out of {Crates::Items::%{_text}%::*}
	format gui slot 13 of {_player} with {_random} named "&aYou won:&f %{_random}%" to do nothing
	wait 3 ticks
	send "&a&lYou Won: %{_random}%" to {_player}
	send " " to {_player}

	send "&7That's Cool!" or "&7Good Luck next time!" to {_player}
	give {_player} {_random}
	set {_uudi} to uuid of {_player}
	remove {_text} from {Crates::Inventory::%{_uudi}%}

command crates [<text>]:
	trigger:
		if world of player is {Hub::World}:
			if arg 1 is "open":
				
				open chest with 6 rows named "&aCrates" to player
				set {_slot} to 0
				loop all numbers between 0 and 128:
					format gui slot loop-number of player with light gray glass pane named " " to do nothing
				loop {Crates::Inventory::%uuid of player%::*}:
					format gui slot {_slot} of player with chest named "%{Crates::Name::%loop-value%}%" to run function openTypeGUI(player, loop-value)
					add 1 to {_slot}
			if arg 1 is "see":
				open chest with 6 rows named "&7Crates We have:" to player
				loop all numbers between 0 and 128:
					format gui slot loop-number of player with light gray glass pane named " " to do nothing
				set {_slot} to 0
				loop {Crates::*}:
					format gui slot {_slot} of player with chest named "%{Crates::Name::%loop-value%}%" to run function seeCrate(player, loop-value)
					add 1 to {_slot}
		else:
			send "&cCrates can only be opened in the Hub!"
#If you're seeing this and you're wishing to make Webstie it is compatible with BuyCraft (The store system) 
on join:
	if {Crates::Daily::%player%} is not set:
		set {Crates::Daily::%player%} to now

every 1 second:
	loop all players:
		if difference between now and {Crates::Daily::%loop-player%} is bigger than or equal to 1 day:
			set {Crates::Daily::%loop-player%} to now
			if {Crates::DailyList::*} is not empty:
				loop {Crates::DailyList::*}:
					givec loop-player crate loop-value
					show crates message to loop-player as he got loop-value