mIRC Homepage

Scripting: $read the whole txt file

Posted By: Noiz

Scripting: $read the whole txt file - 28/04/04 06:10 PM

Hi there..
Well, im new to scripting and this is my first script smile

This is my script:
Code:
 
on *:TEXT:!favorits:#: { 
/msg $chan $read(favorits.txt) 
} 

My problem is that, with this code, it only reads some random line in the txt file.
What I want it to is read the whole file and not some random line or some specfic line.
I could use some help laugh
Posted By: LittleJohnsr

Re: Scripting: $read the whole txt file - 28/04/04 06:20 PM

Try this

on *:TEXT:!favorits:#: {
play $chan $mircdirfavorits.txt 100
}

LittleJohnsr


Posted By: Wolfie

Re: Scripting: $read the whole txt file - 28/04/04 06:23 PM

use a higher number than 100 though, unless it's a really small file, otherwise you risk flooding off. (1000 = 1 second), adjust as needed for the network you are on.
Posted By: Noiz

Re: Scripting: $read the whole txt file - 28/04/04 06:41 PM

Weee.. grin

Thx m8s.. :tongue:

It works perfect now..

i'll be back soon with a new problem laugh
Posted By: LittleJohnsr

Re: Scripting: $read the whole txt file - 28/04/04 06:53 PM

Your welcome and Wolfie is right that was a fat finger moment should have been 1000 blush
Posted By: Wolfie

Re: Scripting: $read the whole txt file - 28/04/04 07:00 PM

I stated to adjust as necessary, because if it's a short file (say 4 lines, which is still a flood risk in itself)..

4 lines listed real fast is no biggy.. If the IRC allows, say, 20 lines before flooding, then a small file is nothing, and 100 is ok. 1000 is still too fast and can cause flooding if it lasts for too long... etc..

Being one paranoid of flooding...
Code:
on *:TEXT:!favorits:#:if (!$hget(faves,$+($cid,#))) { play $chan favorits.txt 1000 | hadd $+(-mu,$calc(30 + $lines(favorits.txt))) faves $+($cid,#) $ticks } }

That *should* prevent someone from activating it from the time it starts to 30 seconds after it stops (if you set it for 1 line per second)
Posted By: SS217

Re: Scripting: $read the whole txt file - 28/04/04 08:15 PM

You could try this..

on *:TEXT:!favorits:#: {
if (%nospam.favorits) { return }
else {
set -u20 %nospam.favorits true
var %y = 0
var %z
while ( %y <= $lines(favorits.txt) ) {
var %z = %z $read(favorits.txt,%y)
inc %y
}
msg $chan %z
}
}

Not tested.
Posted By: FiberOPtics

Re: Scripting: $read the whole txt file - 28/04/04 09:22 PM

Hi,

I've made you a quick script that will open a dcc chat to the persons typing !favorits in your channel, and it will msg your favorites to them through the dcc chat, which is lagless, so they'll have it instantly, without having to worry about getting flooded off the server, since dcc chat is a direct connection between you and the other person.

I've added an extra option, that if you are unable to connect to them in 15 seconds, that you will play the file to them as stated in the previous replies by the other people.

Put the following into your remotes:
Code:
 
on *:TEXT:!favorits:#: if !$timer($nick) { .timer $+ $nick 1 15 check.dcc $nick | dcc chat $nick } 
on *:OPEN:=:{
  if $timer($nick) {
    .timer [ $+ [ $nick ] ] off
    var %x = 1, %file = $+(",$mircdir,favorits.txt,")
    while %x &lt;= $lines(%file) { msg =$nick [Favorits] $read(%file,%x) | inc %x }
  }
}
alias check.dcc { 
  if $chat($1).status != active { 
    close -c $1   
   .notice $1 I was unable to open a dcc chat to you. Here come my favorits: 
    play $1 $+(",$mircdir,favorits.txt,") 1000 
  }
}


Note how I use $+(",$mircdir,favorits.txt,"), this will make sure that the file will be found, if the path to the file would contain spaces. E.g. c:\program files\mirc\favorits.txt

Btw, the correct word is 'favorites', though everyone is free to use whatever word they want of course smile

Hope this was somewhat helpful for you!

Greetz
Posted By: Wolfie

Re: Scripting: $read the whole txt file - 28/04/04 11:23 PM

No offense, but that wouldn't work. If the file has 25 lines in it, 25 characters each line (and that's small when you think about it), that's 625 characters. My experience has been that it the IRC won't allow that much on one line. And that's a low estimate of what could be in the file.
Posted By: Noiz

Re: Scripting: $read the whole txt file - 29/04/04 03:23 PM

well...
I must say that im suprised to get all that response.
But its not that kinda advance script (its my first script).
So im using Wolfie's code, and it works great.. laugh

But thx for all that help..
i'll be back with new problems :P

/Noiz
© 2019 mIRC Discussion Forums