Created by MattyHD0

Other available versions. Ordered by newest to oldest versions:

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.

#DISCLAIMER: All item and inventory data is stored in 'plugins\Skript\variables.csv' deleting this file will cause data loss
#DISCLAIMER: changing 'backpack-rows' to a lower number than it was previously will also cause data loss
	backpack-name: &8Your Backpack
	other-backpack-name: &8%{_player}%'s Backpack #Don't use the same name you used in 'backpack-name' or there will be errors!
	backpack-rows: 3

	not-editable-message: &cThis inventory is not editable

	prefix: &8[&6SimpleBackpack&8] &7

	open-message: true
	open-backpack-message: You just opened your backpack

	close-message: true
	close-backpack-message: You just closed your backpack

	other-backpack-message: You are checking %{_player}%'s backpack

	clean-message: You cleaned %{_player}%'s backpack

	permission-message: &cYou don't have permission to do that!

	version: v1.0.1

on load:
	delete {SimpleBackpack.playerStatus::*}

command /backpack:
	permission: simplebackpack.backpack
	permission message: {@permission-message}

command /simplebackpack [<string>] [<offline player>]:
	permission: simplebackpack.admin
	permission message: {@permission-message}
	aliases: /sb
		if arg-1 is set:
			if arg-1 is "help":
				send "&6&lSimpleBackpack &7with &e&l<3 &7for &e&lYour Server &7| &e{@version}"
				send "&6/backpack &7- &eopen your backpack"
				send "&6/sb view <player> &7- &eview the contents of a player's backpack"
				send "&6/sb clear <player> - &eclean the contents of a player's backpack"
				send "&6/sb reload &7- &ereload the script"
			else if arg-1 is "view":
				sb_viewBackpack(player, arg-2)
			else if arg-1 is "clear":
				set {_player} to arg-2
				send "{@prefix}{@clean-message}"
			else if arg-1 is "reload":
				execute player command "sk reload %script%"
				send "{@prefix}&7The entered subcommand does not exist"
			send "{@prefix}&7To see the command list enter &e/sb help&7."

function sb_openBackpack(player: player):
	set {SimpleBackpack.playerStatus::%{_player}%} to 1
	if {@open-message} is true:
		send "{@prefix}{@open-backpack-message}" to {_player}
	open virtual chest with {@backpack-rows} rows named "{@backpack-name}" to {_player}
	loop ((rows of {_player}'s current inventory)*9) times:
		set slot (loop-number)-1 of {_player}'s current inventory to {SimpleBackpack.backpack.%{_player}%::%(loop-number)-1%}

function sb_viewBackpack(player: player, backpack: offline player):
	set {SimpleBackpack.playerStatus::%{_player}%} to 2
	send "{@prefix}{@other-backpack-message}" to {_player}
	set {_inventory} to virtual chest with {@backpack-rows} rows named "{@other-backpack-name}"
	loop ((rows of {_backpack})*9) times:
		set slot (loop-number)-1 of {_inventory} to {SimpleBackpack.backpack.%{_backpack}%::%(loop-number)-1%}
	show {_inventory} to {_player}

function sb_saveBackpack(player: player):
	delete {SimpleBackpack.backpack.%{_player}%::*}
	loop ((rows of {_player}'s current inventory)*9) times:
		set {SimpleBackpack.backpack.%{_player}%::%(loop-number)-1%} to slot (loop-number)-1 of {_player}'s current inventory

on inventory click:
	if {SimpleBackpack.playerStatus::%player%} is 2:
		if event-item is set:
			cancel the event
			send "{@prefix}{@not-editable-message}" to player

function sb_clearBackpack(player: player):
	if {SimpleBackpack.playerStatus::%{_player}%} is 1:
		close the inventory view of {_player}
		delete {SimpleBackpack.playerStatus::%{_player}%}
	delete {SimpleBackpack.backpack.%{_player}%::*}

on inventory close:
	if {SimpleBackpack.playerStatus::%player%} is 1:
		delete {SimpleBackpack.playerStatus::%player%}
		if {@close-message} is true:
			send "{@prefix}{@close-backpack-message}" to player
	else if {SimpleBackpack.playerStatus::%player%} is 2:
		delete {SimpleBackpack.playerStatus::%player%}