This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

trivia TCL problem

Old posts that have not been replied to for several years.
Locked
m
mindflow
Voice
Posts: 22
Joined: Thu Mar 10, 2005 11:14 am

trivia TCL problem

Post by mindflow »

the problem is that when somone with the signs [ ] in ther nick answer i question, then the bot just add him over and over again, and i dont know how to solve this, it looks like:

« @bot » Show 'em how it's done [tag]nick! The answer was JAMIE LEE CURTIS.
« @bot » The scores: [tag]nick 6, [tag]nick 5, [tag]nick 4, another_nick 3, [tag]nick 3, [tag]nick 2, another_nick 1, [tag]nick 1

the [tag]nick is the same person, but he get added for every right ansewer he say. and he get a new "add" after every right answered question, somone that know how to solve it? :?:


this is the part of the code that create the problem "i guess"

Code: Select all

#triggered when someone says the correct answer.
proc tgcorrectanswer {nick host hand chan text} {
 global tgcurrentanswer tghinttimer tgtimenext tgchan tgnexttimer tgstreak tgstreakmin
 global tgscoresbyname tgranksbyname tgranksbynum tgcongrats tgscorestotal tgmissed
 tggetscores
 if {![info exists tgranksbyname($nick)]} {
  set _oldrank 0
 } else {
  set _oldrank [lindex [split $tgranksbyname($nick) ,] 0]
 }
 tgincrscore $nick
 tggetscores
 set _newrank [lindex [split $tgranksbyname($nick) ,] 0]
 set _msg "\00306[lindex $tgcongrats [rand [llength $tgcongrats]]] \00304$nick\00306! The answer was \00304[strupr $tgcurrentanswer]\00306."
 if {$_newrank<$_oldrank} {
  if {$_newrank==1} {
   append _msg " You are now in first place!"
  } else {
   append _msg " You are now ranked \00304[tgnumsuf [lindex [split $tgranksbyname($nick) ,] 0]]\00306 of \00304$tgscorestotal\00306, behind \00304[lindex [split $tgranksbynum([expr $_newrank-1]) ,] 0]\00306 with \00304[lindex [split $tgranksbynum([expr $_newrank-1]) ,] 1]\00306."
  }
 }
 tggamemsg "$_msg"
 if {$tgstreak!=0} {
  if {[lindex [split $tgstreak ,] 0]==$nick} {
   set tgstreak $nick,[expr [lindex [split $tgstreak ,] 1]+1]
   if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin} {
    tggamemsg "\00312$nick is on a winning streak! [lindex [split $tgstreak ,] 1] in a row so far!"
   }
  } else {
   if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin} { tgstreakend }
   set tgstreak $nick,1
  }
 } else {
  set tgstreak $nick,1
 }
 set tgmissed 0
 tgshowscores
 unbind pubm -|- "$tgchan $tgcurrentanswer" tgcorrectanswer
 killutimer $tghinttimer
 set tgnexttimer [utimer $tgtimenext tgnext]
 return 1
}

#read current scores from file, sort and store in variable.
proc tggetscores {} {
 global tgscf tgscorestotal tgscores tgscoresbyname tgranksbyname tgranksbynum
 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 tgranksbynum]} {unset tgranksbynum}
 set i 0
 while {$i<[llength $tgscores]} {
  set _item [lindex $tgscores $i]
  set _nick [lindex [split $_item ,] 2]
  set _score [lindex [split $_item ,] 0]
  set tgscoresbyname($_nick) $_score
  set tgranksbyname($_nick) [expr $i+1],$_score
  set tgranksbynum([expr $i+1]) $_nick,$_score
  incr i
 }
 return
}

#increment someone's score.
proc tgincrscore {who} {
 global tgscores tgscf tgpointsperanswer tgscorestotal
 tggetscores
 if {$tgscorestotal>0} {
  set i 0
  if {[lsearch $tgscores "*,*,$who"]==-1} {
   append _newscores "1,[expr 1000000000000.0/[unixtime]],$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],[expr 1000000000000.0/[unixtime]],$who[expr [expr [llength $tgscores]-$i]==1?"":"\ "]"
   } else {
    append _newscores "$_score,$_time,$_nick[expr [expr [llength $tgscores]-$i]==1?"":"\ "]"
   }
   incr i
  }
 } else {
  append _newscores "1,[expr 1000000000000.0/[unixtime]],$who"
 }
 set _sfile [open $tgscf w]
 puts $_sfile "$_newscores"
 close $_sfile
 return
}

#shows the current scores on channel.
proc tgshowscores {} {
 global tgscores tgchan tgscorestotal
 tggetscores
 set i 0
 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 "\00304$_nick $_score"
  } elseif {$i==1} {
   append _scores ", \00303$_nick $_score"
  } elseif {$i==2} {
   append _scores ", \00312$_nick $_score"
  } elseif {[onchan $_nick $tgchan]} {
   append _scores ", \00306$_nick $_score"
  }
  incr i
 }
 tggamemsg "\00306The scores: $_scores"
}
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Take a look here. :wink:
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Locked