Aller au contenu

Faire une boutique automatisée (GUI entre autres) [PART 2/2]


Messages recommandés

Posté(e)

(Suite du code précédent)

        else if arg 1 is objets: #Lorsque le joueur fait la commande /menu objets, on affiche un nouveau menu pour vendre des objets, a vous de jouer pour le modifier !

[indent]        wait 1 ticks
       open chest with 6 rows named "&8Objets :" to player
       wait 2 ticks
       format slot 0 of player with white glass named " " to be unstealable
       format slot 1 of player with white glass named " " to be unstealable
       format slot 2 of player with white glass named " " to be unstealable
       format slot 3 of player with white glass named " " to be unstealable
       format slot 4 of player with white glass named " " to be unstealable
       format slot 5 of player with white glass named " " to be unstealable
       format slot 6 of player with white glass named " " to be unstealable
       format slot 7 of player with white glass named " " to be unstealable
       format slot 8 of player with white glass named " " to be unstealable
       format slot 9 of player with white glass named " " to be unstealable
       format slot 17 of player with white glass named " " to be unstealable
       format slot 18 of player with white glass named " " to be unstealable
       format slot 26 of player with white glass named " " to be unstealable
       format slot 27 of player with white glass named " " to be unstealable
       format slot 35 of player with white glass named " " to be unstealable
       format slot 36 of player with white glass named " " to be unstealable
       format slot 44 of player with white glass named " " to be unstealable
       format slot 45 of player with white glass named " " to be unstealable
       format slot 46 of player with white glass named " " to be unstealable
       format slot 47 of player with white glass named " " to be unstealable
       format slot 48 of player with white glass named " " to be unstealable
       format slot 49 of player with white glass named " " to be unstealable
       format slot 50 of player with white glass named " " to be unstealable
       format slot 51 of player with white glass named " " to be unstealable
       format slot 52 of player with white glass named " " to be unstealable
       format slot 53 of player with white glass named " " to be unstealable
format slot 10 of player with iron ingot named "&7Lingot de Fer" with lore "&a15 Points Boutiques||&81 Lingot de Fer" to close then run "sudo %player% achat 1#Pour faire un saut de ligne dans la description d'objet (lore), faites "||" ![/indent]


Comme vous l'aurez constaté, on fait apparaître une nouvelle commande : /achat !

Celle ci nous permettra de déclencher l'achat de l'objet !

 

Maintenant, commençons à la coder.

command /achat <number>:
   trigger:
       if arg 1 is 1: #Si l'argument 1 est 1 (définit par le lingot de fer)
           if {%player%.pointsBoutiques.compte} > 15 #Si le joueur a plus de 15 points boutiques
               give 1 iron ingot to player #On lui donne un lingot de fer (vous pouvez lui rajouter un nom , une description et des enchantements bien
               add -15 to {%player%.pointsBoutiques.compte} #On retire 15 points au compte du joueur
           else: #Si le joueur n'a pas le nombre de points boutiques suffisant
               message "&cVous n'avez pas assez de points boutique"

 

Voila ! Maintenant le joueur pourra acheter son lingot de fer !

 

Note : Vous pouvez tout a fait rajouter des objets en rajoutant 1 a l'argument dans la commande !

 

a) Le menu grades

Bon, maintenant on s'attaque au menu des grades. On va du coup continuer la commande /menu

et y ajouter l'argument "grades" !

    else if arg 1 is "grades":
       wait 1 ticks
       open chest with 6 rows named "Récompenses :" to player
       wait 2 ticks
       format slot 0 of player with white glass named " " to be unstealable
       format slot 1 of player with white glass named " " to be unstealable
       format slot 2 of player with white glass named " " to be unstealable
       format slot 3 of player with white glass named " " to be unstealable
       format slot 4 of player with white glass named " " to be unstealable
       format slot 5 of player with white glass named " " to be unstealable
       format slot 6 of player with white glass named " " to be unstealable
       format slot 7 of player with white glass named " " to be unstealable
       format slot 8 of player with white glass named " " to be unstealable
       format slot 9 of player with white glass named " " to be unstealable
       format slot 17 of player with white glass named " " to be unstealable
       format slot 18 of player with white glass named " " to be unstealable
       format slot 26 of player with white glass named " " to be unstealable
       format slot 27 of player with white glass named " " to be unstealable
       format slot 35 of player with white glass named " " to be unstealable
       format slot 36 of player with white glass named " " to be unstealable
       format slot 44 of player with white glass named " " to be unstealable
       format slot 45 of player with white glass named " " to be unstealable
       format slot 46 of player with white glass named " " to be unstealable
       format slot 47 of player with white glass named " " to be unstealable
       format slot 48 of player with white glass named " " to be unstealable
       format slot 49 of player with white glass named " " to be unstealable
       format slot 50 of player with white glass named " " to be unstealable
     format slot 51 of player with white glass named " " to be unstealable
       format slot 52 of player with white glass named " " to be unstealable
       format slot 53 of player with white glass named " " to be unstealable
       format slot 10 of player with iron chestplate named "&8VIP" with lore "&a500 Points Boutiques" to close then run "sudo %player% grade 1"#Grade vip disponible pour 500 Points boutiques 

 

