Skocz do zawartości
  • 0

Problem z "cancel event"


Pytanie

on inventory click:
    if name of event-inventory is {guis::dragons}:
        if name of event-item is not  " ":
            cancel event
            loop 12 times:
                set {_n} to name of event-item
                if {dragons::%loop-integer%} contains {_n}:
                    mlody_smokiGUI(player, "%loop-integer%")
                    stop
    if {dragons::*} contains name of event-inventory:
        cancel event
        loop 12 times:
            set {_n} to name of event-item
            if {dragons::%loop-integer%} contains {_n}:

Mam taki kod, w którym jest 12 smoków jest gui gdzie po kliknięciu na dowolnego otwieram gui tego smoka
w kodzie powyżej jest kawałek on inventory click i i część kodu po if {dragons::*} dotyczy gui które są dla smoków
chodzi oto że mam tam cancel event, ale on nie działa, ale tylko w dwóch smokach o numerach 3 i 7

Nie wiem czy dobrze to wytłumaczyłem, ale w skrócie cancel event nie działa na dwóch smokach o numerach 3 i 7

 

Odnośnik do komentarza
https://skript.pl/temat/57469-problem-z-cancel-event/
Udostępnij na innych stronach

7 odpowiedzi na to pytanie

Rekomendowane odpowiedzi

  • 0
Godzinę temu, judosmok napisał:

Mam taki kod, w którym jest 12 smoków jest gui gdzie po kliknięciu na dowolnego otwieram gui tego smoka
w kodzie powyżej jest kawałek on inventory click i i część kodu po if {dragons::*} dotyczy gui które są dla smoków
chodzi oto że mam tam cancel event, ale on nie działa, ale tylko w dwóch smokach o numerach 3 i 7

Nie wiem czy dobrze to wytłumaczyłem, ale w skrócie cancel event nie działa na dwóch smokach o numerach 3 i 7

Trudno jest mi jednoznacznie określić przyczynę braku działania Pana skryptu, ponieważ nie wiem jak wygląda zawartość listy {dragons::*} i nie wiem jak wygląda GUI tworzone przez Pana skrypt.

W tej sytuacji mogę wskazać dwa najbardziej prawdopodobne scenariusze.

  1. Przy kliknięciu na wspomniane smoki numer 3 i 7 warunek porównujący zawartość listy {dragons::*} z nazwą klikniętego inwentarza nie jest spełniony. Tutaj sugeruję dodanie jakiejś instrukcji 'send' po przejściu przez warunek (wyświetlający jakąkolwiek wiadomość, ma to być jedynie informacja) i dodatkowo 'send' przed tym warunkiem wyświetlający nazwę inwentarza 'name of event-inventory'. Dla porównania może Pan również sprawdzić 'name of clicked inventory'.
  2. Może mieć Pan w tym lub w jakimkolwiek innym skrypcie (a nawet w pluginie) listener zdarzenia 'on inventory click' (Bukkit API: InventoryClickEvent), który odwołuje anulowanie zdarzenia. Plugin/skrypt może mieć wyższy priorytet dla tego listenera i w tych specyficznych warunkach jest powodem tego dziwnego problemu.
    Nie traktowałbym tej sugestii na ten moment poważnie, gdyż jest to mało prawdopodobne. Pan powinien na razie się skupić na samym tym skrypcie, później na innych skryptach i finalnie na pluginach.

Na pierwszy rzut oka skrypt wygląda całkowicie w porządku, niemniej jednak nie widzę całej prawdy, więc w tej chwili wróżę z fusów.

Oczywiście najlepsza i jedyna metoda debuggingu to wysyłanie wiadomości na czacie. Niech Pan sprawdzi wszystkie kluczowe zmienne i wyrażenia, które Pan wykorzystuje w tym skrypcie. Jest szansa, że Pan zauważy jakąś nieprawidłowość.

Kończąc mój wywód, do ewentualnego tworzenia testowego kodu listenera 'on inventory click:' może Pan wspomóc się tym warunkiem.

Odnośnik do komentarza
https://skript.pl/temat/57469-problem-z-cancel-event/#findComment-342197
Udostępnij na innych stronach

  • 0

Problem jest taki, że nawet jak napisze
 

on inventory click:
    if (name of event-inventory is {dragon::3} ro {dragon::7}):
		cancel event

