When a bot in the channel writes one of the following sentences, my bot should save the playername with the number of MVPs and MostKills in a textfile. In the txt-file there should be displayed at first the playername, then the number of MVPs and then the number of MostKills.
I began with making this script:Host: [BR] genaraln7 has been recommended by BlazeRegulator: MVP on C&C_Islands with 1000 points
Host: [BR] genaraln7 has been recommended by BlazeRegulator: Most Kills on C&C_Canyon with 17 frags
Code: Select all
bind pubm - * medals
proc medals {nick uhost hand chan arg} {
set file scripts/medals.txt
if {![file exists $file]} { close [open $file w] }
set l [split [read [set f [open $file]]][close $f] \n]
set n [lindex [split $arg] 2]
set mvp 0
set kills 0
if {[string match -nocase {*BlazeRegulator: Most Kills*} $arg]} {
set kills [expr $kills + 1]
lappend l "$n $mvp $kills"
set f [open $file w]
foreach le $l {
if {$le != ""} { puts $f $le }
}
close $f
}
if {[string match -nocase {*BlazeRegulator: MVP*} $arg]} {
set mvp [expr $mvp + 1]
lappend l "$n $mvp $kills"
set f [open $file w]
foreach le $l {
if {$le != ""} { puts $f $le }
}
close $f
}
}
1. The design of the txt-file is like this: "genaraln7 0 1 genaraln7 1 0" Is it possbile that there is a break before a new name begins?
2. If a person gets for example MVP and this person is already listed in the textfile, my bot should not begin a new line, but it should add it to the nick. How is this possible?