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.

players stats for gather bot

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
s
serx
Voice
Posts: 4
Joined: Fri Nov 03, 2006 1:59 pm

players stats for gather bot

Post by serx »

hello,
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 :(
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

If the rank order is just the order names are added:

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
      }
}
Not tested.

Keep in mind if you try to use names with " (double quotes), [ ] (square brackets) or other special tcl chars the puthelp strings will likely produce errors, in which case you can just remove the [join $text] part and use $text (which will show strings like \[name\" which is not a problem, it just looks bad..)
Last edited by rosc2112 on Sun Nov 05, 2006 2:45 pm, edited 1 time in total.
s
serx
Voice
Posts: 4
Joined: Fri Nov 03, 2006 1:59 pm

Post by serx »

thanx man :)
s
serx
Voice
Posts: 4
Joined: Fri Nov 03, 2006 1:59 pm

Post by serx »

then I type: .add serx bot add to txt file that "text" and :( nothing ;[
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

You asked for a script to add nicks, that's what it does (unless there's some error, which your reply does not make clear)
s
serx
Voice
Posts: 4
Joined: Fri Nov 03, 2006 1:59 pm

Post by serx »

[09:39:20] <SerX> .add FMB
[09:39:22] <tessstas> Wrote text to file D:/Viliaus/CD/sys/Eggdrop/ech/rankfile.txt
[09:39:24] <SerX> .rank FMB
[09:39:26] <tessstas> Rank for text: 2
[09:39:30] <FMB> :D
[09:39:42] <SerX> .rank serx
[09:39:43] <tessstas> Rank for text: 2
:(
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Here is the mistake, in both procs:

set text [split text]

should be:

set text [split $text]

I editted the above script to fix that.
Post Reply