{dragon::3} i {dragon::7} do nich są ustawione nazwy dwóch gui i tylko one nie działają
i nawet jak napisz powyższy kod to nadal da się z tych gui wyjmować itemy

Odnośnik do komentarza
https://skript.pl/temat/57469-problem-z-cancel-event/#findComment-342201
Udostępnij na innych stronach

  • 0
24 minuty temu, judosmok napisał:

Problem jest taki, że nawet jak napisze
 

on inventory click:
    if (name of event-inventory is {dragon::3} ro {dragon::7}):
		cancel event

{dragon::3} i {dragon::7} do nich są ustawione nazwy dwóch gui i tylko one nie działają
i nawet jak napisz powyższy kod to nadal da się z tych gui wyjmować itemy

Czy sprawdził Pan rzeczy, o których mówiłem? Pomijam literówkę przy 'or', bo to jest nieistotne.

Proszę pokazać zawartość listy {dragon::*} i nazwy tych GUI, o których Pan mówi.

Odnośnik do komentarza
https://skript.pl/temat/57469-problem-z-cancel-event/#findComment-342203
Udostępnij na innych stronach

  • 0
4 godziny temu, judosmok napisał:

{dragon::*} - zawiera 12 nazw gui, od {dragon::1} do {dragon::12}
no i główne gui przez które wchodzi się do poszczególnych gui - {dragon::gui} (ale z nim nie ma problemu)

Niestety nie jestem w stanie odtworzyć bugu, z którym Pan się męczy. Może Pan ma literówki lub niezgadzające się kolory w nazwach GUI i przez to warunek nie jest spełniony?

Napisałem poniższy kod testowy i wszystko działa jak należy, nieważne o którym GUI mówimy.

on script load:
	set {dragons::*} to "&6smok1", "&6smok2", "&6smok3", "&6smok4", "&6smok5", "&6smok6", "&6smok7", "&6smok8", "&6smok9", "&6smok10", "&6smok11", "&6smok12"
	set {guis::dragons} to "&cSmoki"
	
command /dragonstest:
	trigger:
		set {_g} to chest inventory with 3 rows named {guis::dragons}
		loop (size of {dragons::*}) times:
			set slot (loop-number - 1) of {_g} to iron ingot named {dragons::%loop-number%}
		open {_g} to player
		
function mlody_smokiGUI(p: player, n: number):
	set {_g} to chest inventory with 3 rows named {dragons::%{_n}%}
	set slot (integers between 0 and 26) of {_g} to gold ingot named "Test"
	open {_g} to {_p}
		
on inventory click:
	if name of event-inventory is {guis::dragons}:
		if name of event-item is not " ":
			cancel event
			set {_n} to name of event-item
			loop 12 times:
				if {dragons::%loop-number%} contains {_n}:
					close player's inventory
					mlody_smokiGUI(player, loop-number)
					stop
	if {dragons::*} contains name of event-inventory:
		cancel event
		send "Nie możesz tego wyjąć!" to player
	
	
command /dragonsclear:
	trigger:
		clear {dragons::*} and {guis::dragons}

 

Odnośnik do komentarza
https://skript.pl/temat/57469-problem-z-cancel-event/#findComment-342236
Udostępnij na innych stronach

  • 0

Może dlatego że mam inaczej zrobione, wyśle może jak to umie wygląda:
 

command /smoki:
    trigger:
        mlody_smokiGUI(player, "main")

