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.

Auto Voice Top 3 word (kelime) players

Help for those learning Tcl or writing their own scripts.
Post Reply
p
pektek
Halfop
Posts: 58
Joined: Sat Jul 01, 2023 4:51 pm

Auto Voice Top 3 word (kelime) players

Post by pektek »

I don't understand English very well. Sorry

I want my word bot to auto voice users that are in the score file. the score file lists users in 1st place to last. So on join it would need to check to see if user is in the scores file. and then if the user is amoung the top 3 players he/she is auto voiced. This below Is a section on a public command used to display the top 10 players in the channel.

Code: Select all

#triggered when someone uses !top10 command
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]Skor tablosu boş."
		}
	}
}
User avatar
CrazyCat
Revered One
Posts: 1333
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: Auto Voice Top 3 word (kelime) players

Post by CrazyCat »

You can do it with a small proc using tgscore:
proc tgvonjoin {nick uhost handle chan} {
   set tmp [list]
   for {set i 0} {$i<[llength $::tgscore]} {incr i} {
      lappend tmp [split [lindex $::tgscore $i] ,]
   }
   set tmp [lrange [lsort -decreasing -integer -index 2 $tmp] 0 2]
   if {[lsearch -nocase -index 0 $tmp $nick]>-1} {
      pushmode $chan +v $nick
   }
}
bind join - "$tgchan *" tgvonjoin
p
pektek
Halfop
Posts: 58
Joined: Sat Jul 01, 2023 4:51 pm

Re: Auto Voice Top 3 word (kelime) players

Post by pektek »

Thank you very much CrazyCat 8)

but error

Tcl error [tgvonjoin]: can't read "::tgscore": no such variable
Post Reply