mIRC Home    About    Download    Register    News    Help

Print Thread
#183656 21/08/07 03:10 PM
Joined: Jun 2003
Posts: 994
C
Hoopy frood
OP Offline
Hoopy frood
C
Joined: Jun 2003
Posts: 994
I have a script that is looping through the nicklist of a channel and doing a whois on each. Everything works great except I sometimes get flooded off. Is there a method I can use to delay the increment of the variable so I can avoid this?


I refuse to engage in a battle of wits with an unarmed person. wink
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Nope, but you can do something like this:

Code:
; Delay between each whois in milliseconds (3000 = 3 seconds).
alias -l whois_delay { return 3000 }
alias whoisall {
  var %i = 1
  while ($nick($1,%i)) {
    .timer -m 1 $calc((%i - 1) * $whois_delay) whois $v1
    inc %i
  }
}


/whoisall <channel>

Joined: Dec 2002
Posts: 2,033
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,033
Why not just use timers?

Code:

alias mwhois {
  var %i = 1,%ii = 0
  while ($gettok($1-,%i,44) != $null) {
    .timer 1 %ii whois $v1
    inc %i
    inc %ii 2
  }
}

menu nicklist {
  $iif(!$snick(#,0),$style(2)) Whois:mwhois $snicks
}



~ Edit ~

hixxy beat me to it
smile

Joined: Jun 2003
Posts: 994
C
Hoopy frood
OP Offline
Hoopy frood
C
Joined: Jun 2003
Posts: 994
Thanks hixxy! As usual you've cut my coding in half with one that does more than my own did grin ! Will you loan me your brain on weekends?

Thanks to RoCk, as well grin

Last edited by CtrlAltDel; 21/08/07 03:55 PM.

I refuse to engage in a battle of wits with an unarmed person. wink
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
You don't want it, it's too distracted at the minute to be useful laugh

RoCk #183665 21/08/07 05:34 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Just a word of caution: the time it takes to create an unnamed timer in mirc grows very fast w.r.t. the number of existing unnamed timers (very roughly, if creating 100 unnamed timers takes 0.5 secs, creating 200 of them takes 0.5*10 = 5 secs). In practice, in a channel of 400 or more users, it becomes ridiculously slow. The simplest solution is to name the timers, for example
.timermwhois $+ %ii 1 %ii whois $v1
or even
.timer $+ %ii 1 %ii whois $v1

An even better solution imo would be to use a single timer; it requires some extra bookkeeping but it's less wasteful.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Why is that, qwerty?


Invision Support
#Invision on irc.irchighway.net
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Just an amendment: reply-related loops are also possible without any timer smile
Here is an example for using the "end of whois" to perform the next one
(remove the filter part and add raw 401 to prevent break on part/quit/kick/nick of the whois'd user - it's just to get the main idea. add of joining nicks with /aline(nick), track of nickchanges with /rline(fline(nick)) and remove of nicks no longer valid with /dline(fline(nick)) would be possible, too)

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
When assigning a number to a new timer, mirc uses the first available number, starting from 1. So if you already have N timers running, each having a number from 1 to N, a new timer will be assigned N+1 but not before mirc checks all numbers from 1 to N to see if one of them is available for use. In rather technical terms, creating N unnamed timers this way can be no less than O(N^2). In mirc it's actually worse for some reason.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Thanks for the explanation. I'm glad I name my timers. smile


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard