Communauté Eggdrop
Trivia TCl ( points variable ) - Version imprimable

+- Communauté Eggdrop (https://forum.eggdrop.fr)
+-- Forum : Eggdrop et TCL (https://forum.eggdrop.fr/forumdisplay.php?fid=8)
+--- Forum : Scripts TCL (https://forum.eggdrop.fr/forumdisplay.php?fid=4)
+--- Sujet : Trivia TCl ( points variable ) (/showthread.php?tid=170)

Pages : 1 2


Trivia TCl ( points variable ) - hearty120120 - 01/03/2008

Bonjour tlm

J'ai quelque soucis avec mon trivia.tcl.. avec quelques améliorations, y me reste encore la variation des points, je veux que chaque questions obtient un nombre de point different, avec un lancement de Bonus aleatoire. contrairement a ce qu'on trouve sur Trivia avec un seul score pour tout les questions.

merci pour votre aide


RE: Trivia TCl ( points variable ) - BdS - 02/03/2008

Tiens on dirait mon robot quizz:

Pour les points variable, perso j'ai joué sur les timers des indices pour choisir le nombres de points gagnés.
Pour le bonus aléatoire, c'est vague comme demande ...


RE: Trivia TCl ( points variable ) - hearty120120 - 02/03/2008

tu peux me donner un exemple stp.. comment faire pour le truc du timer stp


RE: Trivia TCl ( points variable ) - hearty120120 - 02/03/2008

voila mon script
tcl
#  Cette variable permet de définir combien de point seront donnés à un utilisateur
#  qui donne une bonne réponse.
set tgpointsperanswer 3000

#incrément les points de la personne points.
proc tgincrscore {who} {
    global tgscores tgscf tgpointsperanswer tgscorestotal tgscoresbyname tghintnum
    tggetscores
    if {$tgscorestotal>0} {
        set i 0
        if {![info exists tgscoresbyname([strlwr $who])]} {
	        append _newscores "[expr $tgpointsperanswer-$tghintnum],[expr 1000000000000.0/[unixtime]],$who,[strlwr $who] "
            #append _newscores "1,[expr 1000000000000.0/[unixtime]],$who,[strlwr $who] "
        }
        while {$i<[llength $tgscores]} {
            set _item [lindex $tgscores $i]
            set _nick [lindex [split $_item ,] 2]
            set _time [lindex [split $_item ,] 1]
            set _score [lindex [split $_item ,] 0]
            if {[strlwr $who]==[strlwr $_nick]} {
	            append _newscores "[expr $_score+$tgpointsperanswer-$tghintnum],[expr 1000000000000.0/[unixtime]],$who,[strlwr $who][expr [expr [llength $tgscores]-$i]==1?"":"\ "]"
                #append _newscores "[expr $_score+$tgpointsperanswer],[expr 1000000000000.0/[unixtime]],$who,[strlwr $who][expr [expr [llength $tgscores]-$i]==1?"":"\ "]"
            } else {
                append _newscores "$_score,$_time,$_nick,[strlwr $_nick][expr [expr [llength $tgscores]-$i]==1?"":"\ "]"
            }
            incr i
        }
    } else {
	    append _newscores "[expr $tgpointsperanswer-$tghintnum],[expr 1000000000000.0/[unixtime]],$who,[strlwr $who]"
        #append _newscores "1,[expr 1000000000000.0/[unixtime]],$who,[strlwr $who]"
    }
    set _sfile [open $tgscf w]
    puts $_sfile "$_newscores"
    close $_sfile
    return
}





RE: Trivia TCl ( points variable ) - hearty120120 - 02/03/2008

Mercii d'avantage


RE: Trivia TCl ( points variable ) - NuNuX - 02/03/2008

( la balise tcl )


RE: Trivia TCl ( points variable ) - MenzAgitat - 02/03/2008

hearty120120 a écrit :voila mon script en entier
(...)

3 remarques à faire :
  • j'ai supprimé ton post car le script n'était pas entier (il en manquait environ la moitié car tu as atteint la longueur maximale d'un post) et qu'on ne poste pas un script de 884 lignes en entier sur un forum.
  • utilise les balises [tcl] [/tcl] pour poster du code en Tcl.
  • Tu dis qu'il s'agit de ton script mais d'après ce que je peux voir il s'agit du script Trivia.tcl de EnEmY.



RE: Trivia TCl ( points variable ) - hearty120120 - 03/03/2008

Ouii c'est un trivia et je cherche a rendre les points variable.. ici on me donne un seul score pour tte les questions...aidez moi svp


tcl
################################################################################
#VEUILLEZ adapter les arrangements a vos besoins avant de rehashing votre BOT! #
################################################################################

#  indiquer dans quel repertoire devra se trouver votre base de donnée contenant les questions/réponses.
set tgqdb "scripts/trivia.questions"

#  indiquer quel séparateur distinguera les questions des réponses dans la base de données. Dans le cas présent il s'agit d'un |
set tgqdbsep "|"

#  ce paramètre permet de dire si les lignes de la base de donnée contenant les questions est de la forme :
#  . Réponse seperateur question (dans ce cas mettre la variable à 0)
#  ou
#  . Question séparateur réponse (dans ce cas metre la variable à 1)
set tgqdbquestionfirst 1

#  Ce paramètre permettra de définir dans quel répertoire se situe le fichier contenant les scores du jeu.
#  Si ce fichier existe pas il sera crée automatiquement.
set tgscf "scripts/trivia.scores"

#  Ce paramètre permet de définir comment vous serez averti en cas d'erreur dans une question :
#  . Mettre à 1 si vous désirez être averti par email (et si votre shell peut le faire)
#  ou
#  . Mettre à 0 si vous voulez que les erreurs soient stocker dans un fichier.
set tgerrmethod 1

#  C'est dans cette variable que vous mettrez dans quel répertoire
#  vous voulez stocker le fichier contenant les erreurs. (si tgerrmethod est à 0)
#  Si ce fichier n'existe pas il sera crée automatiquement.
set tgerrfil "scripts/trivia.errors"

#  Dans cette variable vous mettrez votre email. Ceci permettra au robot
#  d'envoyer un rapport sur les erreurs éventuelles. (si tgerrmethod est à 1)
set tgerremail ""

#  Ici vous définirez ou est ce que le robot créera un fichier temporaire
#  contenant un rapport sur les envois des erreurs PAR EMAIL.
set tgerrmailtmp "/tmp"

#  Ici vous définirez le Répertoire + nom de la page Web que génèrera le robot !
#  En effet, le robot génère une page web en temps réèl avec les scores.
#  Si ce fichier n'existe pas il sera crée automatiquement.
set tghtmlfile "scripts/quizz.html"

#  Cette variable permet de définir tout les combiens de temps la page HTML est rafraichi.
#  Mettre 0 pour désactivé la page HTML.
set tghtmlrefresh 20

#  Cette variable permet de définir quel style de fond sera utilisé sur la page web.
set tghtmlfont "verdana,helvetica,arial"

#  Cette variable permet de définir dans quel salon se déroulera le quizz.
set tgchan "#channel"

#  Cette variable permet de définir combien de point seront donnés à un utilisateur
#  qui donne une bonne réponse.
set tgpointsperanswer 3000

#  Cette variable définit le nombre max d'indice fournit pas le robot lors d'une question.
set tgmaxhint 3

#  Cette variable permet de définir si le robot montrera la question à chaque conseil (1)
#  ou seulement à la première (0).
set tgalwaysshowq 0

#  Cette variable permet de montrer (1) ou pas (0), les questions en lettres majuscules.
set tgcapsquestion 0

#  Cette variable permet de montrer (1) ou pas (0), les réponses en lettres majuscules.
set tgcapsanswer 0

#  Cette variable permet de montrer (1) ou pas (0), les conseils en lettres majuscules.
set tgcapshint 0

#  Cette variable permet de définir à partir de combien de réponse une personne se retrouvera
#  dites dans une 'série de bonnes réponses' (Mettre à 0 pour désactiver).
set tgstreakmin 3

#  Cette variable permet de définir à partir de combien de questions sans réponse le quizz
#  sera stoppé. (Si vous mettez 0, le quizz ne se stoppera que lorsqu'une personne autorisée fera !stop).
set tgmaxmissed 0

#  Cette variable permet de définir quel caractère remplacera la réponse lorsque le quizz posera la question.
set tghintchar "*"

#  Cette variable permet de définir combien de temps (en seconde) s'écoulera entre chaque conseils.
set tgtimehint 13

#  Permet de définir le temps (en seconde) qui s'écoulera entre le moment ou une bonne réponse a été donnée.
set tgtimenext 8

#  Cette variable permet de définir ce que dira le robot lors d'une bonne réponse.
set tgcongrats [list "Bravooo,"]

#  Cette variable permet de définir ce que dira le robot lorsque personne n'aura répondu correctement à une question.
set tgnobodygotit [list ""]

#  Cette variable permet de définir ce que dira le robot lorsque l'on gagne plusieurs fois d'affilé.
set tgmulti [list "veut atteindre le podium" "a t-il prit des cachets ?" "Wowww ca va bien ?" "qu'est-ce qui t'arrive ?" "ne veut pas finir dernier sa c sur !"]

 
#  Cette variable permet de définir ce que dira le robot lorsque personne n'aura répondu à une question et l'arrivée de la prochaine question.
set tgtrythenextone [list ""]

#  Cette variable permet de calculer en combien de temps a été donné une bonne réponse. Mettre à 1 pour activer, 0 pour désactiver.
set tgtimeanswer 1

#  Cette variable permet de définir si le robot donnera la réponse si personne la trouve. Mettre à 0 pour cacher la réponse, à 1 pour la montrer.
set tgshowanswer 1

#  Cette variable permet de définir si le robot anoncera le score de la personne donnant une bonne réponse (0)
#  ou alors les scores de tout les joueurs présents sur le salon (1).
set tgshowallscores 1

#  Cette variable permet d'activé le gras (1) ou non (0) dans ses phrases.
set tgusebold 0

#  Mettre à 1 si vous voulez que le robot envoie les messages privés en pv, ou à 0 pour qu'ils les envoient en notice.
set tgpriv2msg 1

#  Cette variable permet de définir sur quel mot réagira le robot pour vous aider... dans ce cas là,
#  si vous envoyez en message privé au robot 'Qindice' , il vous enverra un message d'aide.
set tgcmdhelp "Help"

#  Commande permettant de lancer le quizz.
set tgcmdstart "!quizz"

#  Flag requiert pour lancer le quizz.
set tgflagsstart "-|-"

#  Commande permettant de stopper le quizz.
set tgcmdstop "!stop"

#  Flag requiert pour stopper le quizz.
set tgflagsstop "o|o"

#  Commande permettant de donné un indice à une question.
set tgcmdhint "~"

#  Flag requiert pour effectuer la commande pour obtenir un indice.
set tgflagshint "-|-"

#  Temps en seconde entre lequel la commande ~ est désactivé lorsque celle-ci est utilisée.
set tgtempnohint 10

#  Commande permettant de voir le Top10 !
set tgcmdtop10 "!top10"

#  Flag requiert pour pouvoir utiliser le top10.
set tgflagstop10 "-|-"

#  Commande permettant de mettre à zéro les scores (/msg botnick reset)
set tgcmdreset "reset"

#  Flag requiert pour pouvoir utiliser la commande reset.
set tgflagsreset "m|m"

#  Mettre à 1 pour utiliser le reset avec un pass (/msg quizz reset votre-pass),
#  à 0 sans pass (/msg quizz reset).
set tgresetreqpw 0

#  Cette commande permet de définir la commande pour voir les scores ( /msg botnick score ).
set tgcmdlookup "score"

#  Cette commande permet de définir la commande pour ciblé un score (/msg botnick place pseudo).
set tgcmdtarget "place"

#  Cette commande permet de définir la commande pour repporter une erreur (/msg botnick erreur).
set tgcmderror "erreur"

#  Cette commande permet de définir la commande pour connaitre les règles du salon (/msg botnick règles).
set tgcmdrules "règles"

#  cette variable permet de définir les règles du salon.
set tgrules "Aucune publicité, aucun blasphème, aucun harcelement des utilisateurs, aucuns scripts actifs et aucun flood.  Violez ces règles et vous vous verrez banni. Bon jeu :-)"

#  Nombre de minutes entre lequel la commande de report d'erreur est désactivée.
set tgerrremindtime 30

#  COULEURS
#  Voilà les codes couleurs utilisé sur Mirc:
#  00:blanc        01:noir        02:blue foncé   03:vert foncé
#  04:rouge        05:marron      06:pourpre      07:orange
#  08:jaune        09:vert clair  10:turquoise    11:cyan
#  12:bleu clair   13:magenta     14:gris foncé   15:vert clair
#
#  Il faut toujours spécifié le code couleurs avec 2 chiffres "01"
#  et non un seul "1".
#  Pour spécifié un fond mettre d'abord la couleur de texte,
#  une virgule et la couleur de fond exemple "00,04" (texte blanc
#  sur fond rouge).
#  Pour désactivé la couleur utilise "".
 
set tgcolourstart "03"        ;#Début du jeu.
set tgcolourstop "04"        ;#Fin du jeu.
set tgcolourerr "01,08"        ;#Quand report d'une erreur.
set tgcolourmiss "12"        ;#Personne n'a répondu à la question.
set tgcolourqhead "03"        ;#Titre de la question.
set tgcolourqbody "08,02"        ;#Couleur du texte de la question.
set tgcolourhint "08,02"        ;#Couleur de l'indice.
set tgcolourstrk "12"        ;#Personne dans une 'une série de bonne réponse'.
set tgcolourscr1 "04"        ;#Couleur de la personne en 1ere place.
set tgcolourscr2 "07"        ;#Couleur de la personne en 2nd place.
set tgcolourscr3 "14"        ;#Couleur de la personne en 3eme place.
set tgcolourrset "04"        ;#Quand les scores sont mises à 0.
set tgcolourstend "12"        ;#Fin d'une 'série de bonne réponse'.
set tgcolourmisc1 "12"        ;#Couleur diverse 1.
set tgcolourmisc2 "04"        ;#Couleur diverse 2.

 
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#                                                                         #
#   l'édition faite au delà de ce point est faite à votre propre risque!  #
#                                                                         #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#Contrôles divers et initialisations des variables
set tgver "1.3.4"
set tgrel "release"
 
proc no_accent {code_text} {
   regsub -all é $code_text "e" code_text
   regsub -all è $code_text "e" code_text
   regsub -all ê $code_text "e" code_text
   regsub -all ï $code_text "i" code_text
   regsub -all ï $code_text "i" code_text
   regsub -all ù $code_text "u" code_text
   regsub -all ô $code_text "o" code_text
   regsub -all ç $code_text "c" code_text
   regsub -all à $code_text "a" code_text
   regsub -all â $code_text "a" code_text
   return $code_text
}
 
if {[info tclversion]<8.2} {
    putlog "\002[file tail [info script]]\002 chargement échoué: Pour utiliser ce script, votre eggdrop doit être compilé avec tcl 8.2 ou supérieur (recommandé: version stable)."
    return
}
if {$tgtimeanswer==1&&[info tclversion]<8.3} {
    putlog "\002[file tail [info script]]\002 warning: la synchronisation des réponses a été automatiquement neutralisée. Cette commande requiert tcl 8.3 ou supérieur."
    set tgtimeanswer 0
}
if {![info exists alltools_loaded]||$allt_version<205} {
    putlog "\002[file tail [info script]]\002 chargement échoué: charger alltools.tcl v1.14 ou supérieur (disponible avec un eggdrop 1.6.13 ou supérieur) avant d'essayer de charger ce tcl."
    return
}
if {[utimerexists tghtml]!=""} {killutimer $tghtmlrefreshtimer}
if {$tghtmlrefresh>0} {
    set tghtmlrefreshtimer [utimer $tghtmlrefresh tghtml]
}
if {![file exists $tgqdb]} {
    putlog "\002[file tail [info script]]\002 chargement échoué: $tgqdb n'existe pas."
    return
}
if {[llength [split $tgchan]]!=1} {
    putlog "\002[file tail [info script]]\002 chargement échoué: trop de canaux indiqués."
    return
}
if {![info exists tgplaying]} {
    set ctcp-version "${ctcp-version} (avec trivia.tcl $tgver ($tgrel) par www.eggdrop.za.net)"
    set tgplaying 0
}
if {![info exists tghintnum]} {set tghintnum 0}
if {![info exists tgmissed]} {set tgmissed 0}

#Binds
bind pubm $tgflagsstart "$tgchan %$tgcmdstart" tgstart
bind pubm $tgflagsstop "$tgchan %$tgcmdstop" tgstop
proc tgbindhintcmd {} {
    global tgflagshint tgcmdhint
    bind pubm $tgflagshint "$::tgchan %$tgcmdhint" tgforcehint
}
proc tgunbindhintcmd {} {
    global tgflagshint tgcmdhint
    unbind pubm $tgflagshint "$::tgchan %$tgcmdhint" tgforcehint
}
tgbindhintcmd
bind pubm $tgflagstop10 "$tgchan %$tgcmdtop10" tgshowtop10
bind join -|- "$tgchan *" tgjoinmsg
bind msg - $tgcmdhelp tggivehelp
bind msg - $tgcmdlookup tgscorelookup
bind msg - $tgcmdtarget tgtargetlookup
bind msg - $tgcmderror tgerror
bind msg - $tgcmdrules tgrulesmsg
bind msg $tgflagsreset "$tgcmdreset" tgresetscores
bind kick - "$tgchan $botnick" tgbotgotkicked
bind evnt - disconnect-server tgbotgotdisconnected

#lancé le jeu s'il n'est pas en marche.
proc tgstart {nick host hand chan text} {
    global tgplaying tgstreak tgchan tgerrremindtime tgerrremindtimer tgmissed
    if {[strlwr $tgchan]==[strlwr $chan]} {
        if {$tgplaying==0} {
            tggamemsg "[tgcolstart]Quizz démarré par $nick!"
            tgnextq
            set tgplaying 1
            set tgstreak 0
            set tgmissed 0
            set tgerrremindtimer [timer $tgerrremindtime tgerrremind]
        }
    }
}

#arrête le jeu s'il fonctionne.
proc tgstop {nick host hand chan text} {
    global tghinttimer tgnextqtimer tgplaying tgchan tgcurrentanswer tgstreak tgstreakmin
    global tgerrremindtimer tgrebindhinttimer
    if {[strlwr $tgchan]==[strlwr $chan]} {
        if {$tgplaying==1} {
            tggamemsg "[tgcolstop]Quizz arreté par $nick!"
            if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin} { tgstreakend }
            set tgstreak 0
            set tgplaying 0
            catch {unbind pubm -|- "$tgchan *" tgcheckanswer}
            if {[utimerexists tghint]!=""} {killutimer $tghinttimer}
            if {[utimerexists tgnextq]!=""} {killutimer $tgnextqtimer}
            if {[timerexists tgerrremind]!=""} {killtimer $tgerrremindtimer}
            if {[utimerexists tgrebindhinttimer]!=""} {killtimer $tgrebindhinttimer}
        }
    }
}

#donne un indice s'il y a actuellement une question à répondre.
proc tgforcehint {nick host hand chan text} {
    global tghinttimer tgnextqtimer tgplaying tgchan tgcurrentanswer tgstreak tgstreakmin
    global tgtempnohint tgmaxhintcurrent tghintnum tgrebindhinttimer tgtempnohint
    if {[strlwr $tgchan]==[strlwr $chan]} {
        if {$tgplaying==1&&[utimerexists tghint]!=""} {
            killutimer $tghinttimer
            tghint
            tgunbindhintcmd
            if {$tghintnum<$tgmaxhintcurrent} {
                set tgrebindhinttimer [utimer $tgtempnohint tgbindhintcmd]
            }
        }
    }
}

#saute la question courante si on le demande.
proc tgskip {nick host hand chan text} {
    global tghinttimer tgnextqtimer tgplaying tgchan tgcurrentanswer tgstreak
    global tgstreakmin tgtimenext tgrebindhinttimer
    if {[strlwr $tgchan]==[strlwr $chan]} {
        if {$tgplaying==1&&[utimerexists tghint]!=""} {
            tggamemsg "[tgcolskip]Saut vers la prochaine question par [tgcolmisc2]$nick[tgcolskip] "
            if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin&&[strlwr [lindex [split $tgstreak ,] 0]]==[strlwr $nick]} {
                tgstreakend
                set tgstreak 0
            }
            catch {unbind pubm -|- "$tgchan *" tgcheckanswer}
            killutimer $tghinttimer
            if {[utimerexists tgrebindhinttimer]!=""} {killtimer $tgrebindhinttimer}
            set tgnextqtimer [utimer $tgtimenext tgnextq]
        }
    }
}

#rappelle sur le canal comment rapporter des erreurs dans les questions/réponses
proc tgerrremind {} {
    global tgerrremindtimer tgerrremindtime botnick tgcmderror
    tggamemsg "[tgcolerr]Envoyez Toute Proposition de Questions à "
    set tgerrremindtimer [timer $tgerrremindtime tgerrremind]
}

#Arrete le quizz si le bot est kické
proc tgbotgotkicked {nick host hand chan targ text} {
    tgquietstop
}
#Arrete le quizz si le bot est déconnecté
proc tgbotgotdisconnected {disconnect-server} {
    tgquietstop
}

#arrête le jeu si plus sur le canal.
proc tgquietstop {} {
    global tgplaying tgstreak tgchan tgcurrentanswer tghinttimer tgnextqtimer tgerrremindtimer
    global tgrebindhinttimer
    if {$tgplaying==1} {
        set tgstreak 0
        set tgplaying 0
        catch {unbind pubm -|- "$tgchan *" tgcheckanswer}
        if {[utimerexists tghint]!=""} {killutimer $tghinttimer}
        if {[utimerexists tgnextq]!=""} {killutimer $tgnextqtimer}
        if {[timerexists tgerrremind]!=""} {killtimer $tgerrremindtimer}
        if {[utimerexists tgrebindhinttimer]!=""} {killtimer $tgrebindhinttimer}
    }
}

#lit la base de données de question.
proc tgreadqdb {} {
    global tgqdb tgquestionstotal tgquestionslist
    set tgquestionstotal 0
    set tgquestionslist ""
    set qfile [open $tgqdb r]
    set tgquestionslist [split [read -nonewline $qfile] "\n"]
    set tgquestionstotal [llength $tgquestionslist]
    close $qfile
}

#selectionne la prochaine question.
proc tgnextq {} {
    global tgqdb tgcurrentquestion tgcurrentanswer tgquestionnumber
    global tgquestionstotal tghintnum tgchan tgquestionslist tgqdbsep tgqdbquestionfirst
    global tgcapsquestion tgcapsanswer
    tgreadqdb
    set tgcurrentquestion ""
    set tgcurrentanswer ""
    while {$tgcurrentquestion == ""} {
        set tgquestionnumber [rand [llength $tgquestionslist]]            
        set tgquestionselected [lindex $tgquestionslist $tgquestionnumber]
        set tgcurrentquestion [lindex [split $tgquestionselected $tgqdbsep] [expr $tgqdbquestionfirst^1]]
        if {$tgcapsquestion==1} {
            set tgcurrentquestion [strupr $tgcurrentquestion]
        }
        set tgcurrentanswer [string trim [lindex [split $tgquestionselected $tgqdbsep] $tgqdbquestionfirst]]
        if {$tgcapsanswer==1} {
            set tgcurrentanswer [strupr $tgcurrentanswer]
        }
    }
    unset tghintnum
    tghint
    bind pubm -|- "$tgchan *" tgcheckanswer
    return
}

#Mise en place des indices.
proc tghint {} {
    global tgmaxhint tghintnum tgcurrentanswer tghinttimer tgchan
    global tgtimehint tghintchar tgquestionnumber tgquestionstotal
    global tgcurrentquestion tghintcharsused tgnextqtimer tgtimenext tgstreak tgstreakmin
    global tgnobodygotit tgtrythenextone tgmissed tgmaxmissed tgcmdstart tgshowanswer
    global tgtimestart tgtimeanswer tgalwaysshowq tgmaxhintcurrent tgtempnohint tgcapshint
    if {[catch {incr tghintnum}]!=0} {
        set tghintnum 0
        regsub -all -- "\[^A-Za-z0-9\]" [no_accent $tgcurrentanswer] "" _hintchars
        set tgmaxhintcurrent [expr [strlen $_hintchars]<=$tgmaxhint?[expr [strlen $_hintchars]-1]:$tgmaxhint]
        catch {tgunbindhintcmd}
        if {$tgmaxhintcurrent>0} {
            set tgrebindhinttimer [utimer $tgtempnohint tgbindhintcmd]
        }
    }
    if {$tghintnum >= [expr $tgmaxhintcurrent+1]} {
        incr tgmissed
        set _msg ""
        append _msg "[tgcolmiss][lindex $tgnobodygotit [rand [llength $tgnobodygotit]]]"
        if {$tgshowanswer==1} {
            append _msg "[tgcolmisc2]Trop tard![tgcolmiss] La réponse est ->  [tgcolmisc2]$tgcurrentanswer[tgcolmiss]  <-"
        }
        if {$tgmaxmissed>0&&$tgmissed>=$tgmaxmissed} {
            append _msg " Cela fait $tgmissed questions sans réponse ! Le quizz est automatiquement arrêté. pour le relancer, taper $tgcmdstart"
            tgquietstop
        } else {
            append _msg " [lindex $tgtrythenextone [rand [llength $tgtrythenextone]]]"
        }
        tggamemsg "[tgcolmiss]$_msg"
        if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin} { tgstreakend }
        set tgstreak 0
        catch {unbind pubm -|- "$tgchan *" tgcheckanswer}
        if {$tgmaxmissed==0||$tgmissed<$tgmaxmissed} {
            set tgnextqtimer [utimer $tgtimenext tgnextq]
        }
        return
    } elseif {$tghintnum == 0} {
        set i 0
        set _hint {}
        set tghintcharsused {}
        foreach word [split $tgcurrentanswer] {
            regsub -all -- "\[A-Za-z0-9\]" [no_accent $word] $tghintchar _current
            lappend _hint $_current
        }
        if {$tgtimeanswer==1} {
            set tgtimestart [clock clicks -milliseconds]
        }
    } elseif {$tghintnum == 1} {
        set i 0
        set _hint {}
        while {$i<[llength [split $tgcurrentanswer]]} {
            set _word [lindex [split $tgcurrentanswer] $i]
            set j 0
            set _newword {}
            while {$j<[strlen $_word]} {
                if {$j==0} {
                    append _newword [stridx $_word $j]
                    lappend tghintcharsused $i,$j
                } else {
                    if {[string is alnum [stridx $_word $j]]} {
                        append _newword $tghintchar
                    } else {
                        append _newword [stridx $_word $j]
                        lappend tghintcharsused $i,$j
                    }
                }
                incr j
            }
            lappend _hint $_newword
            incr i
        }
        } else {
            set i 0
            set _hint {}
            while {$i<[llength [split $tgcurrentanswer]]} {
                set _word [lindex [split $tgcurrentanswer] $i]
                set j 0
                set _newword {}
                set _selected [rand [strlen $_word]]
                regsub -all -- "\[^A-Za-z0-9\]" [no_accent $_word] "" _wordalnum
                if {[strlen $_wordalnum]>=$tghintnum} {
                    while {[lsearch $tghintcharsused $i,$_selected]!=-1||[string is alnum [stridx $_word $_selected]]==0} {
                     set _selected [rand [strlen $_word]]
                    }
                }
                lappend tghintcharsused $i,$_selected
                while {$j<[strlen $_word]} {
                    if {[lsearch $tghintcharsused $i,$j]!=-1||[string is alnum [stridx $_word $j]]==0} {
                        append _newword [stridx $_word $j]
                    } else {
                        if {[string is alnum [stridx $_word $j]]} {
                            append _newword $tghintchar
                        }
                }
                incr j
            }
            lappend _hint $_newword
            incr i
        }
    }
    if {$tgcapshint==1} {
        set _hint [strupr $_hint]
    }
    tggamemsg "[tgcolqhead][expr $tghintnum?"($tghintnum/$tgmaxhintcurrent)":""] "
    if {$tgalwaysshowq==1||$tghintnum==0} {
        tggamemsg "[tgcolqbody]$tgcurrentquestion"
    }
    tggamemsg "[tgcolhint]Aide: [join $_hint]"
    set tghinttimer [utimer $tgtimehint tghint]
}

#déclenché quand quelqu'un emploie la commande !top10
proc tgshowtop10 {nick host hand chan text} {
    global tgscores tgchan tgscorestotal
    if {[strlwr $chan]==[strlwr $tgchan]} {
        tggetscores
        if {$tgscorestotal>0} {
            if {$tgscorestotal>9} {
                set _max 9
            } else {
                set _max [expr $tgscorestotal-1]
            }
            set i 0
            while {$i<=$_max} {
                set _item [lindex $tgscores $i]
                set _nick [join [lindex [split $_item ,] 2]]
                set _score [join [lindex [split $_item ,] 0]]
                if {$i==0} {
                    append _scores "[tgcolscr1]$_nick $_score"
                } elseif {$i==1} {
                    append _scores ", [tgcolscr2]$_nick $_score"
                } elseif {$i==2} {
                    append _scores ", [tgcolscr3]$_nick $_score"
                } else {
                    append _scores ", [tgcolmisc1]$_nick $_score"
                }
                incr i
            }
            tggamemsg "[tgcolmisc1]Top 10: $_scores"
        } else {
            tggamemsg "[tgcolmisc1]Pas de score pour l'instant."
        }
    }
}

#vérifie si n'importe qui a indiqué la réponse correcte sur le canal.
proc tgcheckanswer {nick host hand chan text} {
    global tgcurrentanswer
    putlog [tgstripcodes $text]
    if {[strlwr [no_accent $tgcurrentanswer]] == [tgstripcodes [strlwr [string trim [no_accent $text]]]]} {
        tgcorrectanswer $nick
    }
}

#déclenché quand quelqu'un dit la réponse correcte.
proc tgcorrectanswer {nick} {
    global tgcurrentanswer tghinttimer tgtimenext tgchan tgnextqtimer tgstreak tgstreakmin
    global tgscoresbyname tgranksbyname tgranksbynum tgcongrats tgscorestotal tgmissed
    global tgtimestart tgshowallscores tgrealnames tgscoresbyrank tgtimeanswer tgmulti
    tggetscores
    if {![info exists tgranksbyname([strlwr $nick])]} {
        set _oldrank 0
    } else {
        set _oldrank $tgranksbyname([strlwr $nick])
    }
    tgincrscore $nick
    tggetscores
    set _newrank $tgranksbyname([strlwr $nick])
    set _timetoanswer ""
    if {$tgtimeanswer==1} {
        set _timetoanswer [expr [expr [clock clicks -milliseconds]-$tgtimestart]/1000.00]
    }
    set _msg "[tgcolmisc1][lindex $tgcongrats [rand [llength $tgcongrats]]] [tgcolmisc2]$nick[tgcolmisc1]! La réponse était [tgcolmisc2]$tgcurrentanswer[tgcolmisc1].[expr $tgtimeanswer==1?" Tu l'as trouvé en [tgcolmisc2]$_timetoanswer[tgcolmisc1] seconds.":""]"
    if {$_newrank<$_oldrank} {
        if {$_newrank==1} {
            append _msg " Tu es maintenant en 1er position!"
        } else {
            if {$tgshowallscores==0} {
                append _msg " Tu as changé de place!"
            } else {
                append _msg " Tu es maintenant classé [tgcolmisc2][ordnumber $tgranksbyname([strlwr $nick])][tgcolmisc1] sur [tgcolmisc2]$tgscorestotal[tgcolmisc1], derrière [tgcolmisc2]$tgrealnames($tgranksbynum([expr $_newrank-1]))[tgcolmisc1] avec [tgcolmisc2]$tgscoresbyrank([expr $_newrank-1])[tgcolmisc1]."
            }
        }
    }
    tggamemsg "$_msg"
    if {$tgstreak!=0} {
        if {[lindex [split $tgstreak ,] 0]==[strlwr $nick]} {
            set tgstreak [strlwr $nick],[expr [lindex [split $tgstreak ,] 1]+1]
            if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin} {
                tggamemsg "[tgcolstrk][tgcolmisc2]$nick[tgcolstrk] [lindex $tgmulti [rand [llength $tgmulti]]] [tgcolmisc2][lindex [split $tgstreak ,] 1] [tgcolstrk]réponses consécutives!"
            }
        } else {
            if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin} { tgstreakend }
            set tgstreak [strlwr $nick],1
        }
    } else {
        set tgstreak [strlwr $nick],1
    }
    set tgmissed 0
    tgshowscores $nick
    catch {unbind pubm -|- "$tgchan *" tgcheckanswer}
    killutimer $tghinttimer
    set tgnextqtimer [utimer $tgtimenext tgnextq]
}

