mIRC Home    About    Download    Register    News    Help

Print Thread
#12743 24/02/03 12:03 AM
Joined: Dec 2002
Posts: 204
K
keeker Offline OP
Fjord artisan
OP Offline
Fjord artisan
K
Joined: Dec 2002
Posts: 204
Which is better for on TEXT events?
Code:
on *:TEXT:*:#:{
  if (something ISIN $1) { do stuff }
  elseif somethingelse ISIN $1) { do something else }
  elseif (yetanotherthing ISIN $1) { do another thing entirely }
  etc....
}

or 

on *:TEXT:something:#:{
  do stuff
}
on *:TEXT:somethingelse:#:{
  do something else
}
etc....

i am asking because my text event is freezing my mirc so bad that is stops responding, this doenst happen unless i am in a bunch of large channels. heres my code:
Code:
on *:TEXT:*:#:{
  if (@find isin $1) {
    var %i = 1, %song = $+(*,$replace($2-,$chr(32),*),*.mp3)
    if ($findfile($mp3dir,%song,0)) .msg $nick Matches for %song - Copy and paste in $chan to request a file.
    while ($findfile($mp3dir,%song,%i)) {
      .timer 1 $calc(%i * 3) .msg $nick $+(!,$me) $nopath($ifmatch)
      inc %i
    }
    .timer 1 $calc(%i * 3) .msg $nick Total Matches found: $calc(%i - 1)
    echo -a 15Results Sent to $nick for %song
  }
  elseif ( $+(@,$me) iswm $1 ) { 
    dcc send $nick %mp3list
    echo -a Sending $nick Your List
    .msg $nick Sending My List -- %mp3list -- Your Way
    echo -a 15List sent to $nick 
  }
  elseif ( $+(!,$me) iswm $1 ) { 
    var %file $strip($2-)
    dcc send $nick $findfile($mp3dir,$left(%file,$pos(%file,3)),1)
    echo -a 15File Sent to $nick  
  }
}

I think it is the @finder that is messing with me....especially when someone hits on a @find that i have a hell of a lot of.....dont know, whatcha all think?

[EDIT: reformated long script line to better display in this forum. -Hammer]

Last edited by Hammer; 24/02/03 03:43 AM.

keek: Scots - intr.v. keeked, keekĀ·ing, keeks
To peek; peep.
Joined: Dec 2002
Posts: 77
B
Babel fish
Offline
Babel fish
B
Joined: Dec 2002
Posts: 77
It's probably the use of $findfile that is causing the freezeups.

It would be better to dump the contents of your mp3 folder into a text file or hash table (you could write an alias in mirc to do that, and then periodically update using a timer if necessary).

Then search the text file or hash table to find what is requested. That would be much faster.

Joined: Dec 2002
Posts: 2,985
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 2,985
In my view the first option is better. I think it is bad practice to have more than one ON TEXT, for example, in the same file. In most situations it won't even work correctly.

Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
I disagree. The more specific you can make your on TEXT headers (the part before the actual code of the event), the more you limit which of those events will fire. on *:TEXT:@find *:#: only fires if someone types @find something in a channel. The same applies to on *:TEXT:$(@ $+ $me):#: for @Hammer requests. Underneath THAT, you would put your on *:TEXT:*:#: generic "else" on TEXT event to catch whatever didn't get caught by the previous on TEXT events. It ONLY fires if none of the above do, but will not fire at all if a higher example matched first.

As for the other half of the question, $findfile shouldn't be causing you too many problems. However, you probably DO want to limit how many results you set on those timers...like to 5 or 10. Using timers is fairly easy. You can also write the results to a text file, such as $+($mknickfn($nick),.txt, and /play -q it to them slowly (so you don't flood off) if you find any results to send them.


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C

Link Copied to Clipboard