function mlody_smokiGUI(p: player, n: string):
    if {_n} is "main":
        set {_gui} to chest inventory with 4 row named {guis::dragons}
        loop integers between 0 and 35:
            set {_gui}'s slot loop-integer to black stained glass pane named " "
        set {_i1} to 10
        set {_i2} to 20
        # ----------
        loop 7 times:
            set {_gui}'s slot {_i1} to sunflower named {dragons::%loop-integer%} with lore "&7Wymagania:" and "&8・&7Poziom » &f%{poziom::%{_p}'s uuid%}%&7/&f%{dragons::%loop-integer%::level}%" and "&8・&7Zabójstwa » &f%{kill::%{_p}'s uuid%}%&7/&f%{dragons::%loop-integer%::kills}%" and "&8・&7Wykopane bloki » &f%{blok::%{_p}'s uuid%}%&7/&f%{dragons::%loop-integer%::blocks}%" and "&8・&7Odrodzenia » &f%{odrodzenie::%{_p}'s uuid%}%&7/&f%{dragons::%loop-integer%::revives}%" and "&8・&f&lStatus » &f%{dragons::%loop-integer%::canClaim::%{_p}'s uuid%}%"
            add 1 to {_i1}
        loop 5 times:
            set {_gui}'s slot {_i2} to sunflower named {dragons::%loop-integer + 7%} with lore "&7Wymagania:" and "&8・&7Poziom » &f%{poziom::%{_p}'s uuid%}%&7/&f%{dragons::%loop-integer + 7%::level}%" and "&8・&7Zabójstwa » &f%{kill::%{_p}'s uuid%}%&7/&f%{dragons::%loop-integer + 7%::kills}%" and "&8・&7Wykopane bloki » &f%{blok::%{_p}'s uuid%}%&7/&f%{dragons::%loop-integer + 7%::blocks}%" and "&8・&7Odrodzenia » &f%{odrodzenie::%{_p}'s uuid%}%&7/&f%{dragons::%loop-integer + 7%::revives}%" and "&8・&f&lStatus » &f%{dragons::%loop-integer + 7%::canClaim::%{_p}'s uuid%}%"
            add 1 to {_i2}
            # -----------------
        open {_gui} to {_p}
        stop
    set {_gui} to chest inventory with 5 rows named {dragons::%{_n}%}
    set {_gui}'s slot 0 and 8 and 36 and 44 to purple stained glass pane named " "
    set {_gui}'s slot 1 and 9 and 7 and 17 and 37 and 43 and 27 and 35 to blue stained glass pane named " "
    set {_gui}'s slot 2 and 3 and 5 and 6 and 18 and 26 and 38 and 39 and 41 and 42 to light blue stained glass pane named " "

    if {dragons::%{_n}%::canClaim::%{_p}'s uuid%} is {@false}:
        set {_gui}'s slot 22 to red wool named {dragons::%{_n}%} with lore "&7Wymagania:" and "&8・&7Poziom » &f%{poziom::%{_p}'s uuid%}%&7/&f%{dragons::%{_n}%::level}%" and "&8・&7Zabójstwa » &f%{kill::%{_p}'s uuid%}%&7/&f%{dragons::%{_n}%::kills}%" and "&8・&7Wykopane bloki » &f%{blok::%{_p}'s uuid%}%&7/&f%{dragons::%{_n}%::blocks}%" and "&8・&7Odrodzenia » &f%{odrodzenie::%{_p}'s uuid%}%&7/&f%{dragons::%{_n}%::revives}%" and "&8・&f&lStatus » &f%{dragons::%{_n}%::canClaim::%{_p}'s uuid%}%"
    else if {dragons::%{_n}%::canClaim::%{_p}'s uuid%} is {@toClaim}:
        set {_gui}'s slot 22 to yellow wool named {dragons::%{_n}%} with lore "&8・&f&lStatus » &f%{dragons::%{_n}%::canClaim::%{_p}'s uuid%}%" and "&8・&7Kliknij aby wytresować smoka %{dragons::%{_n}%}%"
    else:
        set {_gui}'s slot 22 to lime wool named {dragons::%{_n}%} with lore "&8・&f&lStatus » &f%{dragons::%{_n}%::canClaim::%{_p}'s uuid%}%"

    # if {dragons::%{_n}%::canClaim::%%{_p}'s uuid%%} is {@toClaim}:
    #     set {_gui}'s slot 22 to lime wool named {dragons::%{_n}%} with lore "do odebrania"
    # else:
    #     set {_gui}'s slot 22 to lime wool named {dragons::%{_n}%} with lore "wytresowales"
    open {_gui} to {_p}

