Aller au contenu
  • 0

Bloquer une action si une commande = 1


Question

Posté(e)

Bonjour, je souhaite que lorsque un membre du staff fait un /ctf start, ça execute des actions et set une variable à 1, et si cette variable vaut 1 alors lorsqu'on refait la même commande ça nous indique qu'une partie est déjà en cours.

et en faisait un /ctf finish ça nous remet la variable à 0 donc nous permet de redémarrer une partie.

Mais j'ai plusieurs erreur:

- Lorsque je fais un /ctf start, celui qui execute la commande n'est pas tp mais mon pote est tp.

- Si je fais un /ctf start une deuxième fois ça m'affiche http://prntscr.com/e1eoaq alors que je suis bien dans le hub.

 

Comment faire ?

 

voilà mon code:

    if argument 1 is "start":
           player has permission "admin.ctf":
               set {_n} to false
               loop all players:
                   if "%region at loop-player%" contains "hubctf":
                       if {etatctf} = 0:
                           broadcast "&7> La partie commence !"
                           set {startctf} to "&aEn cours"
                           set {etatctf} to 1
                           if {_n} is false:
                               set {team.%loop-player%} to "red"
                               teleport loop-player to {spawnred}
                               set {_n} to true
                               equip loop-player with leather cap
                               equip loop-player with iron chestplate
                               equip loop-player with iron leggings
                               equip loop-player with iron boots
                               wait 5 ticks
                               dye the loop-player's helmet red
                           else:
                               set {team.%loop-player%} to "blue"
                               teleport loop-player to {spawnblue}
                               set {_n} to false
                               equip loop-player with leather cap
                               equip loop-player with iron chestplate
                               equip loop-player with iron leggings
                               equip loop-player with iron boots
                               wait 5 ticks
                               dye the loop-player's helmet blue
                       if {etatctf} = 1:
                           send "&7> Une partie est déjà en cours !" to player
                   else:
                       send "&7> Vous devez être dans le hub pour lancer le CTF !" to player
       if argument 1 is "finish":
           player has permission "admin.ctf":
               broadcast "&7> La partie est terminé !"
               set {startctf} to "&cEn attente"
               set {etatctf} to 0

  • J'aime 1

5 réponses à cette question

Messages recommandés

  • 0
Posté(e)

Pour bloquer la commande il faut mettre le " if " avant le loop.

   if player has permission "admin.ctf":
      if arg 1 is "start":
        if {etatctf} is true:
          send "&7> Une partie est déjà en cours !" to player
          stop
        set {_n} to false
        loop all players:
          if "%region at loop-player%" contains "hubctf":
            if {etatctf} is not set:
              broadcast "&7> La partie commence !"
              set {startctf} to "&aEn cours"
              set {etatctf} to true
              if {_n} is false:
                set {team.%loop-player%} to "red"
                teleport loop-player to {spawnred}
                set {_n} to true
                equip loop-player with leather cap
                equip loop-player with iron chestplate
                equip loop-player with iron leggings
                equip loop-player with iron boots
                wait 5 ticks
                dye the loop-player's helmet red
              else:
                set {team.%loop-player%} to "blue"
                teleport loop-player to {spawnblue}
                set {_n} to false
                equip loop-player with leather cap
                equip loop-player with iron chestplate
                equip loop-player with iron leggings
                equip loop-player with iron boots
                wait 5 ticks
                dye the loop-player's helmet blue
          else:
            send "&7> Vous devez être dans le hub pour lancer le CTF !" to player
      if arg 1 is "finish":
        broadcast "&7> La partie est terminé !"
        set {startctf} to "&cEn attente"
        clear {etatctf}

 

Après pour ton problème de téléportation, je ne sais pas, ça fonctionne chez moi.

  • 0
Posté(e)

Voilà :):

   if argument 1 is "start":
       player has permission "admin.ctf":
           if {etatctf} = 1:
                   send "&7> Une partie est déjà en cours !" to player
           else if {etatctf} = 0:
               broadcast "&7> La partie commence !"
               set {_n} to false
               set {startctf} to "&aEn cours"
               set {etatctf} to 1
               loop all players:
                   if "%region at loop-player%" contains "hubctf
                       if {_n} is false:
                           set {team.%loop-player%} to "red"
                           teleport loop-player to {spawnred}
                           set {_n} to true
                           equip loop-player with leather cap
                           equip loop-player with iron chestplate
                           equip loop-player with iron leggings
                           equip loop-player with iron boots
                           wait 5 ticks
                           dye the loop-player's helmet red
                       else if {_n} is true:
                           set {team.%loop-player%} to "blue"
                           teleport loop-player to {spawnblue}                       
                           set {_n} to false
                           equip loop-player with leather cap
                           equip loop-player with iron chestplate
                           equip loop-player with iron leggings
                           equip loop-player with iron boots
                           wait 5 ticks
                           dye the loop-player's helmet bluer
                   else:
                       send "&7> Vous devez être dans le hub pour lancer le CTF !" to player
       if argument 1 is "finish":
           player has permission "admin.ctf":
               broadcast "&7> La partie est terminé !"
               set {startctf} to "&cEn attente"
               set {etatctf} to 0

 

Met un j'aime si je t'ai aidé, et dit moi si ça marche ;)

  • J'aime 2
  • 0
Posté(e)

Désolé, revoilà le code corrigé:

    if argument 1 is "start":
       player has permission "admin.ctf":
           if {etatctf} = 1:
                   send "&7> Une partie est déjà en cours !" to player
           else if {etatctf} = 0:
               if "%region at loop-player%" contains "hubctf":
                   broadcast "&7> La partie commence !"
                   set {_n} to false
                   set {startctf} to "&aEn cours"
                   set {etatctf} to 1
                   loop all players:
                       if {_n} is false:
                           set {team.%loop-player%} to "red"
                           teleport loop-player to {spawnred}
                           set {_n} to true
                           equip loop-player with leather cap
                           equip loop-player with iron chestplate
                           equip loop-player with iron leggings
                           equip loop-player with iron boots
                           wait 5 ticks
                           dye the loop-player's helmet red #'
                       else if {_n} is true:
                           set {team.%loop-player%} to "blue"
                           teleport loop-player to {spawnblue}                   
                           set {_n} to false
                           equip loop-player with leather cap
                           equip loop-player with iron chestplate
                           equip loop-player with iron leggings
                           equip loop-player with iron boots
                           wait 5 ticks
                           dye the loop-player's helmet blue #'
       if argument 1 is "finish":
           player has permission "admin.ctf":
               broadcast "&7> La partie est terminé !"
               set {startctf} to "&cEn attente"
               set {etatctf} to 0

 

Je t'ai aidé? Clique sur "J'aime"

  • J'aime 1
×
×
  • Créer...

Information importante

Nous avons placé des cookies sur votre appareil pour aider à améliorer ce site. Vous pouvez choisir d’ajuster vos paramètres de cookie, sinon nous supposerons que vous êtes d’accord pour continuer.