Aller au contenu
  • 0

Calculer en Skript ? (faire des opérations (* & /)


Question

Posté(e)

Bonjour, bonsoir

Aujourd'hui, j'ai créer un sondage sur Minecraft (server spigot 1.8 à 1.12).

Et j'aimerais que l'on fasse "/sondage view", et là sa affiche les résultats en pourcentage, et le nombre de votant...

 

Voici mes lignes de codes:

[spoiler=1. Le sondage]

command /sondage [<text>]:

[b]    trigger:
       if arg-1 is not set:
           wait 1 second
           open chest with 1 rows named "" to player
           play "NOTE_PLING" to player at volume 5
           format slot 2 of player with red wool block named "{@LaineRouge}" to close then run [make player execute command "/$sondage rouge"]
           format slot 4 of player with white wool block named "{@LaineBlanche}" to be unstealable
           format slot 6 of player with light green wool block named "{@LaineVerte}" to close then run [make player execute command "/$sondage vert"]
       if arg-1 is "view":
           wait 1 second
           open chest with 1 rows named "" to player
           play "NOTE_PLING" to player at volume 5
           format slot 2 of player with red wool block named "%{sondage.rouge}%" to be unstealable
           format slot 4 of player with white wool block named "{@LaineBlanche}" to be unstealable
           format slot 6 of player with light green wool block named "%{sondage.vert}%" to be unstealable
       if arg-1 is "reset":
           if executor is "XTReMxLogik":
               set {sondage.rouge} to 0
               set {sondage.vert} to 0
               delete {sondage.%player%}
               message " "

 

 

[spoiler=2. Add-on a la premiere partie du sondage]

command /$sondage [<text>]:
   trigger:
       if arg-1 is "rouge":
           add 1 to {sondage.rouge}
           set {sondage.%player%} to true
       if arg-1 is "vert":
           add 1 to {sondage.vert}
           set {sondage.%player%} to true

 

[spoiler=3. TEST (a caller dans le /sondage view (1ere partie)]

command /test:
   trigger:
       set  {_rouge} to {sondage.rouge}
       set {_vert} to {sondage.vert}
       set {_vertTOTAL} to 0
       set {_rougeTOTAL} to 0
   #--- rouge ---#
       set {_rougeTOTAL} to ({_rouge} parsed as a number) / {_vert}
       wait 1 tick
       set {_rougeTOTAL} to ({_rouge} parsed as a number) * 100
       message "%{_rougeTOTAL}%"
   #--- vert ---#  
       set {_vertTOTAL} to ({_vert} parsed as a number) / {_rouge}
       wait 1 tick
       set {_vertTOTAL} to ({_vert} parsed as a number) * 100[/b]
       message "%{_vertTOTAL}%"

#Ne fonctionne pas !
[b]

 

Si possible, ecrire le /sondage view:

Clay rouge (slot 2) > "pourcentage% (nombre de votant)"

Clay vert (slot 6) > "pourcentage% (nombre de votant)"

 

Je reste à disposition pour toute demande...

4 réponses à cette question

Messages recommandés

  • 0
Posté(e)

Salut x)

Bon je ne sais pas pour ton problème, mais je te conseil d'utiliser une fonction pour le /§sondage :)

Ca fait longtemps que j'ai plus fait de Skript donc je ne sais pas si sa marche :(

[spoiler=code]

function sondage(Player player, String arg):
   if arg is "rouge":
       add 1 to {sondage.rouge}
       set {sondage.%player%) to true
   if arg is "vert":
       add 1 to {sondage.vert}
       set {sondage.%player%} to true

 

 

 

Je sais que sa ne t'aide pas trop pour les "opérations" mais bon x)

  • 0
Posté(e)
Salut x)

Bon je ne sais pas pour ton problème, mais je te conseil d'utiliser une fonction pour le /§sondage :)

Ca fait longtemps que j'ai plus fait de Skript donc je ne sais pas si sa marche :(

[spoiler=code]

function sondage(Player player, String arg):
   if arg is "rouge":
       add 1 to {sondage.rouge}
       set {sondage.%player%) to true
   if arg is "vert":
       add 1 to {sondage.vert}
       set {sondage.%player%} to true

 

 

 

Je sais que sa ne t'aide pas trop pour les "opérations" mais bon x)

Merci mais les functions je sais pas utiliser, et oui,pour les oprération se serais mieux...

Merci quand même, bonne continuation !

  • 0
Posté(e)

Essaye ceci :

 

 

command /sondage [<text>]:
   trigger:
       if arg-1 is not set:
           wait 1 second
           open chest with 1 rows named "" to player
           play "BLOCK_NOTE_PLING" to player at volume 5
           format slot 2 of player with red wool block named "{@LaineRouge}" to close then run [make player execute command "/$sondage rouge"]
           format slot 4 of player with white wool block named "{@LaineBlanche}" to be unstealable
           format slot 6 of player with light green wool block named "{@LaineVerte}" to close then run [make player execute command "/$sondage vert"]
       if arg-1 is "view":
           wait 1 second
           set {_viewt} to {sondage.rouge} + {sondage.vert}
           set {_viewr} to ({sondage.rouge} * 100) / {_viewt}
           set {_viewv} to ({sondage.vert} * 100) / {_viewt}
           open chest with 1 rows named "" to player
           play "BLOCK_NOTE_PLING" to player at volume 5
           format slot 2 of player with red wool block named "%{_viewr}%%% (sur %{_viewt}% votant)" to be unstealable
           format slot 4 of player with white wool block named "{@LaineBlanche}" to be unstealable
           format slot 6 of player with light green wool block named "%{_viewv}%%% (sur %{_viewt}% votant)" to be unstealable
       if arg-1 is "reset":
           if executor is "XTReMxLogik":
               set {sondage.rouge} to 0
               set {sondage.vert} to 0
               delete {sondage.%player%}
               message " "
command /$sondage [<text>]:
   trigger:
       if arg-1 is "rouge":
           add 1 to {sondage.rouge}
           set {sondage.%player%} to true
       if arg-1 is "vert":
           add 1 to {sondage.vert}
           set {sondage.%player%} to true

 

 

 

J'ai ajouté

            set {_viewt} to {sondage.rouge} + {sondage.vert}
           set {_viewr} to ({sondage.rouge} * 100) / {_viewt}
           set {_viewv} to ({sondage.vert} * 100) / {_viewt}

dans ton « sondage view », et corrigé le nom du son « NOTE_PLING » en « BLOCK_NOTE_PLING »

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