mIRC Home    About    Download    Register    News    Help

Print Thread
Read 1file or another depending on nick added #137519 13/12/05 03:24 PM
Joined: Jan 2004
Posts: 129
A
AaronL Offline OP
Vogon poet
OP Offline
Vogon poet
A
Joined: Jan 2004
Posts: 129
Hi all
I hope i can make my problem clear. here goes.
I have a bot that checks a command like !beer
When someone type that without a nickname the bor reads file a, but is a nick is added like !beer pino it should read fil b
this is what i got sofar, but it does'nt work.

Code:
 
on *:text:!beer*:#:{ set %beernick $$2
 if (%beernick == '') {
 set %beer $read(drinks.txt, s, $$1
| /msg $chan %beer  
halt } 
 set %beer $read(beernick.txt, s, $$1 }
 


help is appriciated.
Aaron


Deridio fatum
Re: Read 1file or another depending on nick added #137520 13/12/05 04:27 PM
Joined: Apr 2003
Posts: 701
K
Kelder Offline
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
Using $$2 means use $2 if it is there, else stop the script completely. You don't want this here. You don't want this often.

mIRC does not recognize ' or " as a string delimiter in most cases (only some file and window commands have their own parsing for that.)

Don't halt unless you really need to, the most common (and thus best) way to have a script stop is by having it reach the end of the script, in other words the last }

/set is not needed if don't need the %variable after the script ends.

You didn't close the ) in the $read() call. I'm also not sure why you want to search either file for the word !beer since that is $1. I suppose you just want a random line out of that either text file. Please let us know if the text file really has lines with nicks already filled in or if you want to include either the given or the requester's nickname in the line somewhere.

Here's a changed simple version
Code:
on *:text:!beer*:#:{
  if ($2 == $null) { 
    msg $chan $read(drinks.txt)
  }
  else {
    msg $chan $read(beernick.txt)
  }
}


Maybe search this forum for other scripts like this, such scripts can get much more complex for all kinds of situations. Make sure you set the date range to 5 years.

Re: Read 1file or another depending on nick added #137521 13/12/05 06:11 PM
Joined: Jan 2004
Posts: 129
A
AaronL Offline OP
Vogon poet
OP Offline
Vogon poet
A
Joined: Jan 2004
Posts: 129
Hi Kelder.
Well problem is that it should'nt read a random line, but a line that starts with !beer and then shows de rest of the text on that line. In the txtfile i have the $nick etc..
With the ,s,$1 i tell the script it should search for !beer and then shows whats after !beer. according the helpfile i should write it down like $read(drinks, s, !beer) since $1 == !beer that should work. in fact that works fine, but... i have 2 txtfiles, one if no nick is used and one when is.

thnxs for the fast replay, but the short code you gave me did'nt do the job. Instead i get the error msg: insufficient parameters..

Aaron


Deridio fatum
Re: Read 1file or another depending on nick added #137522 13/12/05 08:12 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Try this:
Code:
on *:text:!beer*:#: msg # $$read($iif($2,beernick.txt,drinks.txt),s,!beer)


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Re: Read 1file or another depending on nick added #137523 14/12/05 06:44 AM
Joined: Jan 2004
Posts: 129
A
AaronL Offline OP
Vogon poet
OP Offline
Vogon poet
A
Joined: Jan 2004
Posts: 129
thnxs qwert, for the fast and good solution
works fine now.

Aaron


Deridio fatum