;Copy everything below the line into your ALIASES section
;or use the mIRC Load command
;---------------------------------------------------------
; Version 1.3 01/12/98
;
; The orginial script was written by Pavlov and has been
; modified by puppet, Beavis97 and Olifant
;
; This procedure is the cornerstone of the DDE Link.
; YOU MUST NOT CHANGE THE NAME OF THE ALIAS!
;
; $1 will always be the resolved address or 0 if did not resolve.
; $2 will always be the IP.
; $3 will always be the port.
; $4 will always be the protocol. (tcp or udp)
;
; Please feel free to change anything else about this script :)
;

/nuke {
  set %nukehost $1
  set %nukeip $2
  set %nukeport $3
  set %nukeprot $4
  set %found 0
  
  if %nukehost == 0  {
    set %nuker *!*@ $+ %nukeip
    scannukeip
  }
  else { 
    set %nuker *!*@ $+ %nukehost
    scannukehost
  }
}

scannukehost {
  set %num 1
  set %num1 1
  set %nukechans $chan(0)
  set %num2 1
  
  echo 3 -s Scanning for address %nuker
  
  :loopchans
  set %nukechan $chan(%num1)
  set %num 1
  if (%num1 > %nukechans) { goto end }
  echo 6 -s  Looking in %nukechan
  :loopnicks
  set %num2 1
  if ($nick(%num,%nukechan) == $null) {
    inc %num1 1
    goto loopchans
  }
  :loopial
  if ($ial(%nuker,%num2).nick == $nick(%num,%nukechan)) {
    echo 4 -s -- Found: $ial(%nuker,%num2).nick on %nukechan
    if $me isop %nukechan {
      ban -u900 %nukechan $ial(%nuker,%num2).nick 3
      kick %nukechan $ial(%nuker,%num2).nick Stay off my ports!  (AutoNab from NukeNabber)
      set %found 1
    }
    else  {
      set %found 1
    }
  }
  if ($ial(%nuker,%num2).nick == $null) { goto loopnicks1 }
  inc %num2
  goto loopial
  :loopnicks1
  inc %num
  goto loopnicks
  
  :end
  unset %nuker
  unset %num
  unset %num1
  unset %num2
  unset %nukechan
  unset %nukechans
  
  if (%found == 0) {
    set %nuker *!*@ $+ %nukeip
    scannukeip
  }
  
  halt
}

scannukeip {
  set %num 1
  set %num1 1
  set %nukechans $chan(0)
  set %num2 1  
  echo 3 -s Scanning for address %nuker
  
  :loopchans
  set %nukechan $chan(%num1)
  set %num 1
  if (%num1 > %nukechans) { goto end }
  echo 6 -s  Looking in %nukechan
  :loopnicks
  set %num2 1
  if ($nick(%num,%nukechan) == $null) {
    inc %num1 1
    goto loopchans
  }
  :loopial
  if ($ial(%nuker,%num2).nick == $nick(%num,%nukechan)) {
    echo 4 -s -- Found: $ial(%nuker,%num2).nick on %nukechan
    if $me isop %nukechan {
      ban -u900 %nukechan $ial(%nuker,%num2).nick 3
      kick %nukechan $ial(%nuker,%num2).nick Stay off my ports! (AutoNab from NukeNabber)
      set %found 1
    }
    else  {
      set %found 1
    }
  }
  if ($ial(%nuker,%num2).nick == $null) { goto loopnicks1 }
  inc %num2
  goto loopial
  :loopnicks1
  inc %num
  goto loopnicks
  
  :end
  
  if %found == 0 {
    echo 4 -s Could not find this nuker on local channels...
    if (%nukehost != 0) { who %nukehost }
    who %nukeip
  }
  
  unset %nuker
  unset %num
  unset %num1
  unset %num2
  unset %nukechan
  unset %nukechans
  unset %nukehost
  unset %nukeip
  unset %nukeport
  unset %nukeprot
  unset %found
  
  halt
}