#lire les scores à partir du fichier, les classés  et les entreposé dans la variable.
proc tggetscores {} {
    global tgscf tgscorestotal tgscores tgscoresbyname tgranksbyname tgranksbynum
    global tgrealnames tgscoresbyrank
    if {[file exists $tgscf]&&[file size $tgscf]>2} {
        set _sfile [open $tgscf r]
        set tgscores [lsort -dict -decreasing [split [gets $_sfile]]]
        close $_sfile
        set tgscorestotal [llength $tgscores]
    } else {
        set tgscores ""
        set tgscorestotal 0
    }
    if {[info exists tgscoresbyname]} {unset tgscoresbyname}
    if {[info exists tgranksbyname]} {unset tgranksbyname}
    if {[info exists tgrealnames]} {unset tgrealnames}
    if {[info exists tgranksbynum]} {unset tgranksbynum}
    set i 0
    while {$i<[llength $tgscores]} {
        set _item [lindex $tgscores $i]
        set _nick [lindex [split $_item ,] 2]
        set _lwrnick [lindex [split $_item ,] 3]
        set _score [lindex [split $_item ,] 0]
        set tgscoresbyname($_lwrnick) $_score
        set tgrealnames($_lwrnick) $_nick
        set tgranksbyname($_lwrnick) [expr $i+1]
        set tgranksbynum([expr $i+1]) $_lwrnick
        set tgscoresbyrank([expr $i+1]) $_score
        incr i
    }
    return
}

