Files
mandat.sk
Code
1 310
mandat.sk
# ============================================
# System Mandatow v1.0
# Fizyczny papier + Inventory GUI
# ============================================
# Instrukcja:
# 1. Wrzuc plik do plugins/Skript/scripts/
# 2. Wpisz /sk reload mandat
# 3. Nadaj permise: lp user <nick> permission set mandat.give true
#
# Uzycie:
# /givemandat - otrzymaj pusty papier mandatu
# Kliknij PPM na papier - otworzy GUI do wypelnienia
# Po zapisie przekaz papier sprawcy
# Sprawca klika PPM - widzi szczegoly mandatu
#
# Wymagania: Skript 2.6+
# ============================================
options:
prefix: &8[&c✘ Mandat&r]
# ==================== INICJALIZACJA ====================
on load:
if {mandat::counter} is not set:
set {mandat::counter} to 1000
broadcast "{@prefix} &7System mandatow zaladowany!"
# ==================== KOMENDY ====================
command /givemandat:
permission: mandat.give
description: Otrzymaj pusty mandat do wypelnienia
trigger:
add 1 to {mandat::counter}
set {_id} to {mandat::counter}
set {mandat::%{_id}%::status} to "unfilled"
set {_item} to paper
set name of {_item} to "&c&lMandat #%{_id}%"
set lore of {_item} to "&8&m ", "&7Status: &eNiewypelniony", "", "&eKliknij PPM aby wypelnic"
give {_item} to player
message "{@prefix} &aOtrzymales mandat &7#%{_id}%&a!"
message "{@prefix} &7Kliknij go &ePPM &7aby wypelnic."
# ==================== WYKRYWANIE KLIKNIECIA ====================
on right click:
if player's tool is a paper:
set {_name} to name of player's tool
set {_name} to {_name} replace "§" with "&"
if {_name} contains "Mandat #":
set {_id} to {_name} replace "&c&lMandat #" with ""
set {_id} to trim {_id}
if {_id} is not set or {_id} is "":
stop
if {mandat::%{_id}%::status} is "unfilled":
set {mandat::editing::%player%} to {_id}
openFillGui(player, {_id})
else if {mandat::%{_id}%::status} is "filled":
openViewGui(player, {_id})
# ==================== FUNKCJE GUI ====================
function openFillGui(p: player, id: integer):
set {_gui} to a new chest inventory with 3 rows named "&cWypelnij mandat #%{_id}%"
# Wypelnij calosc czarnym szklem
set {_filler} to black stained glass pane named "&8"
loop 27 times:
set slot {_l} - 1 of {_gui} to {_filler}
# === WIERSZ 1: Pola do wypelnienia ===
# Kwota (slot 1)
set {_kwota} to {mandat::temp::%{_p}%::%{_id}%::kwota}
set {_item} to gold ingot
if {_kwota} is not set:
set name of {_item} to "&6&lKWOTA"
set lore of {_item} to "&7Kliknij aby ustawic", "&7Obecnie: &cNieustawiona"
else:
set name of {_item} to "&6&lKWOTA: &e%{_kwota}%"
set lore of {_item} to "&7Kliknij aby zmienic", "&7Obecnie: &e%{_kwota}%"
set slot 1 of {_gui} to {_item}
# Powod (slot 4)
set {_powod} to {mandat::temp::%{_p}%::%{_id}%::powod}
set {_item} to book
if {_powod} is not set:
set name of {_item} to "&6&lPOWOD"
set lore of {_item} to "&7Kliknij aby ustawic", "&7Obecnie: &cNieustawiony"
else:
set name of {_item} to "&6&lPOWOD: &e%{_powod}%"
set lore of {_item} to "&7Kliknij aby zmienic", "&7Obecnie: &e%{_powod}%"
set slot 4 of {_gui} to {_item}
# Sprawca (slot 7)
set {_sprawca} to {mandat::temp::%{_p}%::%{_id}%::sprawca}
set {_item} to name tag
if {_sprawca} is not set:
set name of {_item} to "&6&lSPRAWCA"
set lore of {_item} to "&7Kliknij aby ustawic", "&7Obecnie: &cNieustawiony"
else:
set name of {_item} to "&6&lSPRAWCA: &e%{_sprawca}%"
set lore of {_item} to "&7Kliknij aby zmienic", "&7Obecnie: &e%{_sprawca}%"
set slot 7 of {_gui} to {_item}
# === WIERSZ 3: Przyciski akcji ===
# Przycisk Zapisz (slot 20)
if {mandat::temp::%{_p}%::%{_id}%::kwota} is set and {mandat::temp::%{_p}%::%{_id}%::powod} is set and {mandat::temp::%{_p}%::%{_id}%::sprawca} is set:
set {_item} to lime dye
set name of {_item} to "&a&lZAPISZ"
set lore of {_item} to "&7Kliknij aby zapisac mandat"
set slot 20 of {_gui} to {_item}
else:
set {_item} to gray dye
set name of {_item} to "&7&lZAPISZ"
set lore of {_item} to "&cWypelnij wszystkie pola!", "&7Kwota, powod i sprawca"
set slot 20 of {_gui} to {_item}
# Przycisk Anuluj (slot 24)
set {_item} to red dye
set name of {_item} to "&c&lANULUJ"
set lore of {_item} to "&7Anuluj i odrzuc mandat"
set slot 24 of {_gui} to {_item}
open {_gui} to {_p}
function openViewGui(p: player, id: integer):
set {_gui} to a new chest inventory with 3 rows named "&cSzczegoly mandatu #%{_id}%"
# Wypelnij calosc
set {_filler} to black stained glass pane named "&8"
loop 27 times:
set slot {_l} - 1 of {_gui} to {_filler}
# Gorny rzad - tytul (slot 4)
set {_item} to paper
set name of {_item} to "&c&lMANDAT #%{_id}%"
set lore of {_item} to "&7Sprawca: &e%{mandat::%{_id}%::sprawca}%", "", "&7Data: &e%{mandat::%{_id}%::data}%"
set slot 4 of {_gui} to {_item}
# Srodkowy rzad - szczegoly
# Kwota (slot 10)
set {_item} to gold ingot
set name of {_item} to "&6&lKWOTA"
set lore of {_item} to "&e%{mandat::%{_id}%::kwota}%"
set slot 10 of {_gui} to {_item}
# Powod (slot 13)
set {_item} to book
set name of {_item} to "&6&lPOWOD"
set lore of {_item} to "&e%{mandat::%{_id}%::powod}%"
set slot 13 of {_gui} to {_item}
# Wystawil (slot 16)
set {_item} to name tag
set name of {_item} to "&6&lWYSTAWIL"
set lore of {_item} to "&e%{mandat::%{_id}%::policjant}%"
set slot 16 of {_gui} to {_item}
# Dolny rzad - przycisk zamkniecia (slot 22)
set {_item} to red dye
set name of {_item} to "&c&lZAMKNIJ"
set lore of {_item} to "&7Kliknij aby zamknac"
set slot 22 of {_gui} to {_item}
open {_gui} to {_p}
# ==================== OBSLUGA KLIKNIEC W GUI FILL ====================
on inventory click:
if name of player's current inventory contains "Wypelnij mandat #":
cancel event
# Wyciagnij ID z tytulu GUI
set {_title} to name of player's current inventory
set {_title} to {_title} replace "§" with "&"
set {_id} to {_title} replace "&cWypelnij mandat #" with ""
set {_id} to trim {_id}
if {_id} is not set or {_id} is "":
stop
# Slot 1 - Ustaw kwote
if event-slot is 1:
close player's inventory
set {mandat::input::%player%::id} to {_id}
set {mandat::input::%player%::type} to "kwota"
send "{@prefix} &aPodaj kwote mandatu (w zl):"
send "&7(Wpisz liczbe, np. 100)"
send "&7Wpisz '&canuluj&7' aby anulowac."
# Slot 4 - Ustaw powod
else if event-slot is 4: