Trivia : les indices continuent après réponse
#1
Bonsoir,

J'ai résolu pas mal de problèmes avec mon Trivia qui datais d'une époque fiouuuuuuu mais après m'avoir connecté sur le réseau IRC ou il tourne j'ai eu quelques réclamations sur un Bug énoncé dans le titre du sujet " Après réponse les indices continuent " ce qui est plutôt casse bonbons :p

Voilà un petit screen de l'histoire des indices :

[Image: http://imagesup.org/images11/1351535791-...12-10-.png]

Voici la proc de la mise en place des indices :

tcl
#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} {}
	if {![info exists tghintnum]} {
        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]
        }
    } else { incr tghintnum }
    if {$tghintnum >= [expr $tgmaxhintcurrent+1]} {
        incr tgmissed
        set _msg ""
        append _msg " [tgcolmiss][lindex $tgnobodygotit [rand [llength $tgnobodygotit]]]"
        if {$tgshowanswer==1} {
            append _msg "09,01La réponse était [tgcolmisc2]13,01$tgcurrentanswer[tgcolmiss]."
        }
        if {$tgmaxmissed>0&&$tgmissed>=$tgmaxmissed} {
            append _msg " Cela fait $tgmissed questions sans réponse ! Le  quizz a ete automatiquement arreté. pour le relancer, tapez 04$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]
    }
    if {$tgalwaysshowq==1||$tghintnum==0} {
        tggamemsg "04,01 -07,01\[\Question n°[expr $tgquestionnumber+1]\]\04,01-[tgcolqbody] $tgcurrentquestion ? "
    }
    tggamemsg "04,01 € 07,01Indice : 08,01[join $_hint] "
    set tghinttimer [utimer $tgtimehint tghint]
}



Puis la vérification lorsque une réponse est donné :

tcl
#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]
    }
	if !([isvoice $nick $tgchan]||[isop $nick $tgchan]) {
			putserv "MODE $tgchan +v $nick"
	}
    set _msg "[tgcolmisc1] [lindex $tgcongrats [rand [llength $tgcongrats]]] [tgcolmisc2]13,01$nick[tgcolmisc1] ! La réponse était [tgcolmisc2]13,01$tgcurrentanswer[tgcolmisc1].[expr $tgtimeanswer==1?" Tu l'as trouvée en [tgcolmisc2]13,01$_timetoanswer[tgcolmisc1] secondes. ":""]"
    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]e 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]13,01 $nick[tgcolstrk]09,01 [lindex $tgmulti [rand [llength $tgmulti]]] [tgcolmisc2]13,01[lindex [split $tgstreak ,] 1] [tgcolstrk]09,01ré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]
}



Une petite idée ?
Répondre Avertir
#2
C'est un timer qui ne s'arrete pas (pour moi). Mais tu dois avoir une erreur en partyline (DCC chat avec le robot).
Si tu peux poste la, je/on pourra mieux t'aider.
Autre chose, quelle version d'eggdrop utilises ?
CrazyCat a écrit :La prochaine fois, essaye d'imaginer que j'ai un cerveau ...
Répondre Avertir
#3
Merci d'avoir répondu, donc pour la version c'est le Eggdrop v1.6.21 et j'ai l'erreur suivante après un .set errorInfo

Code :
<kipof> .set errorInfo
<Game> [20:34:00] #kipof# set errorInfo
<Game> Currently: no such binding
<Game> Currently:     while executing
<Game> Currently: "unbind pubm -|- "$tgchan *" tgcheckanswer"

la proc :

tcl
#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
    }
}


Répondre Avertir
#4
Tu n'as pas une erreur d'une ligne que le robot balance, sans avoir a faire un .setblabla ?
CrazyCat a écrit :La prochaine fois, essaye d'imaginer que j'ai un cerveau ...
Répondre Avertir
#5
Nan, aucune :/

Dans les logs j'ai trouvé :

Code :
[12:18:35] Tcl error [tgcheckanswer]: invalid timerID
[12:54:41] Tcl error [tgcheckanswer]: invalid timerID
[15:44:20] Tcl error [tgcheckanswer]: invalid timerID
[15:52:04] Tcl error [tgcheckanswer]: invalid timerID
[16:44:34] (!) timer drift -- spun 6 minutes
[16:44:00] (!) timer drift -- spun 57 minutes
[16:52:23] (!) timer drift -- spun 2 minutes

Timer comme tu avais dis :/
Répondre Avertir
#6
Tcl error [tgcheckanswer]: invalid timerID
Donc, il n'arrive pas à tuer le bon timer, donc l'indice s'affiche.
Répondre
#7
Alors pour ça je ne suis pas assez bon/assez a la page pour corriger ce problème.
En fait je ne me rappel plus si c'est a cause de tcl8.5 ou de la dernière version d'eggdrop, mais comme le code est vieux les killtimers ne fonctionne pas et j'ai eu le même problème que toi.

Pour "résoudre" ce problème j'ai du revenir à la version précédente d'eggdrop1.6.20 ou tcl8.4.

Si un vrai codeur passe dans le coin (CrazyCat j'ai dis un VRAI lol), je suis preneur aussi d'une vraie solution.
CrazyCat a écrit :La prochaine fois, essaye d'imaginer que j'ai un cerveau ...
Répondre Avertir
#8
le passage à 1.6.20 encore je dis pas mais changer ma version tcl en 8.4 huhu xD
Répondre Avertir
#9
J'avais la flemme de vérifier, mais j'ai bien tcl8.5 d'installer sur mon serveur et j'ai eggdrop1.6.20
C'est bien la version de l'eggdrop que j'ai changé
CrazyCat a écrit :La prochaine fois, essaye d'imaginer que j'ai un cerveau ...
Répondre Avertir
#10
Demain je test la version 1.6.20 en espérant que cela est la solution donc demain je reviens pour te sauter dessus BdS et te bisouter ou continuer à pleurer xD
Merci beaucoup des reponses
Répondre Avertir
#11
Une solution est proposé ici: http://eggwiki.org/Bugs/Timers
CrazyCat a écrit :La prochaine fois, essaye d'imaginer que j'ai un cerveau ...
Répondre Avertir
#12
Merci pour le lien BdS, voilà déjà deux heures que le bot tourne sans problèmes ( Pour le moment ) puis j'ai plus rien avec un .set errorInfo c'est déjà une bonne chose :p

Avant de mettre le sujet en résolu je vais laisser 24h le trivia tourner vue qu'il est presque jamais en arrêt j'aurais des retours par les joueurs.

Merci Encore Smile

Et juste pour information ( hors sujet ) vous avez pas la solution pour cela http://forum.eggdrop.fr/Triviatcl-Points...ml#pid9204 ? :p
Répondre Avertir
#13
La solution http://eggwiki.org/Bugs/Timers marche pas :/ je vais basculer sur 1.6.20 :p
Répondre Avertir
#14
Tu as eu les mêmes messages d'erreur ? Bizarre qu'il tourne bien pendant deux heures et après non.
CrazyCat a écrit :La prochaine fois, essaye d'imaginer que j'ai un cerveau ...
Répondre Avertir
#15
Oui, les même erreurs :/

Code :
Game> [17:47:09] #kipof# set errorInfo
<Game> Currently: no such binding
<Game> Currently:     while executing
<Game> Currently: "unbind pubm -|- "$tgchan *" tgcheckanswer"

Code :
<Game> [17:39:32] Tcl error [tgcheckanswer]: invalid timerID

Grrr, mais cela est de temps en temps pas toujours :/ sinon il marche faut juste que cette suite d'indices passent.
Répondre Avertir


Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)
Tchat 100% gratuit -Discutez en toute liberté