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.

Money.tcl

Help for those learning Tcl or writing their own scripts.
Post Reply
l
l.kleijn
Voice
Posts: 33
Joined: Sun May 18, 2014 10:02 am

Money.tcl

Post by l.kleijn »

I wrote a script but it won't work.
The intention is that after a join a file read.
and if the nick is not in the list there would deposit money to the file

Code: Select all

proc join:money {nick host 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
     }
     money chan nick hand
  }
}
proc money {chan nick hand what} {
     set line_to_add "$nick|500"
     set fname "money.txt"
     set fp [open $fname "a"]
     puts $fp $line_to_add
     close $fp
     putserv "NOTICE $nick :Welkom op $chan, u heeft zojuist geld ontvangen"
     putserv "NOTICE $nick :om bij mij uit te kunnen geven aan de bar."
     return 0
}
l
l.kleijn
Voice
Posts: 33
Joined: Sun May 18, 2014 10:02 am

Post by l.kleijn »

This is the error i get <IRCop-Bot> [15:52:46] Tcl error [join:money]: wrong # args: should be "money nick chan arg"
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

This line of code is where we get that error

Code: Select all

money chan nick hand
I am not sure exactly what you are going for here, but you will want to pass the variable values to the next process, Not the variable names...

Code: Select all

money $chan $nick $hand
And you are calling [money] with the wrong number of arguments.
The proc is wrote requiring 4 args, you are calling it with 3.

Please post the entire script here, or at least all binds/procs leading up to this process. You have several other errors still to come:)
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Post Reply