mIRC Home    About    Download    Register    News    Help

Topic Options
#81105 - 28/04/04 07:10 PM Scripting: $read the whole txt file
Noiz Offline
Self-satisified door

Registered: 28/04/04
Posts: 3
Loc: Denmark
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
_________________________
#Slaske @ Quakenet

Top
#81106 - 28/04/04 07:20 PM Re: Scripting: $read the whole txt file
LittleJohnsr Offline
Pikka bird

Registered: 21/02/04
Posts: 14
Try this

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

LittleJohnsr




Edited by LittleJohnsr (28/04/04 07:20 PM)

Top
#81107 - 28/04/04 07:23 PM Re: Scripting: $read the whole txt file
Wolfie Offline
Fjord artisan

Registered: 07/08/03
Posts: 325
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.

Top
#81108 - 28/04/04 07:41 PM Re: Scripting: $read the whole txt file
Noiz Offline
Self-satisified door

Registered: 28/04/04
Posts: 3
Loc: Denmark
Weee.. grin

Thx m8s.. :tongue:

It works perfect now..

i'll be back soon with a new problem laugh
_________________________
#Slaske @ Quakenet

Top
#81109 - 28/04/04 07:53 PM Re: Scripting: $read the whole txt file
LittleJohnsr Offline
Pikka bird

Registered: 21/02/04
Posts: 14
Your welcome and Wolfie is right that was a fat finger moment should have been 1000 blush

Top
#81110 - 28/04/04 08:00 PM Re: Scripting: $read the whole txt file
Wolfie Offline
Fjord artisan

Registered: 07/08/03
Posts: 325
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)

Top
#81111 - 28/04/04 09:15 PM Re: Scripting: $read the whole txt file
SS217 Offline
Ameglian cow

Registered: 03/04/03
Posts: 25
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.


Edited by SS217 (28/04/04 09:17 PM)

Top
#81112 - 28/04/04 10:22 PM Re: Scripting: $read the whole txt file
FiberOPtics Offline
Hoopy frood

Registered: 05/02/04
Posts: 2019
Loc: Leuven, Belgium
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
_________________________
Gone.

Top
#81113 - 29/04/04 12:23 AM Re: Scripting: $read the whole txt file
Wolfie Offline
Fjord artisan

Registered: 07/08/03
Posts: 325
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.

Top
#81114 - 29/04/04 04:23 PM Re: Scripting: $read the whole txt file
Noiz Offline
Self-satisified door

Registered: 28/04/04
Posts: 3
Loc: Denmark
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
_________________________
#Slaske @ Quakenet

Top