#incrément les points de la personne points.
proc tgincrscore {who} {
    global tgscores tgscf tgpointsperanswer tgscorestotal tgscoresbyname tghintnum
    tggetscores
    if {$tgscorestotal>0} {
        set i 0
        if {![info exists tgscoresbyname([strlwr $who])]} {
	        append _newscores "[expr $tgpointsperanswer-$tghintnum],[expr 1000000000000.0/[unixtime]],$who,[strlwr $who] "
            #append _newscores "1,[expr 1000000000000.0/[unixtime]],$who,[strlwr $who] "
        }
        while {$i<[llength $tgscores]} {
            set _item [lindex $tgscores $i]
            set _nick [lindex [split $_item ,] 2]
            set _time [lindex [split $_item ,] 1]
            set _score [lindex [split $_item ,] 0]
            if {[strlwr $who]==[strlwr $_nick]} {
	            append _newscores "[expr $_score+$tgpointsperanswer-$tghintnum],[expr 1000000000000.0/[unixtime]],$who,[strlwr $who][expr [expr [llength $tgscores]-$i]==1?"":"\ "]"
                #append _newscores "[expr $_score+$tgpointsperanswer],[expr 1000000000000.0/[unixtime]],$who,[strlwr $who][expr [expr [llength $tgscores]-$i]==1?"":"\ "]"
            } else {
                append _newscores "$_score,$_time,$_nick,[strlwr $_nick][expr [expr [llength $tgscores]-$i]==1?"":"\ "]"
            }
            incr i
        }
    } else {
	    append _newscores "[expr $tgpointsperanswer-$tghintnum],[expr 1000000000000.0/[unixtime]],$who,[strlwr $who]"
        #append _newscores "1,[expr 1000000000000.0/[unixtime]],$who,[strlwr $who]"
    }
    set _sfile [open $tgscf w]
    puts $_sfile "$_newscores"
    close $_sfile
    return
}

#montre les points courants sur le canal.
proc tgshowscores {nick} {
    global tgscores tgchan tgscorestotal tgshowallscores tgranksbyname tgranksbynum
    global tgscoresbyname tgrealnames tgscoresbyrank
    tggetscores
    set i 0
    if {$tgshowallscores} {
        while {$i<[llength $tgscores]} {
            set _item [lindex $tgscores $i]
            set _nick [lindex [split $_item ,] 2]
            set _score [lindex [split $_item ,] 0]
            if {$i==0} {
                append _scores "[tgcolscr1]$_nick $_score"
            } elseif {$i==1} {
                append _scores ", [tgcolscr2]$_nick $_score"
            } elseif {$i==2} {
                append _scores ", [tgcolscr3]$_nick $_score"
            } elseif {[onchan $_nick $tgchan]} {
                append _scores ", [tgcolmisc1]$_nick $_score"
            }
            incr i
        }
        tggamemsg "[tgcolmisc1]Les scores: $_scores"
    } else {
        if {$tgranksbyname([strlwr $nick])==1} {
            set _tgt "."
        } else {
            set _tgt ", derrière [tgcolmisc2]$tgrealnames($tgranksbynum([expr $tgranksbyname([strlwr $nick])-1]))[tgcolmisc1] avec [tgcolmisc2]$tgscoresbyrank([expr $tgranksbyname([strlwr $nick])-1])[tgcolmisc1]."
        }
        tggamemsg "[tgcolmisc2]$nick [tgcolmisc1]a maintenant [tgcolmisc2]$tgscoresbyname([strlwr $nick]) [tgcolmisc1][expr $tgscoresbyname([strlwr $nick])==1?"point":"points"] et est classé [tgcolmisc2][ordnumber $tgranksbyname([strlwr $nick])] [tgcolmisc1]sur [tgcolmisc2]$tgscorestotal[tgcolmisc1]$_tgt"
    }
}

