mIRC Home    About    Download    Register    News    Help

Print Thread
#2918 21/12/02 09:33 PM
Joined: Dec 2002
Posts: 20
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Dec 2002
Posts: 20
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


Scott Roberts
T&R Communications of Florida
sroberts@tnrcomm.com
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
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.

Joined: Dec 2002
Posts: 20
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Dec 2002
Posts: 20
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.


Scott Roberts
T&R Communications of Florida
sroberts@tnrcomm.com
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
Code:
on *:TEXT:!item*:#:{
  if ( $read(items.txt,s,$$2-) != $null ) {
    msg # $read(items.txt,s,$$2-)
  }
  else {
    msg # Item " $+ $$2- $+ " not found.
  }
}
 

Joined: Dec 2002
Posts: 20
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Dec 2002
Posts: 20
Bless you...thanks for the quick help...task completed and script works great!!!


Scott Roberts
T&R Communications of Florida
sroberts@tnrcomm.com
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
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
  }

Joined: Dec 2002
Posts: 99
M
MDA Offline
Babel fish
Offline
Babel fish
M
Joined: Dec 2002
Posts: 99
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

Joined: Dec 2002
Posts: 16
A
amr Offline
Pikka bird
Offline
Pikka bird
A
Joined: Dec 2002
Posts: 16
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