bind pub -|- !find find
proc exec_players {} {
return [exec ./qstat -sort g -default rwm -Ts server.qstat -Tp players.qstat -f qstatserverlist.lst -P]
}
proc find {nick host hand chan arg} {
if {[llength $arg] < 1} then {
putquick "NOTICE $nick : You might wanna put in a search word to limit the list a bit"
return
}
putquick "NOTICE $nick :4Starting Search For 9 [lindex $arg 0] 4Please Patience"
set stat [exec_players]
set stat_arr [split $stat "\n"]
set i 0
set str $stat_arr
set found 0
# set str [lsort $stat_arr]
for {set i 0} {$i < [llength $str]} {incr i} {
set j [expr $i + 1]
# Loop through all the players and save them into a list
while {[string range [lindex $str $j] 0 6] == "Player:"} {
set player [string trimleft [lindex $str $j] "Player:"]
set playername [lindex [split $player " "] 2]
set server [join [lindex [split [lindex $str $i] ""] 1] " "]
if {[string first [string tolower $arg] [string tolower $playername]] != -1} then {
incr found
putquick "NOTICE $nick :$playername is on $server "
}
incr j
}
# Make sure we don't check through the players again
set i [expr $j - 1]
}
set info_str [get_number_of $found "player"]
putquick "NOTICE $nick :$info_str"
return 0
}
bind pub -|- !find find
proc exec_players {} {
return [exec ./qstat -sort g -default rwm -Ts server.qstat -Tp players.qstat -f qstatserverlist.lst -P]
}
proc find {nick host hand chan arg} {
if {[llength [split $arg]] < 1} then {
putquick "NOTICE $nick : You might wanna put in a search word to limit the list a bit"
return
}
putquick "NOTICE $nick :4Starting Search For 9 [lindex [split $arg] 0] 4Please Patience"
set stat [exec_players]
set stat_arr [split $stat "\n"]
set i 0
set str $stat_arr
set found 0
# set str [lsort $stat_arr]
for {set i 0} {$i < [llength $str]} {incr i} {
set j [expr $i + 1]
# Loop through all the players and save them into a list
while {[string range [lindex $str $j] 0 6] == "Player:"} {
set player [string trimleft [lindex $str $j] "Player:"]
set playername [lindex [split $player " "] 2]
set server [join [lindex [split [lindex $str $i] ""] 1] " "]
if {[string first [string tolower $arg] [string tolower $playername]] != -1} then {
incr found
putquick "NOTICE $nick :$playername is on $server "
}
incr j
}
# Make sure we don't check through the players again
set i [expr $j - 1]
}
set info_str [get_number_of $found "player"]
putquick "NOTICE $nick :$info_str"
return 0
}
Allthough the error messages says it is in the find proc, this is because fo the way eggdrop reports the last Tcl command it executed (while in that command, Tcl will do the rest of the work).