#remettre à zéro les scores.
proc tgresetscores {nick host hand text} {
    global tgscf tgscorestotal tgscores tgplaying tgresetreqpw
    if {($tgresetreqpw==1 && [passwdok $hand $text]) || $tgresetreqpw==0} {
        if {[file exists $tgscf]&&[file size $tgscf]>2} {
            set _sfile [open $tgscf w]
            puts $_sfile ""
            close $_sfile
            set tgscores ""
            set tgscorestotal 0
        }
        tggamemsg "[tgcolrset]===== Mise à zéro du classement par $nick! ====="
    }
}

#déclenché quand une série dis de 'bonne réponse' est fini.
proc tgstreakend {} {
        global tgstreak tgrealnames
        tggamemsg "[tgcolstend]Dommage pour [tgcolmisc2]$tgrealnames([lindex [split $tgstreak ,] 0])[tgcolstend] qui avait l'air en forme !"
        return
}

#déclenché quand quelqu'un join le chan.
proc tgjoinmsg {nick host hand chan} {
    global botnick tgplaying tgcmdhelp tgcmdstart tgflagsstart tgcmdstop tgflagsstop tgchan
    if {$nick != $botnick} {
        set _msg ""
        append _msg "Bienvenue sur #channel, Le quizz est actuellement"
        if {$tgplaying==1} {
            append _msg " \002activé\002."
        } else {
            append _msg " \002désactivé\002."
        }
        if {[matchattr $hand $tgflagsstart $tgchan]&&$tgplaying==0} {
            append _msg " Pour démarrer le jeu , taper \002$tgcmdstart\002 sur $tgchan."
        }
        if {[matchattr $hand $tgflagsstop $tgchan]&&$tgplaying==1} {
            append _msg ""
        }
        append _msg " Si vous avez besoin d'aide, Taper /MSG  Help ,  Bon jeu :-)"
        puthelp "[tgpriv] $nick :$_msg"
    }
 
}

