mIRC Home    About    Download    Register    News    Help

Print Thread
#160339 25/09/06 07:18 PM
L
Lhurgoyf3
Lhurgoyf3
L
I made a little script to duplicate channels and amaze your friends so I could test while loops

Code:
alias chanduper {
  ;;variables  
  var %cd.chan = $?="What channel do you want to copy?"  
  var %cd.numchan = $?="How many copies?"
  var %cd.op = $?!="Deop in all of the channels?"
  ;;while loop  
  while (%cd.numchan) {
    var %cd.chan = $instok(%cd.chan,,2,46)
    var %cd.chan = $remove(%cd.chan,.)
    var %cd.join = $addtok(%cd.join,%cd.chan,44)
    if (%cd.op) { mode %cd.chan -o $me }
    dec %cd.numchan
  } 
  join %cd.join
}


It works, but I get error messages equal to the number of copies I wanted to make. The error says:
$chan No such channel
(the channels are still joined though...)

comments?

#160340 25/09/06 07:30 PM
L
Lpfix5
Lpfix5
L
Quote:
I made a little script to duplicate channels and amaze your friends so I could test while loops

Code:
alias chanduper {
  ;;variables  
[color:red]var %x = 1[/color] , %cd.chan = $?="What channel do you want to copy?"  , %cd.numchan = $?="How many copies?" , %cd.op = $?!="Deop in all of the channels?"
  ;;while loop  
  while ([color:red]%x <=[/color] %cd.numchan) {
[color:red]join $+($chr(35),%cd.chan,%x)
if ($me isop $chan) && (%cd.op) { mode $+($chr(35),%cd.chan,%x) -o $me }
inc %x[/color]
   } 
}


It works, but I get error messages equal to the number of copies I wanted to make. The error says:
$chan No such channel
(the channels are still joined though...)

comments?


Notice how you need a while loop to have from to from what i mean is have a small number like 1 go to x amount like 20 then have the script increment the %x till it reaches 20 it will loop till then and stop else your not assinging a loop and I wasnt sure what you wanted done but was just to show u

#160341 25/09/06 07:34 PM
L
Lhurgoyf3
Lhurgoyf3
L
It is the same thing
while (x) means that while x != 0, do stuff
so if I set x to 10 and dec it once every time, it will loop 10 times.

#160342 25/09/06 07:39 PM
L
Lpfix5
Lpfix5
L
yeah your right

my bad

#160343 25/09/06 07:40 PM
S
Scorpwanna
Scorpwanna
S
The dec method works too, and saves lines of code.

#160344 25/09/06 07:42 PM
S
Scorpwanna
Scorpwanna
S
I vote it's an mIRC bug, who's with me?

#160345 25/09/06 07:45 PM
L
Lhurgoyf3
Lhurgoyf3
L
It shouldnt be a bug, although it is possible. I wrote it another way and it didnt do that (echo #chan doesnt exist)

#160346 25/09/06 09:53 PM
L
Lpfix5
Lpfix5
L
Well It could be the server your on that only allows you X amount of channels to be on their network.

For example I believe Unreal IRCD = 8 channels maximum unless forced by an IRCOP

#160347 26/09/06 12:56 AM
L
Lhurgoyf3
Lhurgoyf3
L
Ok this is the final code. Everything works and there are no errors (assuming the user does not try to mess up on purpose). I didnt do error checking because it doesnt matter for this little experiment.

Code:
alias chanduper {
  var %cd.chan = $?="What channel do you want to copy?"  
  var %cd.num = $?="How many copies?"
  var %cd.num2 = %cd.num
  var %cd.op = $?!="Deop in all of the channels?"
  while (%cd.num) {
    var %cd.chan = $instok(%cd.chan,,2,46)
    var %cd.chan = $remove(%cd.chan,.)
    var %cd.join = $addtok(%cd.join,%cd.chan,44)
    dec %cd.num
  } 
  join %cd.join
  if (%cd.op) {
    inc %cd.num
    echo -ae %cd.join
    echo -ae %cd.num
    while (%cd.num <= %cd.num2) {
      mode $gettok(%cd.join,%cd.num,44) -o $me
      inc %cd.num
    }
  }
}

#160348 27/09/06 08:47 PM
Joined: Feb 2006
Posts: 523
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 523
your problem is quite simply that you're sending the mode command BEFORE you've sent the corresponding join command (dunno how this could possibly be construed as a mirc bug laugh!), i.e:

Code:
join #chan | mode #chan -o $me


is ok (providing #chan is empty, and unregistered, before you join it) but:

Code:
mode #chan -o $me | join #chan


is obviously invalid. what i recommend you do is build a list of mode commands, $+(mode #chan1 -o $me,$crlf,mode #chan2 -o $me,$crlf,...) where $crlf is used to send multiple commands to the server in the same packet

then you can send the join command at the end, and the mode if applicable

#160349 27/09/06 10:58 PM
S
Scorpwanna
Scorpwanna
S
Or just use a timer.

join #chan | .timermodeme 1 1 mode #chan -o $me


Link Copied to Clipboard