mIRC Home    About    Download    Register    News    Help

Print Thread
I
iceregent
iceregent
I
I need help with reading text from a file. I need to read a line, display it in a pm, then wait about a few seconds, read another line from the file, wit a few seconds, display it, until the end of the file, then close down the pm window. How do ai accomplish this?

G
GamingTom
GamingTom
G
You might be better reading from a .ini file. I used it for a few scripts and it works pretty well. I followed this helpful tutorial and it all worked out great in the end.

Basically, all you need to do is create a .ini file and write your lines in this format:

Code:
[lines]
1=First line.
2=Second line.
3=Third line.
etc. 


Then if you put something like this into your aliases section it should work. Anything after the '=' will be what you want messaged and you can name the '[lines]' whatever you want but it needs to be kept in square brackets.

Code:
/lines { 
msg $chan $readini(file.ini,n,lines,1)
timer1 1 5 msg $chan $readini(file.ini,n,lines,2) 
timer2 1 5 msg $chan $readini(file.ini,n,lines,3)  
}


The 'lines' corresponds to whatever you have in the square brackets in the ini file and the 'file.ini' will have to be renamed to what you call the .ini file and will be the location of where you place the file. The number at the end of the lines corresponds the the text before the '=' in the .ini file, so if you put 'line1' before the '=' you will put 'line1' at the end in the script.

This will display the text in a message to the specified channel but you will have to edit it to display as a PM which I'm not too great as.

Hope this helps and if you have anything else you need, I or anyone else on the forums would be happy to help.
-Tom.

Last edited by GamingTom; 05/07/13 10:11 PM.
D
Deega
Deega
D
You probably just need to use /play, see /help /play (The second item in the popup).

Basically
Code:
/play file.txt 2000
will 'play' the file to the window you typed it into with a 2 second delay between lines.

You can add the nick/channel you want the file sent to
Code:
/play nick file.txt 1500
will 'play' the file to nick/channel with 1.5 second delay between lines.

I
iceregent
iceregent
I
Ok, i tried this, and, /play $nick file.txt 1500 works just beautifully. I thank you kindly for your help my friend!

One more question.. is there a way to cause the window to close from the script end?

Last edited by iceregent; 06/07/13 12:53 AM. Reason: Need more answers
Joined: Jul 2006
Posts: 4,023
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,023
See /help /close to close the window, check /help on playend to know when a file finished playing


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
D
Deega
Deega
D
If you are using the command from a popup, you can use a period (.play) to silence the "playing/playback file" echoes and then you can close the window immediately.
Example query popup
Code:
Play file.txt:.play $1 file.txt 1500 | close -m $1


Or from an alias (to use in query windows)
Code:
alias playfile if $query($active) { .play $v1 file.txt 1500 | close -m $v1 }

I
iceregent
iceregent
I
actually it is from a remote script. I am thinking things are slightly different as in the syntax from remote scripts?

D
Deega
Deega
D
Originally Posted By: iceregent
actually it is from a remote script. I am thinking things are slightly different as in the syntax from remote scripts?
No difference really, silence the /play command (.play) and close the window.
e.g.
Code:
on *:text:*:?:{
  .play $nick file.txt 1500
  close -m $nick
}


Link Copied to Clipboard