Aller au contenu
  • 0

Optimisation..


Question

Posté(e)

Bonjour/Bonsoir,

 

Pour mon serveur Minecraft, j'ai fait un skript pour qu'ils puissent vendre tout leurs items en restant à leurs base. Je voudrais juste savoir si je peux optimiser ou évité quelques bugs, car je ne suis qu'un débutant en skript

command /shop:
   executable by: players
   Permission: shop.sk
   Permission message: &cTu n'as pas la permission, appelle un membre du staff.
   description: ...
   trigger:
       wait 2 ticks
       open chest with 3 rows named "Coffre Shop" to player
       wait 1 ticks
       format slot 0 of player with 1 white stained glass pane named " " to close
       format slot 1 of player with 1 white stained glass pane named " " to close
       format slot 2 of player with 1 white stained glass pane named " " to close
       format slot 3 of player with 1 white stained glass pane named " " to close
       format slot 4 of player with 1 white stained glass pane named " " to close
       format slot 5 of player with 1 white stained glass pane named " " to close
       format slot 6 of player with 1 white stained glass pane named " " to close
       format slot 7 of player with 1 white stained glass pane named " " to close
       format slot 8 of player with 1 white stained glass pane named " " to close
       format slot 9 of player with 1 white stained glass pane named " " to close
       format slot 10 of player with 1 white stained glass pane named " " to close
       format slot 11 of player with 1 golden ingot named "&9Vendre" to close then run [make player execute command "/sell.1"]
       format slot 12 of player with 1 white stained glass pane named " " to close
       format slot 13 of player with 1 white stained glass pane named " " to close
       format slot 14 of player with 1 white stained glass pane named " " to close
       format slot 15 of player with 1 white stained glass pane named " " to close
       format slot 16 of player with 1 eye of ender named "Téléportation" to close then run [make player execute command "/warp shop"]
       format slot 17 of player with 1 white stained glass pane named " " to close
       format slot 18 of player with 1 white stained glass pane named " " to close
       format slot 19 of player with 1 white stained glass pane named " " to close
       format slot 20 of player with 1 white stained glass pane named " " to close
       format slot 21 of player with 1 white stained glass pane named " " to close
       format slot 22 of player with 1 white stained glass pane named " " to close
       format slot 23 of player with 1 white stained glass pane named " " to close
       format slot 24 of player with 1 white stained glass pane named " " to close
       format slot 25 of player with 1 white stained glass pane named " " to close
       format slot 26 of player with 1 white stained glass pane named " " to close

 

1501479248-shop.png

 

L'oeil sert à ce téléporter au shop et le lingot sert pour vendre les choses de sa position.

 

Tout les lignes de skript qui va suivre seront pour continué vers la vente.

 

 

command /sell.1:
   trigger:
       wait 2 ticks
       open chest with 3 rows named "tém vandre ?" to player
       wait 1 ticks
       format slot 0 of player with 1 white stained glass pane named " " to close
       format slot 1 of player with 1 white stained glass pane named " " to close
       format slot 2 of player with 1 white stained glass pane named " " to close
       format slot 3 of player with 1 white stained glass pane named " " to close
       format slot 4 of player with 1 white stained glass pane named " " to close
       format slot 5 of player with 1 white stained glass pane named " " to close
       format slot 6 of player with 1 white stained glass pane named " " to close
       format slot 7 of player with 1 white stained glass pane named " " to close
       format slot 8 of player with 1 white stained glass pane named " " to close
       format slot 9 of player with 1 white stained glass pane named " " to close
       format slot 10 of player with 1 magenta wool named "&9Blocks de couleurs" with lore "&7Liste de tout les blocks de couleurs" to close then run [make player execute command "/sell.couleurs"]
       format slot 11 of player with 1 white stained glass pane named " " to close
       format slot 12 of player with 1 white stained glass pane named " " to close
       format slot 13 of player with 1 creeper spawn egg named "&9Pillage" with lore "&7Liste des objets utiles au pillage." to close then run [make player execute command "/sell.pillage"]
       format slot 14 of player with 1 white stained glass pane named " " to close
       format slot 15 of player with 1 white stained glass pane named " " to close
       format slot 16 of player with 1 diamond named "&9Minerais" with lore "&7Liste de tout les minerais." to close then run [make player execute command "/sell.minerai"]
       format slot 17 of player with 1 white stained glass pane named " " to close
       format slot 18 of player with 1 white stained glass pane named " " to close
       format slot 19 of player with 1 white stained glass pane named " " to close
       format slot 20 of player with 1 white stained glass pane named " " to close
       format slot 21 of player with 1 white stained glass pane named " " to close
       format slot 22 of player with 1 white stained glass pane named " " to close
       format slot 23 of player with 1 white stained glass pane named " " to close
       format slot 24 of player with 1 white stained glass pane named " " to close
       format slot 25 of player with 1 white stained glass pane named " " to close
       format slot 26 of player with 1 black stained glass named "&3Page suivante" to close then run [make player execute command "/sell.2"]

