Skocz do zawartości
  • 0

problem z zmiennymi w stwierdzeniach if


Pytanie

mam mały problem z skryptem

robię skript na 1v1 i 1v1 poczekalnię

on inventory click:
  if name of event-inventory is "Normal Queue":
    cancel event
    if index of event-slot is 0:
      if {queued.%player%} is 0:
        send "0" to player
        set {queued.%player%} to 1
      if {queued.%player%} is not set:
        send "not set" to player
        set {queued.%player%} to 1
      if {queued.%player%} is 1:
        send "1" to player
        set {queued.%player%} to 0
variables:
  {queued.%player%} = 0

 

nie wyskakują żadne errory

jak ktoś kliknie pierwszy raz (if ... is not set) to wtedy wyskoczy 0 i 1 (a powinno wyskoczyć tylko 0)

jak kliknie znowu i jest 0, to wtedy wyskoczy rowniez 0 i 1 (a powinno wyskoczyć tylko 0)

a jak jest 1 to powinno wyskoczyć tylko 1

 

czyli widocznie sprawdza od razu czy {queued.%player%} wynosi 1, i wtedy robi se taki loop z stwierdzeniami

 

jak mogę inaczej to zrobić? i jak możecie to przyślijcie kod na to.

jak potrzebujecie cały kod mój to przyślę

Odnośnik do komentarza
https://skript.pl/temat/53977-problem-z-zmiennymi-w-stwierdzeniach-if/
Udostępnij na innych stronach

4 odpowiedzi na to pytanie

Rekomendowane odpowiedzi

  • 0
variables:
  {queued.%player%} = 0
  {playing.%player%} = 0

options:
  accent: <##ff0000>
  main: &6
  error: &c
  success: &a
  other: &7

command /skriptqueue <string> [<string>] [<string>]:
  trigger:
    if arg-1 is "normal":
      if arg-2 is "join":
        if arg-3 is "axe":
          if {queued.%player%} is 1:
            send "{@error}You're already queued!" to player
          else:
            set {queued.%player%} to 1
            send "{@success}Added to {@main}axe {@success}queue!" to player
      if arg-2 is "leave":
        if {queued.%player%} is 1:
          set {queued.%player%} to 0
          send "{@error}Left {@main}axe {@error}queue!" to player
      if arg-2 is not set:
        set {_gui} to chest inventory with 3 rows named "Normal Queue"
        open {_gui} to player
        set slot 0 of {_gui} to shield named "<##ff0000>&lAxe" with lore " " and " {@other}› {@accent}Queued {@other}→ {@main}%{queued.%player%}%" and "   {@other}➥ {@accent}Playing {@other}→ {@main}%{playing.%player%}%" and " " and "{@accent}Click to {@main}Queue"

on inventory click:
  if name of event-inventory is "Normal Queue":
    cancel event
    if index of event-slot is 0:
      if {queued.%player%} is 0:
        send "0" to player
        set {queued.%player%} to 1
      if {queued.%player%} is not set:
        send "not set" to player
        set {queued.%player%} to 1
      if {queued.%player%} is 1:
        send "1" to player
        set {queued.%player%} to 0

 

albo nie, prześlę ten cały kod lepiej bo będą osoby płakać o ten kod xdd

Odnośnik do komentarza
https://skript.pl/temat/53977-problem-z-zmiennymi-w-stwierdzeniach-if/#findComment-328012
Udostępnij na innych stronach

  • 1

Przeanalizuj twój kod, co tam się dzieje

    if index of event-slot is 0: 
      if {queued.%player%} is 0: # sprawdza czy zmienna to 0
        send "0" to player # wysyla 0
        set {queued.%player%} to 1 #ustawia zmienna na 1
      if {queued.%player%} is not set: #sprawdza czy zmienna nie jest ustawiona, warunek nie jest spełniony bo ustawiłeś ją na 1
        send "not set" to player
        set {queued.%player%} to 1
      if {queued.%player%} is 1: #warunek się sprawdza, bo ustawiłeś zmienną na 1
        send "1" to player # wysyla 1
        set {queued.%player%} to 0 #ustawia na 0

najprociej zrobić if ... is 0: else if ... is 1:

Odnośnik do komentarza
https://skript.pl/temat/53977-problem-z-zmiennymi-w-stwierdzeniach-if/#findComment-328016
Udostępnij na innych stronach

  • 0

dzk, else if zadziałało

jak ktoś potrzebuje kod (bo wiem że niektórzy szukają takie queue gui rzeczy) (czyli ja)

 

variables:
  {queue.%player%} = 0
  {playing.%player%} = 0

options:
  czerwony: <##ff0000>
  zloty: &6
  blad: &c
  sukces: &a
  inny: &7

command /queue <string> [<string>] [<string>]:
  trigger:
    if arg-1 is "normal":
      if arg-2 is "join":
        if arg-3 is "axe":
          if {queue.%player%} is 1:
            send "{@blad}You're already queued!" to player
          else:
            set {queue.%player%} to 1
            send "{@sukces}Added to {@zloty}axe {@sukces}queue!" to player
      if arg-2 is "leave":
        if {queue.%player%} is 1:
          set {queue.%player%} to 0
          send "{@blad}Left {@zloty}axe {@blad}queue!" to player
      if arg-2 is not set:
        set {_gui} to chest inventory with 3 rows named "Normal Queue"
        open {_gui} to player
        set slot 0 of {_gui} to shield named "{@czerwony}&lAxe" with lore " " and " {@inny}› {@czerwony}Queued {@inny}→ {@zloty}%{queue.%player%}%" and "   {@inny}➥ {@czerwony}Playing {@inny}→ {@zloty}%{playing.%player%}%" and " " and "{@czerwony}Click to {@zloty}Queue"

on inventory click:
  if name of event-inventory is "Normal Queue":
    cancel event
    if index of event-slot is 0:
      if {queue.%player%} is 0:
        send "set to 1" to player
        wait 1 second
        set {queue.%player%} to 1
      else if {queue.%player%} is 1:
        send "reset" to player
        wait 1 second
        set {queue.%player%} to 0

 

Odnośnik do komentarza
https://skript.pl/temat/53977-problem-z-zmiennymi-w-stwierdzeniach-if/#findComment-328019
Udostępnij na innych stronach

Nieaktywny
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
  • Ostatnio przeglądający   0 użytkowników

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