mIRC Home    About    Download    Register    News    Help

Print Thread
#160290 25/09/06 05:34 AM
Joined: Sep 2006
Posts: 13
L
Pikka bird
OP Offline
Pikka bird
L
Joined: Sep 2006
Posts: 13
Ive made an interesting script that duplicates channels so I could experiment with while loops. Amaze your friends with this!!!
--------------
Code:
alias chanduper {
  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?"
  var %cd.num = 0
  if (%cd.op == $true) {
    while (%cd.num < %cd.numchan) {
      var %cd.chan = $instok(%cd.chan,,2,46)
      var %cd.chan = $remove(%cd.chan,.)
      join %cd.chan
      mode %cd.chan -o $me
      inc %cd.num
    }
  }
  else {
    while (%cd.num < %cd.numchan) {
      var %cd.chan = $instok(%cd.chan,,2,46)
      var %cd.chan = $remove(%cd.chan,.)
      join %cd.chan
      inc %cd.num
    }
  }
} 

------------
c/p that into remotes tab for it to work.
Comments?

#160291 25/09/06 12:02 PM
Joined: Feb 2006
Posts: 546
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
grats, you've passed mircscripting 101 :S in the next course you'll learn how a combination of well placed if statements and use of $+ and $str can make your code about half its size laugh

went ahead and made an example:

Code:
alias chanduper {
  var %cd.chan = $?="What channel do you want to copy?", %cd.numchan = $?="How many copies?", %cd.op = $?!="Deop in all of the channels?"
  while (%cd.numchan) {
    join %cd.chan $+ $str(,$v1)
    if (%cd.op) mode %cd.chan -o $me
    dec %cd.numchan
  }
}


now you can work on making that send as few commands to the server as possible, such as by sending all the channels to join in a single join command (/join #chan1,#chan2,#chan3...) to avoid floods ;p perhaps add some error checking and such blush

Last edited by jaytea; 25/09/06 12:15 PM.
#160292 25/09/06 01:33 PM
Joined: Sep 2006
Posts: 13
L
Pikka bird
OP Offline
Pikka bird
L
Joined: Sep 2006
Posts: 13
man, I should have thought of putting the if inside the while...
what is $v1?? I looked in the help file and it doesn't explain very much.

#160293 25/09/06 04:12 PM
Joined: Sep 2006
Posts: 13
L
Pikka bird
OP Offline
Pikka bird
L
Joined: Sep 2006
Posts: 13
OK, I couldnt edit the last post but I redid the code to add only 1 command to the server

I didnt use the $str(blah,$v1) because I dont know what $v1 does (and didnt care to find out right now)

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...)

#160294 25/09/06 11:26 PM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
The reason you get the errors is becuase, your writing stupid scripts that do stupid things.
This particular error is caused becuase of attempted mode sets on channels that do not exist at the time of the mode set.

PS: u should move this to the scripts and popups.

#160295 26/09/06 12:37 AM
Joined: Sep 2006
Posts: 13
L
Pikka bird
OP Offline
Pikka bird
L
Joined: Sep 2006
Posts: 13
Quote:
1) The reason you get the errors is becuase, your writing stupid scripts that do stupid things.
2) This particular error is caused becuase of attempted mode sets on channels that do not exist at the time of the mode set.

PS: 3) u should move this to the scripts and popups.


1) Isnt there something in the faq or sticky that says not to say stuff like that?
2) Thanks
3) I did

#160296 26/09/06 07:21 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
1) Isnt there something in the faq or sticky that says not to say stuff like that?


I doubt there is any rule saying you can not state facts. smile

#160297 28/09/06 04:20 PM
Joined: Mar 2003
Posts: 612
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Mar 2003
Posts: 612
$v1 and $v2 return the first and second parameters of a comparison.

i think the helpfile says something like

if ( text isin sometext )
$v1 is text
$v2 is sometext

btk


billythekid
#160298 25/10/06 11:07 PM
Joined: Oct 2006
Posts: 21
S
Ameglian cow
Offline
Ameglian cow
S
Joined: Oct 2006
Posts: 21
"I doubt there is any rule saying you can not state facts. "

How about being a butthead?


Sam Hamwich
-Build a Better Mousetrap, and They Will Build A Smarter Mouse-
#160299 26/10/06 05:17 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Stating facts is one thing, calling people names is another, and doing the second is a really good way to go about having the helpers ignore you and all of your posts. Additionally, I believe, that multiple posts similar to that can cause you to lose your account on the forum and possibly get you banned.

#160300 26/10/06 11:21 PM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
How about being a butthead?


No your welcome to being one smile And have a nice day.


Link Copied to Clipboard