#déclenché quand quelqu'un /msgs le BOT avec la commande de consultation de points.
proc tgscorelookup {nick host hand text} {
    global tgscoresbyname tgranksbyname tgscorestotal tgrealnames
    if {$text==""} { set text $nick } else { set text [lindex [split $text] 0] }
    tggetscores
    if {![info exists tgscoresbyname([strlwr $text])]} {
        if {[strlwr $text]==[strlwr $nick]} {
            set _who "[tgcolmisc1]Tu as"
        } else {
            set _who "[tgcolmisc2]$text [tgcolmisc1]est"
        }
        puthelp "[tgpriv] $nick :[tgbold]$_who [tgcolmisc1]visiblement pas classé."
    } else {
        if {[strlwr $text]==[strlwr $nick]} {
            set _who "[tgcolmisc1]Tu as"
        } else {
            set _who "[tgcolmisc2]$tgrealnames([strlwr $text]) [tgcolmisc1]a"
        }
        puthelp "[tgpriv] $nick :[tgbold]$_who [tgcolmisc2]$tgscoresbyname([strlwr $text])[tgcolmisc1] points, classé [tgcolmisc2][ordnumber $tgranksbyname([strlwr $text])] [tgcolmisc1]sur [tgcolmisc2]$tgscorestotal[tgcolmisc1]."
    }
 
}

#déclenché quand quelqu'un /msgs le BOT avec la commande de consultation de cible.
proc tgtargetlookup {nick host hand text} {
    global tgscoresbyname tgranksbyname tgscorestotal tgranksbynum tgrealnames
    tggetscores
    if {![info exists tgscoresbyname([strlwr $nick])]} {
        puthelp "[tgpriv] $nick :[tgbold][tgcolmisc1]Tu n'es pas dans le classement."
    } elseif {$tgranksbyname([strlwr $nick])==1} {
        puthelp "[tgpriv] $nick :[tgbold][tgcolmisc1]Tu es à la [tgcolmisc2]1ère[tgcolmisc1] place!"
    } else {
        puthelp "[tgpriv] $nick :[tgbold][tgcolmisc1]Tu as [tgcolmisc2]$tgscoresbyname([strlwr $nick])[tgcolmisc1] points. Devant toi se trouve [tgcolmisc2]$tgrealnames($tgranksbynum([expr $tgranksbyname([strlwr $nick])-1])) [tgcolmisc1]avec [tgcolmisc2]$tgscoresbyname($tgranksbynum([expr $tgranksbyname([strlwr $nick])-1]))[tgcolmisc1] points, placé [tgcolmisc2][ordnumber [expr $tgranksbyname([strlwr $nick])-1]] [tgcolmisc1]sur [tgcolmisc2]$tgscorestotal[tgcolmisc1]."
    }
 
}

#déclenché quand quelqu'un /msgs le BOT avec la commande de reportage d'erreur.
proc tgerror {nick host hand text} {
    global tgquestionstotal tgquestionslist tgerrmethod tgerrfil tgerremail tgerrmailtmp
    if {$text==""||![string is int [lindex [split $text] 0]]} {
        puthelp "[tgpriv] $nick :[tgbold][tgcolmisc1]Tu dois spécifier un numéro de question."
        return
    }
    tgreadqdb
    set _qnum [lindex [split $text] 0]
    if {$_qnum>$tgquestionstotal} {
        puthelp "[tgpriv] $nick :[tgbold][tgcolmisc1]Cette question n'existe pas."
        return
    }
    set _qques [lindex [split [lindex $tgquestionslist [expr $_qnum-1]] |] 1]
    set _qans [lindex [split [lindex $tgquestionslist [expr $_qnum-1]] |] 0]
    set _desc [join [lrange [split $text] 1 end]]
    if {$_desc==""} { set _desc "Aucune autre information donnée pour cette erreur." }
    if {$tgerrmethod==1} {
        set _fname $tgerrmailtmp/trivia[rand 100000].tmp
        set _file [open $_fname w]
    } else {
        set _file [open $tgerrfil a]
    }
    puts $_file ""
    puts $_file "Rapport d'erreur généré le [strftime %A,\ %d\ %B\ %Y\ @\ %H:%M:%S]"
    puts $_file "Reporter par:\t$nick!$host"
    puts $_file "Question n°:\t$_qnum"
    puts $_file "Question:\t\t$_qans"
    puts $_file "Réponse:\t\t$_qques"
    puts $_file "Commentaire:\t$_desc"
    puts $_file "------------------------------"
    close $_file
    if {$tgerrmethod==1} {
        exec mail -s "trivia.tcl erreur reportée par $nick" $tgerremail < $_fname
        file delete $_fname
        puthelp "[tgpriv] $nick :[tgbold][tgcolmisc1]Merci! Votre report d'erreur a été envoyé par e-mail à l'owner."
    } else {
        puthelp "[tgpriv] $nick :[tgbold][tgcolmisc1]Merci! Votre report d'erreur a été enregistré, il sera regardé dès que possible."
    }
 
}

