Aller au contenu
  • 0

Remplissage auto loot chests


Question

Posté(e)

Bonjour, je suis débutant en Skript et j'aimerai savoir s'il est possible de réutiliser la commande "refill" du Skript pour l'exécuter automatiquement tout les X minutes, et si possible avec un compte à rebours.

J'utilise la dernière version de Script et de Spigot 1.12

 

Merci d'avance pour votre aide !! :)

 

options:
   prefix: &bLootChest >
   perm: is.admin
   noperm: &cYou don't have the permission to do that!
   minitems: 6
   maxitems: 11
   version: 1.0

on load:
   clear {ritem::*}
   add 8 snowballs to {ritem::*}
   add 16 eggs to {ritem::*}
   add 32 eggs to {ritem::*}
   add 8 eggs to {ritem::*}
   add iron sword to {ritem::*}
   add iron helmet to {ritem::*}
   add iron chestplate to {ritem::*}
   add iron leggings to {ritem::*}
   add iron boots to {ritem::*}
   add diamond chestplate to {ritem::*}
   add diamond helmet to {ritem::*}
   add diamond leggings to {ritem::*}
   add diamond boots to {ritem::*}
   add 32 arrow to {ritem::*}
   add 16 arrow to {ritem::*}
   add 24 arrow to {ritem::*}
   add 32 stone to {ritem::*}
   add 16 stone to {ritem::*}
   add 24 bricks to {ritem::*}
   add 32 bricks to {ritem::*}
   add shield to {ritem::*}
   add bow to {ritem::*}
   add leather boots to {ritem::*}
   add leather helmet to {ritem::*}
   add leather chestplate to {ritem::*}
   add leather leggings to {ritem::*}
   add 16 snowballs to {ritem::*}
   add 32 snowballs to {ritem::*}
   add 1 golden apple to {ritem::*}
   add 2 golden apple to {ritem::*}
   add 4 golden apple to {ritem::*}
   add 32 oak planks to {ritem::*}
   add 16 oak planks to {ritem::*}
   add 64 oak planks to {ritem::*}
   add 1 ender pearl to {ritem::*}
   add 2 ender pearl to {ritem::*}
   add 32 experience bottle to {ritem::*}
   add 64 experience bottle to {ritem::*}
   add water_bottle:8194 to {ritem::*}
   add water_bottle:8201 to {ritem::*}
   add 2 diamond to {ritem::*}

   set {twd.lootchest.last_refill} to now
   broadcast "&bChests have been refilled"
   loop {cheloc::*}:
       set {_cheslot::*} to ""
       loop 27 times:
           add loop-number to {_slotnum::*}
       clear inventory of block at loop-value
       wait 1 tick
       set {_loop} to a random integer between {@minitems} and {@maxitems}
       loop {_loop} times:
           set {_cheitem} to a random element out of {ritem::*}
           set {_cheslot} to a random element out of {_slotnum::*}
           add {_cheitem} to slot ({_cheslot} - 1) of block at loop-value-1

command /lootchest [<text>]:
   trigger:
       if arg 1 is "add":
           if player has permission "{@perm}":
               if target block is chest:
                   loop {cheloc::*}:
                       if loop-value is location of target block:
                           message "{@prefix} This chest has already been checked as a mCHEST!"
                           stop
                   add location of target block to {cheloc::*}
                   message "{@prefix} Succesfully executed &3AddChest"
               else:
                   message "&b{@prefix} You need to select a chest!"
           else:
               message "{@noperm}"

       if arg 1 is "remove":
           if player has permission "{@perm}":
               if target block is a chest or stone:
                   remove location of target block from {cheloc::*}
                   message "{@prefix} Succesfully removed the selected chest!"
                   clear inventory of target block
                   stop
               else:
                   message "{@prefix} You need to select a chest!"
           else:
               message "{@noperm}"

       if arg 1 is "refill":
           if player has permission "{@perm}":
               set {twd.lootchest.last_refill} to now
               broadcast "&b&3Chests refilled in 3s"
               wait 1 second
               broadcast "&b&3Chests refilled in 2s"
               wait 1 second
               broadcast "&b&3Chests refilled in 1s"
               wait 1 second
               broadcast "&bChests have been refilled"
               loop {cheloc::*}:
                   set {_cheslot::*} to ""
                   loop 27 times:
                       add loop-number to {_slotnum::*}
                   clear inventory of block at loop-value
                   wait 1 tick
                   set {_loop} to a random integer between {@minitems} and {@maxitems}
                   loop {_loop} times:
                       set {_cheitem} to a random element out of {ritem::*}
                       set {_cheslot} to a random element out of {_slotnum::*}
                       add {_cheitem} to slot ({_cheslot} - 1) of block at loop-value-1
           else:
               message "{@noperm}"

       if arg 1 is "about" OR "version":
           message "&3&lmChests &r&b> Currently running version &3{@version}"

       if arg 1 is not set:
           if player has permission "{@perm}":
               message "{@prefix} You need to specify a command! Usage: /mchest <add/remove/refill>"
           else:
               message "{@noperm}"
