| View previous topic :: View next topic |
| Author |
Message |
serx Voice
Joined: 03 Nov 2006 Posts: 4
|
Posted: Sat Nov 04, 2006 1:35 pm Post subject: players stats for gather bot |
|
|
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  |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Sat Nov 04, 2006 5:25 pm Post subject: |
|
|
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 |
|
 |
serx Voice
Joined: 03 Nov 2006 Posts: 4
|
Posted: Sun Nov 05, 2006 3:27 am Post subject: |
|
|
thanx man  |
|
| Back to top |
|
 |
serx Voice
Joined: 03 Nov 2006 Posts: 4
|
Posted: Sun Nov 05, 2006 3:42 am Post subject: |
|
|
then I type: .add serx bot add to txt file that "text" and nothing ;[ |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Sun Nov 05, 2006 5:41 am Post subject: |
|
|
| 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 |
|
 |
serx Voice
Joined: 03 Nov 2006 Posts: 4
|
Posted: Sun Nov 05, 2006 9:13 am Post subject: |
|
|
[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>
[09:39:42] <SerX> .rank serx
[09:39:43] <tessstas> Rank for text: 2
 |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Sun Nov 05, 2006 2:43 pm Post subject: |
|
|
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 |
|
 |
|