mIRC Home    About    Download    Register    News    Help

Print Thread
#2918 21/12/02 09:33 PM
S
ScottRoberts
ScottRoberts
S
confused I have a text file that has a list of items. The first word of each line is the item and the rest of the line is the description.

I am trying to write a script that when a user types !item <item> it will go to this file, find the line with that item and respond with the description. How can I do this. I am fairly new at writing scrips and know that this is possible.

At this time, the file has approx 600 items in it. and will grow to near 1000.

Thanks for your help

Joined: Dec 2002
Posts: 3,015
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,015
Code:
on *:TEXT:!item*:#:{
  if ( $read(items.txt,s,$$2-) != $null ) {
    msg # $read(items.txt,s,$$2-)
  }
}
 

Replace items.txt with the name of your text file.

S
ScottRoberts
ScottRoberts
S
That worked great...now to add one more thing...what if the ITEM is not found. How do I display a message saying that it was not found.

Again. Thansk for the help.

Joined: Dec 2002
Posts: 3,015
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,015
Code:
on *:TEXT:!item*:#:{
  if ( $read(items.txt,s,$$2-) != $null ) {
    msg # $read(items.txt,s,$$2-)
  }
  else {
    msg # Item " $+ $$2- $+ " not found.
  }
}
 

S
ScottRoberts
ScottRoberts
S
Bless you...thanks for the quick help...task completed and script works great!!!

Joined: Dec 2002
Posts: 1,893
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,893
detail, since running $read() twice would be rather slow, I'd use $ifmatch where possible.
Code:
  if ( $read(items.txt,s,$$2-) != $null ) {
    msg # $ifmatch
  }

M
MDA
MDA
M
Greetings Collective and Members,

How would I add a timer to this code to enable the reading of a sizeable text file back to a remote user via a whisper to them without flooding out the script in doing so?

on *:TEXT:!item*:#:{ if ( $read(items.txt,s,$$2-) != $null ) { msg # $nick $ifmatch }
else {
msg # $nick Item " $+ $$2- $+ " not found.
}
}


Thanks for your time and consideration,

Regards,
MDA

A
amr
amr
A
Code:
on *:TEXT:!item*:#:{ if ( $read(items.txt,s,$$2-) != $null ) { msg $nick $ifmatch }
else {
msg $nick Item " $+ $$2- $+ " not found.
}
}  


no idea however on the timer..sorry

Last edited by amr; 27/12/02 09:00 PM.

Link Copied to Clipboard