|
Joined: Sep 2006
Posts: 13
Pikka bird
|
OP
Pikka bird
Joined: Sep 2006
Posts: 13 |
I made a little script to duplicate channels and amaze your friends so I could test while loops
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?
|
|
|
|
Joined: Aug 2005
Posts: 1,052
Hoopy frood
|
Hoopy frood
Joined: Aug 2005
Posts: 1,052 |
I made a little script to duplicate channels and amaze your friends so I could test while loops
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
|
|
|
|
Joined: Sep 2006
Posts: 13
Pikka bird
|
OP
Pikka bird
Joined: Sep 2006
Posts: 13 |
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.
|
|
|
|
Joined: Aug 2005
Posts: 1,052
Hoopy frood
|
Hoopy frood
Joined: Aug 2005
Posts: 1,052 |
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
|
|
|
|
Joined: Sep 2003
Posts: 261
Fjord artisan
|
Fjord artisan
Joined: Sep 2003
Posts: 261 |
The dec method works too, and saves lines of code.
We don't just write the scripts, we put them to the test! (ScriptBusters)
|
|
|
|
Joined: Sep 2003
Posts: 261
Fjord artisan
|
Fjord artisan
Joined: Sep 2003
Posts: 261 |
I vote it's an mIRC bug, who's with me?
We don't just write the scripts, we put them to the test! (ScriptBusters)
|
|
|
|
Joined: Sep 2006
Posts: 13
Pikka bird
|
OP
Pikka bird
Joined: Sep 2006
Posts: 13 |
It shouldnt be a bug, although it is possible. I wrote it another way and it didnt do that (echo #chan doesnt exist)
|
|
|
|
Joined: Aug 2005
Posts: 1,052
Hoopy frood
|
Hoopy frood
Joined: Aug 2005
Posts: 1,052 |
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
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
|
|
|
|
Joined: Sep 2006
Posts: 13
Pikka bird
|
OP
Pikka bird
Joined: Sep 2006
Posts: 13 |
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. 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
}
}
}
|
|
|
|
Joined: Feb 2006
Posts: 546
Fjord artisan
|
Fjord artisan
Joined: Feb 2006
Posts: 546 |
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 !), i.e:
join #chan | mode #chan -o $me
is ok (providing #chan is empty, and unregistered, before you join it) but:
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
"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
|
|
|
|
Joined: Sep 2003
Posts: 261
Fjord artisan
|
Fjord artisan
Joined: Sep 2003
Posts: 261 |
Or just use a timer.
join #chan | .timermodeme 1 1 mode #chan -o $me
We don't just write the scripts, we put them to the test! (ScriptBusters)
|
|
|
|
|