every 300 second:
   make console execute command "/lootchest refill" as op

9 réponses à cette question

Messages recommandés

  • 0
Posté(e)
Bonjour, je suis débutant en Skript et j'aimerai savoir s'il est possible de réutiliser la commande "refill" du Skript pour l'exécuter automatiquement tout les X minutes, et si possible avec un compte à rebours.

J'utilise la dernière version de Script et de Spigot 1.12

 

Merci d'avance pour votre aide !! :)

 

options:
   prefix: &bLootChest >
   perm: is.admin
   noperm: &cYou don't have the permission to do that!
   minitems: 6
   maxitems: 11
   version: 1.0

on load:
   clear {ritem::*}
   add 8 snowballs to {ritem::*}
   add 16 eggs to {ritem::*}
   add 32 eggs to {ritem::*}
   add 8 eggs to {ritem::*}
   add iron sword to {ritem::*}
   add iron helmet to {ritem::*}
   add iron chestplate to {ritem::*}
   add iron leggings to {ritem::*}
   add iron boots to {ritem::*}
   add diamond chestplate to {ritem::*}
   add diamond helmet to {ritem::*}
   add diamond leggings to {ritem::*}
   add diamond boots to {ritem::*}
   add 32 arrow to {ritem::*}
   add 16 arrow to {ritem::*}
   add 24 arrow to {ritem::*}
   add 32 stone to {ritem::*}
   add 16 stone to {ritem::*}
   add 24 bricks to {ritem::*}
   add 32 bricks to {ritem::*}
   add shield to {ritem::*}
   add bow to {ritem::*}
   add leather boots to {ritem::*}
   add leather helmet to {ritem::*}
   add leather chestplate to {ritem::*}
   add leather leggings to {ritem::*}
   add 16 snowballs to {ritem::*}
   add 32 snowballs to {ritem::*}
   add 1 golden apple to {ritem::*}
   add 2 golden apple to {ritem::*}
   add 4 golden apple to {ritem::*}
   add 32 oak planks to {ritem::*}
   add 16 oak planks to {ritem::*}
   add 64 oak planks to {ritem::*}
   add 1 ender pearl to {ritem::*}
   add 2 ender pearl to {ritem::*}
   add 32 experience bottle to {ritem::*}
   add 64 experience bottle to {ritem::*}
   add water_bottle:8194 to {ritem::*}
   add water_bottle:8201 to {ritem::*}
   add 2 diamond to {ritem::*}

   set {twd.lootchest.last_refill} to now
   broadcast "&bChests have been refilled"
   loop {cheloc::*}:
       set {_cheslot::*} to ""
       loop 27 times:
           add loop-number to {_slotnum::*}
       clear inventory of block at loop-value
       wait 1 tick
       set {_loop} to a random integer between {@minitems} and {@maxitems}
       loop {_loop} times:
           set {_cheitem} to a random element out of {ritem::*}
           set {_cheslot} to a random element out of {_slotnum::*}
           add {_cheitem} to slot ({_cheslot} - 1) of block at loop-value-1

command /lootchest [<text>]:
   trigger:
       if arg 1 is "add":
           if player has permission "{@perm}":
               if target block is chest:
                   loop {cheloc::*}:
                       if loop-value is location of target block:
                           message "{@prefix} This chest has already been checked as a mCHEST!"
                           stop
                   add location of target block to {cheloc::*}
                   message "{@prefix} Succesfully executed &3AddChest"
               else:
                   message "&b{@prefix} You need to select a chest!"
           else:
               message "{@noperm}"

       if arg 1 is "remove":
           if player has permission "{@perm}":
               if target block is a chest or stone:
                   remove location of target block from {cheloc::*}
                   message "{@prefix} Succesfully removed the selected chest!"
                   clear inventory of target block
                   stop
               else:
                   message "{@prefix} You need to select a chest!"
           else:
               message "{@noperm}"

       if arg 1 is "refill":
           if player has permission "{@perm}":
               set {twd.lootchest.last_refill} to now
               broadcast "&b&3Chests refilled in 3s"
               wait 1 second
               broadcast "&b&3Chests refilled in 2s"
               wait 1 second
               broadcast "&b&3Chests refilled in 1s"
               wait 1 second
               broadcast "&bChests have been refilled"
               loop {cheloc::*}:
                   set {_cheslot::*} to ""
                   loop 27 times:
                       add loop-number to {_slotnum::*}
                   clear inventory of block at loop-value
                   wait 1 tick
                   set {_loop} to a random integer between {@minitems} and {@maxitems}
                   loop {_loop} times:
                       set {_cheitem} to a random element out of {ritem::*}
                       set {_cheslot} to a random element out of {_slotnum::*}
                       add {_cheitem} to slot ({_cheslot} - 1) of block at loop-value-1
           else:
               message "{@noperm}"

       if arg 1 is "about" OR "version":
           message "&3&lmChests &r&b> Currently running version &3{@version}"

       if arg 1 is not set:
           if player has permission "{@perm}":
               message "{@prefix} You need to specify a command! Usage: /mchest <add/remove/refill>"
           else:
               message "{@noperm}"
every 300 second:
   make console execute command "/lootchest refill" as op

Si c'est un truc régulier passe par une fonction...

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

every 10 seconds:
   set {twd.lootchest.last_refill} to now
   broadcast "&b&3Chests refilled in 3s"
   wait 1 second
   broadcast "&b&3Chests refilled in 2s"
   wait 1 second
   broadcast "&b&3Chests refilled in 1s"
   wait 1 second
   broadcast "&bChests have been refilled"
   loop {cheloc::*}:
       set {_cheslot::*} to ""
       loop 27 times:
           add loop-number to {_slotnum::*}
           clear inventory of block at loop-value
           wait 1 tick
           set {_loop} to a random integer between {@minitems} and {@maxitems}
           loop {_loop} times:
               set {_cheitem} to a random element out of {ritem::*}
               set {_cheslot} to a random element out of {_slotnum::*}
               add {_cheitem} to slot ({_cheslot} - 1) of block at loop-value-1

 

