Aller au contenu
  • 0

TimeSpan


Question

Posté(e)

Bonjour, je poste ceci car je travaille sur un skript de tempban mais je suis confronter à une erreur que voici:

http://www.noelshack.com/2017-28-1-1499684138-capture.png (j'ai réaliser ce bout de code en cherchant sur le net, mais pas moyen de trouver une solution pour l'erreur :/)

 

J'aimerais donc savoir si quelqu'un aurait une solution.

 

Je possède la dernière version de skript et également de pack d'addons de @SwiKZiiK et spigot 1.8.

 

En remerciant d'avance la/les personne(s) pouvant m'aider :)

 

[spoiler=code]

function CheckTime(time: text) :: boolean: # Fonction qui va vérifier si une durée a été écrite correctement !
   if length of {_time} is 2:
       set {_check::*} to groups 0 of "%{_time}%" matched to "^[0-9](s|S|m|M|h|H|d|D)$"
   else if length of {_time} is 3:
       set {_check::*} to groups 0 of "%{_time}%" matched to "^[0-9]{2}(s|S|m|M|h|H|d|D)$"
   if {_check::*} is set:
       return true
   else:
       return false

function TransformTime(time: text) :: timespan: # Fonction qui va retourner le temps sous forme de TimeSpan !
   if length of {_time} is 2:
       set {_time} to "0%{_time}%"
   set {_characters::*} to {_time} split at ""
   if {_characters::3} is "s":
       set {_characters::3} to " seconds"
   else if {_characters::3} is "m":
       set {_characters::3} to " minutes"
   else if {_characters::3} is "h":
       set {_characters::3} to " hours"
   else if {_characters::3} is "d":
       set {_characters::3} to " days"
   set {_result} to "%{_characters::1}%%{_characters::2}%%{_characters::3}%" parsed as timespan
   return {_result}

function SanctionTime(time: timespan) :: text: # Fonction qui va retourner le temps de la sanction !
   set {_time} to "%{_time}%"
   set {_words::*} to {_time} split at " "
   if {_words::2} is "second" or "seconds":
       set {_words::2} to "seconde(s)"
   else if {_words::2} is "minute" or "minutes":
       set {_words::2} to "minute(s)"
   else if {_words::2} is "hour" or "hours":
       set {_words::2} to "heure(s)"
   else if {_words::2} is "day" or "days":
       set {_words::2} to "jour(s)"
   set {_result} to "%{_words::1}% %{_words::2}%"
   return {_result}

function TimeLeft(difference: timespan, cooldown: timespan) :: text: # Fonction qui va retourner le temps d'une sanction temporaire !
   subtract {_difference} from {_cooldown}
   set {_cooldown} to "%{_cooldown}%"
   replace "second " with "seconde(s) " in {_cooldown}
   replace "seconds" with "seconde(s)" in {_cooldown}
   replace "minute " with "minute(s) " in {_cooldown}
   replace "minutes" with "minute(s)" in {_cooldown}
   replace "hour " with "heure(s) " in {_cooldown}
   replace "hours" with "heure(s)" in {_cooldown}
   replace "day " with "jour(s) " in {_cooldown}
   replace "days" with "jour(s)" in {_cooldown}
   replace "and" with "et" in {_cooldown}
   set {_words::*} to {_cooldown} split at " "
   if {_words::5} is set:
       set {_words::1} to rouned down ("%{_words::1}%" parsed as number)
       set {_words::4} to rouned down ("%{_words::4}%" parsed as number)
       set {_result} to "%{_words::1}% %{_words::2}% %{_words::3}% %{_words::4}% %{_words::5}%"
   else:
       set {_words::1} to rouned down ("%{_words::1}%" parsed as number)
       set {_result} to "%{_words::1}% %{_words::2}%"
   return {_result}

command /ttempban <offline player> <text> <text>:
   trigger:
       if CheckTime(arg 2) is false:
           send "&cErreur : La durée n'a pas été écrite correctement !"
       else:
           set {ban.%arg 1%} to true
           set {ban.now.%arg 1%} to now
           set {ban.time.%arg 1%} to TransformTime(arg 2)
           set {ban.reason.%arg 1%} to arg 3
           wait a tick
           set {_time} to SanctionTime({ban.time.%arg 1%})
           broadcast "&b> %arg 1% &7a été banni par &b%player% &7pendant &b%{_time}% &7pour &b%arg 2% &7!"
           kick arg 1 due to "&cErreur : Vous avez été banni !%nl%%nl%&7Raison : &a%{ban.reason.%player%}%%nl%&7Temps restant : &a%{_time.left}%"

on join:
   if {ban.%player%} is true:
       if difference between {ban.now.%player%} and now is less than {ban.time.%player%}:
           set {_time.left} to TimeLeft(difference between {ban.now.%player%} and now, {ban.time.%player%})
           kick player due to "&cErreur : Vous avez été banni !%nl%%nl%&7Raison : &a%{ban.reason.%player%}%%nl%&7Temps restant : &a%{_time.left}%"

 

 

3 réponses à cette question

Messages recommandés

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