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.

>> Simple MIRC -> TCL Script Conversion <<

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
H
Hamish
Voice
Posts: 25
Joined: Mon Mar 27, 2006 1:20 pm

>> Simple MIRC -> TCL Script Conversion <<

Post by Hamish »

I need a script that will allow the user to type !price item
The script should get the item from this text file Pricelist and return the line that word is contained on.

Eg. user types !price Abyssal whip and the bot will search the text file and return line one of the text file "Abyssal whip: 2.9-3.2Mil" as a notice to the user... So it's like:

<@Hamish> !price Abyssal whip
-ClanBot- Abyssal whip: 2.9-3.2Mil

Also, if it helps at all, here is the MIRC version:

Code: Select all

on *:TEXT:!price*:#:{ 
    .notice $nick *** [7 $upper($$2-) ]: $read(prices.txt, s, $$2- $+ :) 
  } 
} 
Thanks, Hamish.
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

something like that should do the trick:

Code: Select all

bind pub - !price prices

proc prices {nick uhost hand chan text} {
   set hit 0
   set fd [open prices.txt r]
   while {![eof $fd]} {
      if {[string match -nocase "$text: *" [set price [gets $fd]]]} {
         set hit 1
         break
      }
   }
   close $fd
   if {$hit} {
       puthelp "NOTICE $nick :$price"
       return 1
   } else {
       puthelp "NOTICE $nick :No match found"
       return 0
   }
}
Read TCL manual for possible wildcard searchs.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
H
Hamish
Voice
Posts: 25
Joined: Mon Mar 27, 2006 1:20 pm

Post by Hamish »

De Kus, it works perfectly, thanks alot man! :D
Thanks, Hamish.
Post Reply