LES TABULATIONS NE SONT PAS RESPECTEES (NORMALEMENT SI MAIS QUAND TU COPIES COLLES SA PART EN CACA-HUETE, T'as demandé comme faire le même truc de refill t'as juste à rajuter ça.

  • 0
Posté(e)
every 10 seconds:
   set {twd.lootchest.last_refill} to now
   broadcast "&b&3Chests refilled in 3s"
   wait 1 second
   broadcast "&b&3Chests refilled in 2s"
   wait 1 second
   broadcast "&b&3Chests refilled in 1s"
   wait 1 second
   broadcast "&bChests have been refilled"
   loop {cheloc::*}:
       set {_cheslot::*} to ""
       loop 27 times:
           add loop-number to {_slotnum::*}
           clear inventory of block at loop-value
           wait 1 tick
           set {_loop} to a random integer between {@minitems} and {@maxitems}
           loop {_loop} times:
               set {_cheitem} to a random element out of {ritem::*}
               set {_cheslot} to a random element out of {_slotnum::*}
               add {_cheitem} to slot ({_cheslot} - 1) of block at loop-value-1

 

LES TABULATIONS NE SONT PAS RESPECTEES (NORMALEMENT SI MAIS QUAND TU COPIES COLLES SA PART EN CACA-HUETE, T'as demandé comme faire le même truc de refill t'as juste à rajuter ça.

De un je n'ai pas comprit la dernière phrase et de deux c'est du full maj. Je lock que si ça venez à se reproduire. Merci

  • 0
Posté(e)

Finalement je suis passé par une fonction comme uiytt me l'a conseillé mais j'ai remarqué que lorsque je refill beaucoup de coffre (plusieurs dizaines) cela fait lagger le serveur, y a t'il un moyen d'optimiser le refill ?

 

options:
   prefix: &bLootChest >
   perm: lootchest.perm
   noperm: &cYou don't have the permission to do that!
   minitems: 6
   maxitems: 11

function RefillChest(null: int=0):
   set {twd.lootchest.last_refill} to now
   broadcast "&b&3Chests refilled in 3s"
   wait 1 second
   broadcast "&b&3Chests refilled in 2s"
   wait 1 second
   broadcast "&b&3Chests refilled in 1s"
   wait 1 second
   broadcast "&bChests have been refilled"
   loop {cheloc::*}:
       set {_cheslot::*} to ""
       loop 27 times:
           add loop-number to {_slotnum::*}
       clear inventory of block at loop-value
       wait 1 tick
       set {_loop} to a random integer between {@minitems} and {@maxitems}
       loop {_loop} times:
           set {_cheitem} to a random element out of {ritem::*}
           set {_cheslot} to a random element out of {_slotnum::*}
           add {_cheitem} to slot ({_cheslot} - 1) of block at loop-value-1


on load:
   set {_refill} to true
   clear {ritem::*}
   add 8 snowballs to {ritem::*}
   add 16 eggs to {ritem::*}
   add 32 eggs to {ritem::*}
   add 8 eggs to {ritem::*}
   add iron sword to {ritem::*}
   add iron helmet to {ritem::*}
   add iron chestplate to {ritem::*}
   add iron leggings to {ritem::*}
   add iron boots to {ritem::*}
   add diamond chestplate to {ritem::*}
   add diamond helmet to {ritem::*}
   add diamond leggings to {ritem::*}
   add diamond boots to {ritem::*}
   add 32 arrow to {ritem::*}
   add 16 arrow to {ritem::*}
   add 24 arrow to {ritem::*}
   add 32 stone to {ritem::*}
   add 16 stone to {ritem::*}
   add 24 bricks to {ritem::*}
   add 32 bricks to {ritem::*}
   add shield to {ritem::*}
   add bow to {ritem::*}
   add leather boots to {ritem::*}
   add leather helmet to {ritem::*}
   add leather chestplate to {ritem::*}
   add leather leggings to {ritem::*}
   add 16 snowballs to {ritem::*}
   add 32 snowballs to {ritem::*}
   add 1 golden apple to {ritem::*}
   add 2 golden apple to {ritem::*}
   add 4 golden apple to {ritem::*}
   add 32 oak planks to {ritem::*}
   add 16 oak planks to {ritem::*}
   add 64 oak planks to {ritem::*}
   add 1 ender pearl to {ritem::*}
   add 2 ender pearl to {ritem::*}
   add 32 experience bottle to {ritem::*}
   add 64 experience bottle to {ritem::*}
   add water_bottle:8194 to {ritem::*}
   add water_bottle:8201 to {ritem::*}
   add 2 diamond to {ritem::*}

   RefillChest()           

command /lootchest [<text>]:
   trigger:
       if arg 1 is "add":
           if player has permission "{@perm}":
               if target block is chest:
                   loop {cheloc::*}:
                       if loop-value is location of target block:
                           message "{@prefix} This chest has already been checked as a mCHEST!"
                           stop
                   add location of target block to {cheloc::*}
                   message "{@prefix} Succesfully executed &3AddChest"
               else:
                   message "&b{@prefix} You need to select a chest!"
           else:
               message "{@noperm}"

       if arg 1 is "remove":
           if player has permission "{@perm}":
               if target block is a chest or stone:
                   remove location of target block from {cheloc::*}
                   message "{@prefix} Succesfully removed the selected chest!"
                   clear inventory of target block
                   stop
               else:
                   message "{@prefix} You need to select a chest!"
           else:
               message "{@noperm}"

       if arg 1 is "refill":
           if player has permission "{@perm}":
               RefillChest()
           else:
               message "{@noperm}"

       if arg 1 is not set:
           if player has permission "{@perm}":
               message "{@prefix} You need to specify a command! Usage: /mchest <add/remove/refill>"
           else:
               message "{@noperm}"

  • 0
Posté(e)
Finalement je suis passé par une fonction comme uiytt me l'a conseillé mais j'ai remarqué que lorsque je refill beaucoup de coffre (plusieurs dizaines) cela fait lagger le serveur, y a t'il un moyen d'optimiser le refill ?

 

options:
   prefix: &bLootChest >
   perm: lootchest.perm
   noperm: &cYou don't have the permission to do that!
   minitems: 6
   maxitems: 11

function RefillChest(null: int=0):
   set {twd.lootchest.last_refill} to now
   broadcast "&b&3Chests refilled in 3s"
   wait 1 second
   broadcast "&b&3Chests refilled in 2s"
   wait 1 second
   broadcast "&b&3Chests refilled in 1s"
   wait 1 second
   broadcast "&bChests have been refilled"
   loop {cheloc::*}:
       set {_cheslot::*} to ""
       loop 27 times:
           add loop-number to {_slotnum::*}
       clear inventory of block at loop-value
       wait 1 tick
       set {_loop} to a random integer between {@minitems} and {@maxitems}
       loop {_loop} times:
           set {_cheitem} to a random element out of {ritem::*}
           set {_cheslot} to a random element out of {_slotnum::*}
           add {_cheitem} to slot ({_cheslot} - 1) of block at loop-value-1


on load:
   set {_refill} to true
   clear {ritem::*}
   add 8 snowballs to {ritem::*}
   add 16 eggs to {ritem::*}
   add 32 eggs to {ritem::*}
   add 8 eggs to {ritem::*}
   add iron sword to {ritem::*}
   add iron helmet to {ritem::*}
   add iron chestplate to {ritem::*}
   add iron leggings to {ritem::*}
   add iron boots to {ritem::*}
   add diamond chestplate to {ritem::*}
   add diamond helmet to {ritem::*}
   add diamond leggings to {ritem::*}
   add diamond boots to {ritem::*}
   add 32 arrow to {ritem::*}
   add 16 arrow to {ritem::*}
   add 24 arrow to {ritem::*}
   add 32 stone to {ritem::*}
   add 16 stone to {ritem::*}
   add 24 bricks to {ritem::*}
   add 32 bricks to {ritem::*}
   add shield to {ritem::*}
   add bow to {ritem::*}
   add leather boots to {ritem::*}
   add leather helmet to {ritem::*}
   add leather chestplate to {ritem::*}
   add leather leggings to {ritem::*}
   add 16 snowballs to {ritem::*}
   add 32 snowballs to {ritem::*}
   add 1 golden apple to {ritem::*}
   add 2 golden apple to {ritem::*}
   add 4 golden apple to {ritem::*}
   add 32 oak planks to {ritem::*}
   add 16 oak planks to {ritem::*}
   add 64 oak planks to {ritem::*}
   add 1 ender pearl to {ritem::*}
   add 2 ender pearl to {ritem::*}
   add 32 experience bottle to {ritem::*}
   add 64 experience bottle to {ritem::*}
   add water_bottle:8194 to {ritem::*}
   add water_bottle:8201 to {ritem::*}
   add 2 diamond to {ritem::*}

   RefillChest()          

command /lootchest [<text>]:
   trigger:
       if arg 1 is "add":
           if player has permission "{@perm}":
               if target block is chest:
                   loop {cheloc::*}:
                       if loop-value is location of target block:
                           message "{@prefix} This chest has already been checked as a mCHEST!"
                           stop
                   add location of target block to {cheloc::*}
                   message "{@prefix} Succesfully executed &3AddChest"
               else:
                   message "&b{@prefix} You need to select a chest!"
           else:
               message "{@noperm}"

       if arg 1 is "remove":
           if player has permission "{@perm}":
               if target block is a chest or stone:
                   remove location of target block from {cheloc::*}
                   message "{@prefix} Succesfully removed the selected chest!"
                   clear inventory of target block
                   stop
               else:
                   message "{@prefix} You need to select a chest!"
           else:
               message "{@noperm}"

       if arg 1 is "refill":
           if player has permission "{@perm}":
               RefillChest()
           else:
               message "{@noperm}"

       if arg 1 is not set:
           if player has permission "{@perm}":
               message "{@prefix} You need to specify a command! Usage: /mchest <add/remove/refill>"
           else:
               message "{@noperm}"

J'ai une idée mais bon c'est pas ça qui va changer grand chose.

Au lieu de redéfinir a chaque fois slotnum, pourquoi ne pas le définir une seul fois dans le on load ?

  • 0
Posté(e)

Lorsque je met :

    loop 27 times:
       add loop-number to {_slotnum::*}

Dans on load ça ne fait pas d'erreur mais les coffres reste vide après exécution du refill

  • 0
Posté(e)
Lorsque je met :

    loop 27 times:
       add loop-number to {_slotnum::*}

Dans on load ça ne fait pas d'erreur mais les coffres reste vide après exécution du refill

oui il faut enlever le _ devant car sinon la variable disparait à la fin de l'event ^^

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