#déclenché quand quelqu'un /msg le BOT avec la commande pour voir les règles.
proc tgrulesmsg {nick host hand text} {
    global tgrules
    puthelp "[tgpriv] $nick :[tgcolqhead]Voici les règles à respecter: $tgrules"
}
#déclenché quand quelqu'un /msg le BOT avec la commande d'aide.
proc tggivehelp {nick host hand {text ""}} {
    global botnick tgcmdlookup tgcmdhelp tgcmdstart tgcmdstop tgchan tgflagsstop
    global tgcmdstop tgflagshint tgcmdhint tgflagsskip tgcmdskip tgflagsreset tgcmdreset
    global tgcmdtarget tgcmderror tgcmdrules tgflagsstart
    if {$text==""} {
        puthelp "[tgpriv] $nick : [tgcolqhead]-Vous avez access à ces commands: Taper, /MSG $botnick command"
        puthelp "[tgpriv] $nick : "
        puthelp "[tgpriv] $nick : [tgcolerr]Liste des commands:"
        puthelp "[tgpriv] $nick : -------------------------------------------------------------------------"
        puthelp "[tgpriv] $nick : "
        puthelp "[tgpriv] $nick : - Règles => Listes des règles du canal."
        puthelp "[tgpriv] $nick : - Score \[nick\] => Voir le rang et les points de \[nick\]."
        puthelp "[tgpriv] $nick : - Place => Voir votre rang et le rang et les points de la personne qui est devant vous."
        puthelp "[tgpriv] $nick : - Signalez les erreurs => Rapporter les erreurs sur les questions en envoyant vos réclamations ; La description doit être complète et claire afin de résoudre ce problème rapidement et facilement."
        puthelp "[tgpriv] $nick : "
        puthelp "[tgpriv] $nick : --------------------------------------------------------------------------"
        puthelp "[tgpriv] $nick : [tgcolerr]Sur le channel Tapez:"
        puthelp "[tgpriv] $nick : !dico <mot> ==> pour chercher la définition" 
        puthelp "[tgpriv] $nick : !tra en-fr <mot> ==> pour traduire un mot ex : Français à l'anglais (en-fr), Français a l'italien (fr-it)"
        puthelp "[tgpriv] $nick : !images <désignation> ==> pour chercher une image" 
        puthelp "[tgpriv] $nick : !google define:mot ==> chercher une définition ex : (!google define:economie)" 
        puthelp "[tgpriv] $nick : "
        puthelp "[tgpriv] $nick : ----------------------------------------------------------------------------"
        puthelp "[tgpriv] $nick :[tgcolerr] N'hésitez pas à envoyez vos suggestions sur "
        puthelp "[tgpriv] $nick :                    [tgcolerr]Culture Team"
        }
        if {[strlwr $text]=="pubcmds"} {
        puthelp "[tgpriv] $nick :Vous avez accès aux commandes suivantes:"
        if {[matchattr $hand $tgflagsstart $tgchan]} {
            puthelp "[tgpriv] $nick :  \002$tgcmdstart\002 -- Démarrer le Quizz."
        }
        if {[matchattr $hand $tgflagsstop $tgchan]} {
            puthelp "[tgpriv] $nick :  \002$tgcmdstop\002 -- Stopper le Quizz."
 
        }
        if {[matchattr $hand $tgflagshint $tgchan]} {
            puthelp "[tgpriv] $nick :  \002$tgcmdhint\002 -- Donner un indice."
        }
        if {[matchattr $hand $tgflagsskip $tgchan]} {
            puthelp "[tgpriv] $nick :  \002$tgcmdskip\002 -- Passer à la question suivantes."
        }
        puthelp "[tgpriv] $nick :Pour avoir la liste des /MSG commands, /MSG $botnick [strupr $tgcmdhelp]"
 
    }
}
# Renvoie le texte sans codes de couleur, "bold", etc. de commande.
# C'est dépouillé en bas de la version du proc dans MC_8's mc.moretools.tcl.
proc tgstripcodes {text} {
    regsub -all -- "\003(\[0-9\]\[0-9\]?(,\[0-9\]\[0-9\]?)?)?" $text "" text
    set text "[string map -nocase [list \002 "" \017 "" \026 "" \037 ""] $text]"
    return $text
}
 
proc tggamemsg {what} {
    global tgchan
    putquick "PRIVMSG $tgchan :[tgbold]$what"
}
 
proc tgbold {} {
    global tgusebold
    if {$tgusebold==1} { return "\002" }
}
proc tgcolstart {} {
    global tgcolourstart
    if {$tgcolourstart!=""} { return "\003$tgcolourstart" }
}
proc tgcolstop {} {
    global tgcolourstop
    if {$tgcolourstop!=""} { return "\003$tgcolourstop" }
}
proc tgcolskip {} {
    global tgcolourskip
    if {$tgcolourskip!=""} { return "\003$tgcolourskip" }
}
proc tgcolerr {} {
    global tgcolourerr
    if {$tgcolourerr!=""} { return "\003$tgcolourerr" }
}
proc tgcolmiss {} {
    global tgcolourmiss
    if {$tgcolourmiss!=""} { return "\003$tgcolourmiss" }
}
proc tgcolqhead {} {
    global tgcolourqhead
    if {$tgcolourqhead!=""} { return "\003$tgcolourqhead" }
}
proc tgcolqbody {} {
    global tgcolourqbody
    if {$tgcolourqbody!=""} { return "\003$tgcolourqbody" }
}
proc tgcolhint {} {
    global tgcolourhint
    if {$tgcolourhint!=""} { return "\003$tgcolourhint" }
}
proc tgcolstrk {} {
    global tgcolourstrk
    if {$tgcolourstrk!=""} { return "\003$tgcolourstrk" }
}
proc tgcolscr1 {} {
    global tgcolourscr1
    if {$tgcolourscr1!=""} { return "\003$tgcolourscr1" }
}
proc tgcolscr2 {} {
    global tgcolourscr2
    if {$tgcolourscr2!=""} { return "\003$tgcolourscr2" }
}
proc tgcolscr3 {} {
    global tgcolourscr3
    if {$tgcolourscr3!=""} { return "\003$tgcolourscr3" }
}
proc tgcolrset {} {
    global tgcolourrset
    if {$tgcolourrset!=""} { return "\003$tgcolourrset" }
}
proc tgcolstend {} {
    global tgcolourstend
    if {$tgcolourstend!=""} { return "\003$tgcolourstend" }
}
proc tgcolmisc1 {} {
    global tgcolourmisc1
    if {$tgcolourmisc1!=""} { return "\003$tgcolourmisc1" }
}
proc tgcolmisc2 {} {
    global tgcolourmisc2
    if {$tgcolourmisc2!=""} { return "\003$tgcolourmisc2" }
}
proc tgpriv {} {
    global tgpriv2msg
    if {$tgpriv2msg==1} { return "PRIVMSG" } else { return "NOTICE" }
}