1501479476-sell1.png

 

Et cela c'est pour choisir la catégories de vos items..

 

command /sell.pillage:
   trigger:
       wait 2 ticks
       open chest with 3 rows named "Coffre de pillage" to player
       wait 1 ticks
       format slot 0 of player with 1 white stained glass pane named " " to close
       format slot 1 of player with 1 white stained glass pane named " " to close
       format slot 2 of player with 1 white stained glass pane named " " to close
       format slot 3 of player with 1 white stained glass pane named " " to close
       format slot 4 of player with 1 white stained glass pane named " " to close
       format slot 5 of player with 1 white stained glass pane named " " to close
       format slot 6 of player with 1 white stained glass pane named " " to close
       format slot 7 of player with 1 white stained glass pane named " " to close
       format slot 8 of player with 1 white stained glass pane named " " to close
       format slot 9 of player with 1 white stained glass pane named " " to close
       format slot 10 of player with 8 tnt to run [make player execute command "/sell 46 8"]
       format slot 11 of player with 1 creeper spawn egg to run [make player execute command "/sell 383:50 1"]
       format slot 12 of player with 1 flint and steel to run [make player execute command "/sell 259 1"]
       format slot 13 of player with 8 sticky piston to run [make player execute command "/sell 29 8"]
       format slot 14 of player with 8 piston to run [make player execute command "/sell 33 8"]
       format slot 15 of player with 4 ender pearl to run [make player execute command "/sell 368 4"]
       format slot 16 of player with 2 boat to run [make player execute command "/sell 333 2"]
       format slot 17 of player with 1 white stained glass pane named " " to close
       format slot 18 of player with 1 white stained glass pane named " " to close
       format slot 19 of player with 1 white stained glass pane named " " to close
       format slot 20 of player with 1 white stained glass pane named " " to close
       format slot 21 of player with 1 white stained glass pane named " " to close
       format slot 22 of player with 1 white stained glass pane named " " to close
       format slot 23 of player with 1 white stained glass pane named " " to close
       format slot 24 of player with 1 white stained glass pane named " " to close
       format slot 25 of player with 1 white stained glass pane named " " to close
       format slot 26 of player with 1 white stained glass pane named " " to close

1501479727-pillage.png

 

Cela est la catégories Pillage..

Et pour terminer une dernière catégories pour être sur d'en avoir mis assez :c

 