function mlody_checkSmoki(p: player):
    if {dragons::cooldown::%{_p}'s uuid%} is smaller than now:
        loop 12 times:
            if: 
                {poziom::%{_p}'s uuid%} is greater or equal to {dragons::%loop-integer%::level}
                {kill::%{_p}'s uuid%} is greater or equal to {dragons::%loop-integer%::kills}
                {blok::%{_p}'s uuid%} is greater or equal to {dragons::%loop-integer%::blocks}
                {odrodzenie::%{_p}'s uuid%} is greater or equal to {dragons::%loop-integer%::revives}
            then:
                if {dragons::%loop-integer%::canClaim::%{_p}'s uuid%} is {@false}:
                    set {dragons::%loop-integer%::canClaim::%{_p}'s uuid%} to {@toClaim}

            else:
                set {dragons::%loop-integer%::canClaim::%{_p}'s uuid%} to {@false}
        set {dragons::cooldown::%{_p}'s uuid%} to now + 3 second
        loop 12 times:
            if {dragons::%loop-integer%::canClaim::%{_p}'s uuid%} is {@toClaim}:
                send "%{prefix}% &aMożesz wytresować smoka %{dragons::%loop-integer%}%! &a(&f/smoki&a)" to {_p}

            

on inventory click:
    if name of event-inventory is {guis::dragons}:
        if name of event-item is not  " ":
            cancel event
            loop 12 times:
                set {_n} to name of event-item
                if {dragons::%loop-integer%} contains {_n}:
                    mlody_smokiGUI(player, "%loop-integer%")
                    stop
    if {dragons::*} contains name of event-inventory:
        cancel event
        loop 12 times:
            set {_n} to name of event-item
            if {dragons::%loop-integer%} contains {_n}:
#--------------------------------------------------------------

#------------------------------------------------------------------------
                if {dragons::%loop-integer-1%::canClaim::%player's uuid%} is {@false}:
                    send "%{prefix}% &4Nie spełniasz wymagań, aby wytresować tego smoka!" to player
                if {dragons::%loop-integer-1%::canClaim::%player's uuid%} is {@toClaim}:
                    if player has enough space for {dragons::%loop-integer-1%::reward}:
                        give {dragons::%loop-integer-1%::reward} to player
                        set {dragons::%loop-integer-1%::canClaim::%player's uuid%} to {@true}
                        broadcast "%{prefix}% &7Gracz &f%player% &7wytresował smoka %{dragons::%loop-integer-1%}%"
                        close player's inventory
                        stop
                if {dragons::%loop-integer-1%::canClaim::%player's uuid%} is {@true}:
                    send "%{prefix}% &7Wytresowałeś już tego smoka!"


to jest tylko część 
nie dawałem tu ustawiania zmiennych w on skript load bo w tym były jeszcze inne zmienne

Odnośnik do komentarza
https://skript.pl/temat/57469-problem-z-cancel-event/#findComment-342277
Udostępnij na innych stronach

  • 0
6 godzin temu, judosmok napisał:

to jest tylko część 
nie dawałem tu ustawiania zmiennych w on skript load bo w tym były jeszcze inne zmienne

Nie musiał Pan wysyłać całego skryptu. Wystarczy przecież tylko porównać zawartość listy {dragons::*} z nazwą klikniętego inwentarza.

W dniu 4.05.2024 o 10:55, Kormic napisał:

Oczywiście najlepsza i jedyna metoda debuggingu to wysyłanie wiadomości na czacie. Niech Pan sprawdzi wszystkie kluczowe zmienne i wyrażenia, które Pan wykorzystuje w tym skrypcie. Jest szansa, że Pan zauważy jakąś nieprawidłowość.

Proszę zrobić tak jak wcześniej sugerowałem. Niech Pan przed warunkiem 'if {dragons::*} contains name of event-inventory:' wypisze na czacie zawartość listy {dragons::*} i 'name of clicked inventory'.
Skoro zdarzenie nie jest anulowane, powodem tego musi być brak spełnienia powyższego warunku.

Odnośnik do komentarza
https://skript.pl/temat/57469-problem-z-cancel-event/#findComment-342292
Udostępnij na innych stronach

Dołącz do dyskusji

Możesz dodać zawartość już teraz a zarejestrować się później. Jeśli posiadasz już konto, zaloguj się aby dodać zawartość za jego pomocą.

Nieaktywny
Odpowiedz na pytanie...

×   Wklejono zawartość z formatowaniem.   Usuń formatowanie

  Dozwolonych jest tylko 75 emoji.

×   Odnośnik został automatycznie osadzony.   Przywróć wyświetlanie jako odnośnik

×   Przywrócono poprzednią zawartość.   Wyczyść edytor

×   Nie możesz bezpośrednio wkleić grafiki. Dodaj lub załącz grafiki z adresu URL.

  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...