egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

players stats for gather bot

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
serx
Voice


Joined: 03 Nov 2006
Posts: 4

PostPosted: Sat Nov 04, 2006 1:35 pm    Post subject: players stats for gather bot Reply with quote

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 Sad
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Sat Nov 04, 2006 5:25 pm    Post subject: Reply with quote

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

Code:

#  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
Back to top
View user's profile Send private message
serx
Voice


Joined: 03 Nov 2006
Posts: 4

PostPosted: Sun Nov 05, 2006 3:27 am    Post subject: Reply with quote

thanx man Smile
Back to top
View user's profile Send private message
serx
Voice


Joined: 03 Nov 2006
Posts: 4

PostPosted: Sun Nov 05, 2006 3:42 am    Post subject: Reply with quote

then I type: .add serx bot add to txt file that "text" and Sad nothing ;[
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Sun Nov 05, 2006 5:41 am    Post subject: Reply with quote

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)
Back to top
View user's profile Send private message
serx
Voice


Joined: 03 Nov 2006
Posts: 4

PostPosted: Sun Nov 05, 2006 9:13 am    Post subject: Reply with quote

[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> Very Happy
[09:39:42] <SerX> .rank serx
[09:39:43] <tessstas> Rank for text: 2
Sad
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Sun Nov 05, 2006 2:43 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber