# ==========================================
# PROSTY I NIEZAWODNY PANEL ADMINA (GUI)
# ==========================================
# Komenda główna i jej aliasy do dodawania przedmiotów
command /admin-dajitem:
aliases: /admin daj-item
permission: admin.zarzadzanie
permission message: &cBrak uprawnień do tej komendy.
trigger:
if player's tool is air:
send "&c&lBŁĄD: &7Musisz trzymać przedmiot w ręce!" to player
stop
# Dodajemy przedmiot na koniec listy
add player's tool to {admin_items::*}
send "&a&lSUKCES: &7Dodano przedmiot do Twojego menu admina!" to player
# Komenda otwierająca skrzynkę DO POBIERANIA (Przedmioty się odnawiają)
command /admingui:
aliases: /admin gui
permission: admin.zarzadzanie
permission message: &cBrak uprawnień do tej komendy.
trigger:
# Sprawdzamy ile jest przedmiotów i dodajemy 2 linijki więcej
set {_size} to size of {admin_items::*}
set {_needed_slots} to {_size} + 18
if {_needed_slots} <= 9:
set {_rows} to 1
else if {_needed_slots} <= 18:
set {_rows} to 2
else if {_needed_slots} <= 27:
set {_rows} to 3
else if {_needed_slots} <= 36:
set {_rows} to 4
else if {_needed_slots} <= 45:
set {_rows} to 5
else:
set {_rows} to 6
set {_gui} to chest inventory with {_rows} rows named "&c&lZapisane Przedmioty Admina"
set {_slot} to 0
loop {admin_items::*}:
if {_slot} < 54:
set slot {_slot} of {_gui} to loop-value
add 1 to {_slot}
open {_gui} to player
# Komenda otwierająca skrzynkę DO EDYCJI/USUWANIA (Można wyciągać przedmioty)
command /usuń-item:
aliases: /usun-item, /admin usun, /admin-usun
permission: admin.zarzadzanie
permission message: &cBrak uprawnień do tej komendy.
trigger:
set {_size} to size of {admin_items::*}
set {_needed_slots} to {_size} + 18
if {_needed_slots} <= 9:
set {_rows} to 1
else if {_needed_slots} <= 18:
set {_rows} to 2
else if {_needed_slots} <= 27:
set {_rows} to 3
else if {_needed_slots} <= 36:
set {_rows} to 4
else if {_needed_slots} <= 45:
set {_rows} to 5
else:
set {_rows} to 6
set {_gui} to chest inventory with {_rows} rows named "&4&lUSUWANIE: Wyciągnij przedmioty"
set {_slot} to 0
loop {admin_items::*}:
if {_slot} < 54:
set slot {_slot} of {_gui} to loop-value
add 1 to {_slot}
open {_gui} to player
# OBSŁUGA POZOSTAWIANIA PRZEDMIOTÓW W GUI DO POBIERANIA
on inventory click:
if name of player's current inventory is "&c&lZapisane Przedmioty Admina":
if clicked inventory is not player's inventory:
if clicked item is not air:
set {_slot} to clicked slot
set {_item} to clicked item
wait 1 tick
set slot {_slot} of player's current inventory to {_item}
# AUTOMATYCZNY ZAPIS ZMIAN PO ZAMKNIĘCIU OKNA USUWANIA
on inventory close:
if name of player's current inventory is "&4&lUSUWANIE: Wyciągnij przedmioty":
# Czyścimy starą listę przedmiotów w pamięci
clear {admin_items::*}
# Sprawdzamy co zostało w skrzynce i zapisujemy to na nowo
set {_slot} to 0
loop 54 times:
set {_item} to slot {_slot} of player's current inventory
if {_item} is not air:
add {_item} to {admin_items::*}
add 1 to {_slot}
send "&c&lZAPISANO: &7Usunięto wyciągnięte przedmioty z bazy admina!" to player