#ceci produit une page HTML avec toutes les personnes sur le chan avec
#leurs points, aussi bien qu'une liste de tous les points, assortie par le rang
proc tghtml {} {
    global tgchan botnick tghtmlfile tghtmlrefresh server tgscoresbyname tgranksbyname
    global tgscorestotal tgranksbyname tgrealnames tgscoresbyrank tgranksbynum tgplaying
    global tgquestionstotal tghtmlrefreshtimer tghtmlfont
    tggetscores
    tgreadqdb
    set _file [open $tghtmlfile~new w]
    puts $_file "<!DOCTYPE HTML PUBLIC \"-/W3C/DTD HTML 4.01 Transitional/EN\">"
    puts $_file "<html>"
    puts $_file " <head>"
    puts $_file "  <title>Quizz sur $tgchan </title>"
    puts $_file "  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"
    puts $_file "  <meta http-equiv=\"refresh\" content=\"$tghtmlrefresh\">"
    puts $_file "  <meta name=\"generator\" content=\"trivia.tcl script pour eggdrop. http://www.eggdrop.za.net/\">"
    puts $_file "  <style type=\"text/css\">"
    puts $_file "  <!--"
    puts $_file "  body,td{font-family:$tghtmlfont;font-size:13px;}"
    puts $_file "  a{text-decoration:none;color:#09f;}"
    puts $_file "  -->"
    puts $_file "  </style>"
    puts $_file " </head>"
    puts $_file " <body>"
    puts $_file "  <h1>$tgchan sur [lindex [split $server :] 0]</h1>"
    puts $_file "  <hr size=\"1\" noshade>"
    if {![onchan $botnick $tgchan]} {
        puts $_file "  <p>Hmmm... Il y a personne de connecté sur le chan pour le moment.</p>"
    } else {
        puts $_file "  <p>Le quizz est actuellement  <b>[expr $tgplaying==1?"activé":"désactivé"]</b>. Il y a <b>$tgquestionstotal</b> questions dans la database."
        puts $_file "  <p>En ce moment sur $tgchan :<br>"
        puts $_file "  <table width=\"50%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><table width=\"100%\" cellspacing=\"3\" border=\"0\">"
        puts $_file "   <tr>"
        puts $_file "    <td><b>Nick</b></td>"
        puts $_file "    <td><b>Score</b></td>"
        puts $_file "    <td><b>place</b></td>"
        puts $_file "    <td><b>Idle</b></td>"
        puts $_file "   </tr>"
        foreach nick [lsort [chanlist $tgchan]] {
            puts $_file "   <tr>"
            puts $_file "    <td>[expr [isop $nick $tgchan]?"@":""][expr [isvoice $nick $tgchan]?"+":""]$nick[expr [string match $nick $botnick]?" (C moi!)":""]</td>"
            if {[info exists tgscoresbyname([strlwr $nick])]} {
                puts $_file "    <td>$tgscoresbyname([strlwr $nick])</td>"
            } else {
                puts $_file "    <td>-</td>"
            }
            if {[info exists tgranksbyname([strlwr $nick])]} {
                puts $_file "    <td>$tgranksbyname([strlwr $nick])</td>"
            } else {
                puts $_file "    <td>-</td>"
            }
            puts $_file "   <td>[expr [getchanidle $nick $tgchan]>10?"[getchanidle $nick $tgchan]m":"-"]</td>"
            puts $_file "   </tr>"
        }
        puts $_file "  </table></td></tr></table>"
    }
    if {$tgscorestotal>0} {
        puts $_file "  <p><small>il y a <b>$tgscorestotal</b> [expr $tgscorestotal==1?"nick":"nicks"] dans le classement:<br>"
        set _rank 1
        while {$_rank<=$tgscorestotal} {
            puts $_file "  <b>$_rank</b>. $tgrealnames($tgranksbynum($_rank)) $tgscoresbyrank($_rank)<br>"
            incr _rank
        }
    } else {
        puts $_file "  <p><small>Il n'y a actuellement personne dans le classement.<br>"
    }
    puts $_file "  </small></p>"
    puts $_file "  <hr size=\"1\" noshade>"
    puts $_file "  <small>Générée le [strftime %A,\ %d\ %B\ %Y\ @\ %H:%M:%S] avec <a href=\"http://www.eggdrop.za.net/\">trivia.tcl</a> pour <a href=\"http://www.eggheads.org\">eggdrop</a>.<br>"
    puts $_file "  Cette page est réactualisée automatiquement toutes les [expr $tghtmlrefresh==1?"second":"$tghtmlrefresh seconds"].</small>"
    puts $_file " </body>"
    puts $_file "</html>"
    close $_file
    file rename -force $tghtmlfile~new $tghtmlfile
    set tghtmlrefreshtimer [utimer $tghtmlrefresh tghtml]
}





RE: Trivia TCl ( points variable ) - BdS - 03/03/2008

Je t'ai donné une aide en te disant que a mon niveau j'avais joué sur les indices ... tu as un timer apres chaque indice donné, donc a chaque indice je lui fait changé la variable des points gagné.

Parcontre faut changer pas mal le script ...


RE: Trivia TCl ( points variable ) - nathan - 31/03/2008

svp vous pouvez me donner le lien dou je pourais telecharger ce quizz ? merci


RE: Trivia TCl ( points variable ) - MenzAgitat - 31/03/2008

Regarde dans la section téléchargements.


RE: Trivia TCl ( points variable ) - Behemoth - 03/11/2009

Soir tlm
J'espère que vous allez bien..

Voilà, j ai un soucis pas trop grave..

tcl
[14:04] Tcl error [tgstart]: can't read "tgmaxhintcurrent": no such variable
.set Tcl error [tgstart]: can't read "tgmaxhintcurrent": no such variable
 Error: extra characters after close-quote



depuis 2 jours j cherche ou se trouve ce 'close-quote' mais j ai pas réussi.

j sais pas si c ma cervelle ou mes yeux.. svp aidez moi..

PS: Le script est celui posté par CrazyCat --> http://www.eggdrop.fr/board/downloads.php?action=view&did=34


RE: Trivia TCl ( points variable ) - fedora - 03/11/2009

bonsoir,

un Souci du même genre à était résolu.

regarde par ici :
Trivia [Résolu]


cordialement


RE: Trivia TCl ( points variable ) - Behemoth - 03/11/2009

Soir fedora

J te remercie beaucoup.
Il marche à merveille maintenant..

PS : Ma cervelle et mes yeux ont tous les 2 une défaillance téchnique..

Bonne soirée à vous Smile


RE: Trivia TCl ( points variable ) - MRVOLKANO - 30/04/2010

bonjour

j'aimerais si sais possible de faire dire le top10 automatiquement sur un chan sans etre oubliger de tapper !top10 .
pis j'aimerais le faire dire le top10 a toute les x minutes si sais possible bien sur . dsl chui pas fort en tcl pour modifier certain chose ..jais le quizz trivia celui posté par CrazyCat .


svp.si qq1 pourrais m'aider ...Merci d'Avance Smile