Can every one make script then type: .add nick , bot adden nick to ranks.txt file and then type .rank bot whrite exemple: Your Rank is 50 of 452.
SORRY FOR MY BAD ENGLISH

Code: Select all
# Fixed missing $ in: set text [split $text]
#######################################################################################################################
set rankfile "/home/mybot/data/rankfile.txt"
bind pub - .add addproc
proc addproc {nick uhost hand chan text} {
global rankfile
set text [string trim $text]
if {$text == ""} {puthelp "PRIVMSG $chan :You didn't supply a name!";return}
set text [split $text]
# check the existing data for duplicate names
if {[file exists $rankfile]} {
set rankdata [open $rankfile r]
while {![eof $rankdata]} {
set curline [gets $rankdata]
set curline [split $curline]
if {[string tolower $curline] == [string tolower $text]} {
# I assume you dont want to replace existing data so we just return with an error msg.
puthelp "PRIVMSG $chan :That name '[join $text]' already exists"
catch {close $rankdata}
return
}
}
}
# write the data to the end of the file.
set rankdata [open $rankfile a]
puts $rankdata [join $text]
flush $rankdata
catch {close $rankdata}
puthelp "PRIVMSG $chan :Wrote [join $text] to file $rankfile"
return
}
bind pub - .rank rankproc
proc rankproc {nick uhost hand chan text} {
global rankfile
set text [string trim $text]
if {$text == ""} {puthelp "PRIVMSG $chan :You didn't supply a name!";return}
set text [split $text]
set ranktemp "";set rankdata "";set ranknumber -1
if {![file exists $rankfile]} {
puthelp "PRIVMSG $chan :No datafile exists."
return
}
set ranktemp [open $rankfile r]
while {![eof $ranktemp]} {
set curline [gets $ranktemp]
set curline [split $curline]
if {$curline != ""} {
set rankdata [linsert $rankdata end $curline]
}
}
catch {close $ranktemp}
set ranknumber [lsearch -exact $rankdata $text]
if {$ranknumber != -1} {
puthelp "PRIVMSG $chan :Rank for $text: [expr $ranknumber + 1]"
} else {
puthelp "PRIVMSG $chan :Rank for $text not found."
return
}
}