command /sell.minerai:
   trigger:
       wait 2 ticks
       open chest with 5 rows named "Coffre de minerais" to player
       wait 1 ticks
       format slot 0 of player with 1 white stained glass pane named " " to close
       format slot 1 of player with 1 white stained glass pane named " " to close
       format slot 2 of player with 1 white stained glass pane named " " to close
       format slot 3 of player with 1 white stained glass pane named " " to close
       format slot 4 of player with 1 white stained glass pane named " " to close
       format slot 5 of player with 1 white stained glass pane named " " to close
       format slot 6 of player with 1 white stained glass pane named " " to close
       format slot 7 of player with 1 white stained glass pane named " " to close
       format slot 8 of player with 1 white stained glass pane named " " to close
       format slot 9 of player with 1 white stained glass pane named " " to close
       format slot 10 of player with 5 gold ore to run [make player execute command "/sell 14 5"]
       format slot 11 of player with 5 iron ore to run [make player execute command "/sell 15 5"]
       format slot 12 of player with 5 coal ore to run [make player execute command "/sell 16 16"]
       format slot 13 of player with 5 lapis lazuli ore to run [make player execute command "/sell 21 5"]
       format slot 14 of player with 5 diamond ore to run [make player execute command "/sell 56 5"]
       format slot 15 of player with 5 inactive redstone ore to run [make player execute command "/sell 73 5"]
       format slot 16 of player with 5 emerald ore to run [make player execute command "/sell 129 5"]
       format slot 17 of player with 1 white stained glass pane named " " to close
       format slot 18 of player with 1 white stained glass pane named " " to close
       format slot 19 of player with 2 gold ingot to run [make player execute command "/sell 266 2"]
       format slot 20 of player with 2 iron ingot to run [make player execute command "/sell 265 2"]
       format slot 21 of player with 2 coal to run [make player execute command "/sell 263 2"]
       format slot 22 of player with 2 lapis lazuli to run [make player execute command "/sell 351:4 2"]
       format slot 23 of player with 2 diamond to run [make player execute command "/sell 264 2"]
       format slot 24 of player with 2 redstone to run [make player execute command "/sell 331 2"]
       format slot 25 of player with 2 emerald to run [make player execute command "/sell 388 2"]
       format slot 26 of player with 1 white stained glass pane named " " to close
       format slot 27 of player with 1 white stained glass pane named " " to close
       format slot 28 of player with 1 block of gold to run [make player execute command "/sell 41 1"]
       format slot 29 of player with 1 block of iron to run [make player execute command "/sell 42 1"]
       format slot 30 of player with 1 block of coal to run [make player execute command "/sell 173 1"]
       format slot 31 of player with 1 lapis lazuli block to run [make player execute command "/sell 22 1"]
       format slot 32 of player with 1 block of diamond to run [make player execute command "/sell 57 1"]
       format slot 33 of player with 1 block of redstone to run [make player execute command "/sell 152 1"]
       format slot 34 of player with 1 block of emerald to run [make player execute command "/sell 133 1"]
       format slot 35 of player with 1 white stained glass pane named " " to close
       format slot 36 of player with 1 black stained glass pane named "&9Précédent" to close then run [make player execute command "/sell.1"]
       format slot 37 of player with 1 white stained glass pane named " " to close
       format slot 38 of player with 1 white stained glass pane named " " to close
       format slot 39 of player with 1 white stained glass pane named " " to close
       format slot 40 of player with 1 white stained glass pane named " " to close
       format slot 41 of player with 1 white stained glass pane named " " to close
       format slot 42 of player with 1 white stained glass pane named " " to close
       format slot 43 of player with 1 white stained glass pane named " " to close
       format slot 44 of player with 1 white stained glass pane named " " to close

1501479926-minerai.png

 

Et cela c'est la catégories Minerais..

 

Bref, excusez moi, si mon skript vous a fait mal aux yeux mais c'est mon tout premier skript :c

Je voudrais juste savoir si je devrai rajouté des choses pour éviter tout bug ou en enlever car c'est trop répétitif, merci de votre aide.. ^^

7 réponses à cette question

Messages recommandés

  • 0
Posté(e)

Tu peux également répéter une action plusieurs fois en changeant une variable, exemple

 

set {_slot} to 0

loop 20 times:

format slot {_slot} of player with 1 white stained glass pane named " " to close

add 1 to {_slot}

 

Ça répétera l'action dans le loop, ici ça remplira le slot de variable {_slot}, ensuite ça ajoutera 1 à cette variable pour ajouter 1 au numéro de l'emplacement, pour ensuite répéter 20 fois l'action (dans mon exemple)

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

Salut, juste pour m'amuser j'ai fait le principe de @Random mais en passant par une fonction.

en fait la méthode que je vais afficher ici va permettre de répondre a deux autres personnes qui mon demander une aide particulière, donc je fait une pierre de coup ^^

 

PS: j'ai utiliser Skript 2.2 et SkQuery seulment

 

function setslot(Player: player, Slot: objects, Item: item):
   loop {_Slot::*}:
       format slot loop-value of {_Player} with {_Item} named " " to close

command /shop:
   trigger:
       wait 2 ticks
       open chest with 3 rows named "Coffre Shop" to player
       wait a tick
       setslot(player, (0,1,2,3,4,5,6,7,8,9,10,12,13,14,15,17,18,19,20,21,22,23,24,25 and 26),1 white stained glass pane)
       format slot 11 of player with 1 golden ingot named "&9Vendre" with lore "&cClick pour vendre||&cde ta position" to close then run [make player execute command "/sell.1"]
       format slot 16 of player with 1 eye of ender named "&6Téléportation" with lore "&cClick pour te téléporter||&cau warp" to close then run [make player execute command "/warp shop"]

command /sell.1:
   trigger:
       wait 2 ticks
       open chest with 3 rows named "tém vandre ?" to player
       wait a tick
       setslot(player, (0,1,2,3,4,5,6,7,8,9,11,12,14,15,17,18,19,20,21,22,23,24 and 25),1 white stained glass pane)
       format slot 10 of player with 1 magenta wool named "&9Blocks de couleurs" with lore "&7Liste de tout les blocks de couleurs" to close then run [make player execute command "/sell.couleurs"]
       format slot 13 of player with 1 creeper spawn egg named "&9Pillage" with lore "&7Liste des objets utiles au pillage." to close then run [make player execute command "/sell.pillage"]
       format slot 16 of player with 1 diamond named "&9Minerais" with lore "&7Liste de tout les minerais." to close then run [make player execute command "/sell.minerai"]
       format slot 26 of player with 1 black stained glass named "&3Page suivante" to close then run [make player execute command "/sell.2"]

