| View previous topic :: View next topic |
| Author |
Message |
l.kleijn Voice
Joined: 18 May 2014 Posts: 33
|
Posted: Mon Aug 17, 2020 8:39 am Post subject: Help with script |
|
|
| Code: | bind pub - !money pub:money
proc pub:money {nick host hand chan arg} {
global botnick
set searchstring $arg
set fname "money.txt"
set fp [open $fname "r"]
set data [read -nonewline $fp]
close $fp
set lines [split $data "\n"]
set searchresult ""
foreach line $lines {
if {[string match * $nick* [join $line]]} {
lappend searchresult $line
}
if {[$nick == "[lindex [split [join $searchresult] "|"] 0]"} {
putserv "NOTICE $nick :Je bent al een keer hier geweest."
return 0
}
putserv "NOTICE $nick :You have €[lindex [split [join $searchresult] "|"] 1]"} {
return 0
}
} |
And i'm getting this error: [14:35:22] Tcl error [pub:money]: wrong # args: should be "foreach varList list ?varList list ...? command" |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Mon Aug 17, 2020 9:19 am Post subject: |
|
|
In fact, you have a trouble with the following line:
| Code: | | putserv "NOTICE $nick :You have €[lindex [split [join $searchresult] "|"] 1]"} { |
The right script might be:
| Code: | bind pub - !money pub:money
proc pub:money {nick host hand chan arg} {
global botnick
set searchstring $arg
set fname "money.txt"
set fp [open $fname "r"]
set data [read -nonewline $fp]
close $fp
set lines [split $data "\n"]
set searchresult ""
foreach line $lines {
if {[string match * $nick* [join $line]]} {
lappend searchresult $line
}
if {[$nick == "[lindex [split [join $searchresult] "|"] 0]"} {
putserv "NOTICE $nick :Je bent al een keer hier geweest."
return 0
}
putserv "NOTICE $nick :You have €[lindex [split [join $searchresult] '|'] 1]"
return 0
}
} |
Think to indent your code and you'll see this kind of errors _________________ https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
| Back to top |
|
 |
l.kleijn Voice
Joined: 18 May 2014 Posts: 33
|
Posted: Mon Aug 17, 2020 11:38 am Post subject: |
|
|
| Now it's working thanks |
|
| Back to top |
|
 |
l.kleijn Voice
Joined: 18 May 2014 Posts: 33
|
Posted: Mon Aug 17, 2020 11:39 am Post subject: |
|
|
Now i have something else
I have a file called money.txt and there is a line called Fujin|50 and i want to remove that line with a tcl script. How do i do this ? |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
|
| Back to top |
|
 |
|