mIRC Homepage
Hey folks,
We have a University that makes use of our network via a CGI client. They all connect through the same proxy, but CGI numbers differ from PC to PC. So to prevent them from creating clones i wrote a script to check idents on join and added it to my current on JOIN script.

Code:
alias ccheck {
  unset %ccchan
  var %c = 1, %b = $nick($chan, 0)
  While (%c <= %b) {
    set %ccuser $nick($chan, %c)
    Var %i = 1, %s = $nick($chan, 0)
    While (%i <= %s) {
      if ($address($nick($chan, %i),3) == $address(%ccuser, 3)) {
        if ($nick($chan, %i) != %ccuser) && ($nick($chan,%i) !isin %ccchan) {
          set %ccchan %ccchan $nick($chan, %i) &
        }
      }
      inc %i
    }
    inc %c
  }
  unset %ccuser
  if (%ccchan == $null) {
    return
  }
  else { 
    return [3I14dent 3C14lones: $left(%ccchan,$calc($len(%ccchan) - 2)) $+ ] 
    unset %ccchan* 
  }
}


Now you'll notice that there are two places where i attempt to unset the variable. The one at the start of the script unsets it, but the one at the end doesnt. Why is this? I think its fairly neat, but if anyone has a better what of doing this, please let me know.

Final thing. In order for this script to work, the IAL has to be fulled. So its current set to enable when the command is issued and the IAL is filled. Any thing to add to this to make it better?
I do not know a way to make this work without the IAL being filled.
But your unset isn't executed because return simply halts the current script. /help /return
You only have to replace the unset- and return-line in the else-block.
Im assuming return is the best to use in this case, but surely swapping the return and the unset would unset the variable before it's return, thus returning null?
Why not just make %ccchan a local variable (like you did with %c and %b)?
I had tried to do this with only one set of local variables, and it didnt work, so i assumed i'd have to use global variables if i wanted to use them inside and outside of the while loops.. But i'll give it a try. Thanks qwerty smile
Originally Posted By: WhipLash
Im assuming return is the best to use in this case, but surely swapping the return and the unset would unset the variable before it's return, thus returning null?


Oh, indeed, you're using the variable in the message... sorry shocked
Anyway, a local variable should work in that case, both in- and outside a while loop.
Thanks guys,
I set it as a local variable and all seems to be running smoothly.
© mIRC Discussion Forums