command /sell.pillage:
   trigger:
       wait 2 ticks
       open chest with 3 rows named "Coffre de pillage" to player
       wait a tick
       setslot(player, (0,1,2,3,4,5,6,7,8,9,17,18,19,20,21,22,23,24,25 and 26),1 white stained glass pane)
       format slot 10 of player with 8 tnt to run [make player execute command "/sell 46 8"]
       format slot 11 of player with 1 creeper spawn egg to run [make player execute command "/sell 383:50 1"]
       format slot 12 of player with 1 flint and steel to run [make player execute command "/sell 259 1"]
       format slot 13 of player with 8 sticky piston to run [make player execute command "/sell 29 8"]
       format slot 14 of player with 8 piston to run [make player execute command "/sell 33 8"]
       format slot 15 of player with 4 ender pearl to run [make player execute command "/sell 368 4"]
       format slot 16 of player with 2 boat to run [make player execute command "/sell 333 2"]

command /sell.minerai:
   trigger:
       wait 2 ticks
       open chest with 5 rows named "Coffre de minerais" to player
       wait 1 ticks
       setslot(player, (0,1,2,3,4,5,6,7,8,9,17,18,26,27,35,37,38,39,40,41,42,43 and 44),1 white stained glass pane)
       format slot 10 of player with 5 gold ore to run [make player execute command "/sell 14 5"]
       format slot 11 of player with 5 iron ore to run [make player execute command "/sell 15 5"]
       format slot 12 of player with 5 coal ore to run [make player execute command "/sell 16 16"]
       format slot 13 of player with 5 lapis lazuli ore to run [make player execute command "/sell 21 5"]
       format slot 14 of player with 5 diamond ore to run [make player execute command "/sell 56 5"]
       format slot 15 of player with 5 inactive redstone ore to run [make player execute command "/sell 73 5"]
       format slot 16 of player with 5 emerald ore to run [make player execute command "/sell 129 5"]
       format slot 19 of player with 2 gold ingot to run [make player execute command "/sell 266 2"]
       format slot 20 of player with 2 iron ingot to run [make player execute command "/sell 265 2"]
       format slot 21 of player with 2 coal to run [make player execute command "/sell 263 2"]
       format slot 22 of player with 2 lapis lazuli to run [make player execute command "/sell 351:4 2"]
       format slot 23 of player with 2 diamond to run [make player execute command "/sell 264 2"]
       format slot 24 of player with 2 redstone to run [make player execute command "/sell 331 2"]
       format slot 25 of player with 2 emerald to run [make player execute command "/sell 388 2"]
       format slot 28 of player with 1 block of gold to run [make player execute command "/sell 41 1"]
       format slot 29 of player with 1 block of iron to run [make player execute command "/sell 42 1"]
       format slot 30 of player with 1 block of coal to run [make player execute command "/sell 173 1"]
       format slot 31 of player with 1 lapis lazuli block to run [make player execute command "/sell 22 1"]
       format slot 32 of player with 1 block of diamond to run [make player execute command "/sell 57 1"]
       format slot 33 of player with 1 block of redstone to run [make player execute command "/sell 152 1"]
       format slot 34 of player with 1 block of emerald to run [make player execute command "/sell 133 1"]
       format slot 36 of player with 1 black stained glass pane named "&9Précédent" to close then run [make player execute command "/sell.1"]

 

Voila ton code ce voie alèger de quelque dizaine de ligne pour le même résultat ;)

si tu veux des explication sur comment fonctionne la fonction, hésite pas, mais bon sa me parais compréhensible :)

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

Pareil que le voisin du dessus à la différence que j'utilise pas de variable mais des maths.

 

    loop 27 times:          # ou loop integer between 0 and 26
       format slot ( loop-number + -1) of player with 1 white stained glass pane named " " to close #loop-number commence à 1 donc on retire 1 pour que cela commence à 0 et finisse à 26, simple soustraction mathématique.

       #Puisque ton ton inventaire est rempli de vitre blanche il faut maintenant placer tes items utiles
       format slot 11 of player with 1 golden ingot named "&9Vendre" to close then run [make player execute command "/sell.1"]
       format slot 16 of player with 1 eye of ender named "Téléportation" to close then run [make player execute command "/warp shop"]

       #Tout ton code se ressemble donc tu fais ça a chaque fois et le tour est joué !

  • 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.