mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2021
Posts: 93
Simo Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2021
Posts: 93
greetingz , im strugling to find each nick in $1- and see if they are all actually in channel before proceeding adding them to be voiced with $modespl
here is what i work with so far (got it from here from a post and edited it somewhat)

Code


kjjsdklsddk {
  var %chan = #  , %a = 1,  %nicks = $1-,%b = $numtok(%nicks,32) 
  while (%a = %b) {
    if ($gettok(%nicks,%a,32) ison %chan) { set %nicks $addtok(%nicks,$gettok(%nicks,%a,32),32) }
    if $numtok(%nicks,32) == $modespl {
      .mode %chan + $+ $str(v,$numtok(%nicks,32)) %nicks
      unset %mode.nicks
    }
    inc %a
  }
  if %nicks {
    .mode %chan + $+ $str(v,$numtok(%nicks,32)) %nicks
    unset %nicks
  }
}



thanks in advance.

Joined: Mar 2010
Posts: 146
Vogon poet
Offline
Vogon poet
Joined: Mar 2010
Posts: 146
Don't use '=' for comparison, always use '=='. (In this case you don't need to, because you're doing a loop)

I think the problem is the loop on the third line, while (%a = %b) {
Change it to while (%a <= %b) { and that I think would solve the problem.


Nothing...
Joined: Nov 2021
Posts: 93
Simo Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2021
Posts: 93
thanks for your reply Masoud i tried your suggestion

but only this gets executed :


Quote
if $numtok(%nicks,32) == $modespl {



if any remaining nicks in %nicks dont get voiced

the remaining in :


Quote
if (%nicks) {

dont trigger

Joined: Nov 2021
Posts: 93
Simo Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2021
Posts: 93
someone on IRC provided this alias with 2 while loops would it be possible to use 1 loop ?

Code



alias mvoice {
  var %xTemp $1-  , %nicks = %xTemp,   %newnicks,  %x = 0,  %numnicks = $numtok(%xTemp,32),   %inc = $modespl,  %max = %numnicks,  %nickstring  
  while (%x < $numtok(%xTemp,32)) {
    inc %x
    var %nick = $gettok(%xTemp,%x,32)
    if (%nick ison #) {
      if (%x != 1) %nickstring = %nickstring $+ $
      %nickstring = %nickstring $+ %nick
    }
  }
  %nickstring = $replace(%nickstring,$,$chr(32))
  %x = 1
  while (%x < %max) {
    %end = $calc(%x + %inc)
    if (%end > %max) %end = %max
    %currentnicks = $gettok(%nickstring, %x - %end, 32)
    %vs = + $+ $str(v,$numtok(%currentnicks,32))
    mode # %vs %currentnicks
    inc %x %inc
    inc %x
  }
}


Joined: Jul 2006
Posts: 4,150
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,150
1) Why do you care if it uses 1 or 2 while loops?
2) The code will not prevent any voice to occur if a single nickname is not on the channel, which is how you asked about it originallly
3) Even if the logic you want is to simply filter nickname not being on the channel first and only then do mass voices this code is not correct.
4) It's not correct but in a way that makes it works 100% of the time still, you got lucky, %max should be set to $numtok(%nickstring,32) after reseting %x to 1

It's possible to filter the nickname using $* which will do the while loop for you.

Last edited by Wims; 23/03/24 08:03 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Nov 2021
Posts: 93
Simo Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2021
Posts: 93
perhaps i wasnt clear in the initial request, the idea is to voice a list of users provided in $1- or similar (not entire channel no massvoice of entire channel)

like /mvoice nick nick nick nick nick nick nick nick

and if any of the nicks isnt in the channel to send an echo (with all the nicks that arent in the channel) and send the rest of the nicks to be voiced with $modespl

thanks.

Joined: Jul 2006
Posts: 4,150
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,150
The code you have does that already though.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Nov 2021
Posts: 93
Simo Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2021
Posts: 93
Found a way to use 1 loop and it seems to work as expected makes the code smaller too 👍


Link Copied to Clipboard