Bon, comme pour les objets, on va maintenant créer la commande /grade <number> !

Motivation motivation ! On y est presque les amis ! (Exception pour ceux qui ont 50 objets et 15 grades, et pour qui je demande 1 minute de silence svp)

Mais bon, on le sait, skripter demande quand même du temps et du travail !

command /grade <number>:
   trigger: #Comme avant, ajoutez votre permission si nécessaire
       if arg 1 is 1:
           if {%player%.pointsBoutique.compte} > 500:
               execute console command "Votre permission sans "/" selon votre plugin"
               message "&bVous avez acheté le grade VIP !"
               add -500 to {%player%.pointsBoutiques.compte}
           else:
               message "&cVous n'avez pas assez de points boutiques"

 

Pfiou ! Sacré bout de texte n'est-ce pas ! Mais c'est bon, vous savez (presque) tout sur le GUI et l'édition de variable attitrée à un joueur en particulier !

ATTENTION : Il est très très très très probable que j'eusse fait quelques erreurs, cependant le sens du code y est, et ces quelques erreurs seront sûrement dûe à une faute de frappe, d'indentation ou de léger oubli.

N'hésitez pas à poster vos conseils/améliorations en commentaire, je me ferai un plaisir d'améliorer mon tuto ! Sur ce , merci d'avoir lu ce roman ;D et je vous souhaite une bonne journée !

 

 

Nicoszpako

  • 3 semaines après...
Posté(e)

Bonjour,

Très bon tutoriel selon moi !

Très bien expliqué et bien rédigé.

 

PS: Saurais tu comment ouvrir un GUI a partir d'un item se trouvant dans un autre GUI ? Cela pourrait être intéressant .

Posté(e)

Non merci mais si je demande ça c'est pour qu'il l'ajouter dans son tutoriel ^^

Perso je code plus beaucoup donc ça m'importe peu :')

Posté(e)

@iziix Pour aller d'un gui a l'autre oublier pas les wait 4 ticks et wait 2 ticks

command /test:
   trigger
       wait 4 ticks
       open chest with 6 rows named "Récompenses :" to player
       wait 2 ticks
       format slot 0 of player with stone named "Aller a test1" to close then run [make player execute "/test1"]

command /test1:
   trigger
       wait 4 ticks
       open chest with 6 rows named "Récompenses :" to player
       wait 2 ticks
       format slot 0 of player with diamond named "Aller a test " to close then run [make player execute "/test"]

 

 

 

@nicoszpako

 

Il faut utilier des loop times

 

comme ceci

        open chest with 6 rows named "&8Objets :" to player
       wait 2 ticks
       loop 53 times:
           format slot loop-number of player with white glass named " " to be unstealable
       format slot 10 of player with iron ingot named "&7Lingot de Fer" with lore "&a15 Points Boutiques||&81 Lingot de Fer" to close then run "sudo %player% achat 1#Pour faire un saut de ligne dans la description d'objet (lore), faites "||" !

Posté(e)

Salut ! J'ai des erreurs niveaux variables pour le /grade :/ Que soit-disant ce n'est pas une entitée de type.. Aide-moi s'il te plait? :( (Les : {%arg-3%.pointsBoutiques.compte})

Posté(e)
@iziix Pour aller d'un gui a l'autre oublier pas les wait 4 ticks et wait 2 ticks

command /test:
   trigger
       wait 4 ticks
       open chest with 6 rows named "Récompenses :" to player
       wait 2 ticks
       format slot 0 of player with stone named "Aller a test1" to close then run [make player execute "/test1"]

command /test1:
   trigger
       wait 4 ticks
       open chest with 6 rows named "Récompenses :" to player
       wait 2 ticks
       format slot 0 of player with diamond named "Aller a test " to close then run [make player execute "/test"]

 

 

 

@nicoszpako

 

Il faut utilier des loop times

 

comme ceci

        open chest with 6 rows named "&8Objets :" to player
       wait 2 ticks
       loop 53 times:
           format slot loop-number of player with white glass named " " to be unstealable
       format slot 10 of player with iron ingot named "&7Lingot de Fer" with lore "&a15 Points Boutiques||&81 Lingot de Fer" to close then run "sudo %player% achat 1#Pour faire un saut de ligne dans la description d'objet (lore), faites "||" !

 

Sauf que moi je veux juste un cadre décoratif =)

Avec ca tu me remplis tout l'inventaire

Posté(e)
Ah bon ?

Bah oui ^^ Regarde mon code, je ne fais que les lignes dessus/dessous et les extrémités :D

Mais merci de ton message, je le garde sous la dent au cas où :D

Créer un compte ou se connecter pour commenter

Vous devez être membre afin de pouvoir déposer un commentaire

Créer un compte

Créez un compte sur notre communauté. C’est facile !

Créer un nouveau compte

Se connecter

Vous avez déjà un compte ? Connectez-vous ici.

Connectez-vous maintenant
×
×
  • 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.