mIRC Home    About    Download    Register    News    Help

Print Thread
#134385 31/10/05 07:24 PM
A
Anonymous
Unregistered
Anonymous
Unregistered
A
hi, i've been trying to make a script that searches for an ip address on all the channels that i'm currently in and i have a small problem: if a users is in 5 channels and he matches the mask that i'm searching for.. he shows up 5 times in my search.
smile
any ideas what I should do? here's my script:
Code:
/*
IP SEARCH MENU BEGIN
*/
menu channel {
  Search IP:{
    %mask = $$?="Enter address mask to search for (ex: *!*@*242.98) :"
    %totalNrOfChannels = $comchan($me,0)
    %foundAtLeastOne = 0
    %iterator1 = 1
;
    while (%iterator1 <= %totalNrOfChannels) {  [color:green]  // search in every channel[/color] 
      %currentChan = $comchan($me,%iterator1) //get the name of current channel
      %iterator2 = 1
      if ($ialchan(%mask,%currentChan,0) != 0) { [color:green] // if i've found at least a user that matches.. i list them all[/color]
        while (%iterator2 <= $ialchan(%mask,%currentChan,0)) {
          echo -at $ialchan(%mask,%currentChan,%iterator2) found matching %mask in %currentChan $+ .
          %foundAtLeastOne = 1 [color:green] //also remembering i found at least one [/color]
          inc %iterator2
        }
      }
      inc %iterator1
    }
;
[color:green] // if i find none... show message[/color]
    if (%foundAtLeastOne == 0) echo -at Search found no results matching %mask $+ .
  }
}
/*
IP SEARCH MENU END
*/

a small second question would be... $comchan($me,x) is the only way i can find out the names of the channels that i'm currently in? isn't there something else?

thanks everybody.

Last edited by filip_xyz; 31/10/05 07:38 PM.
#134386 31/10/05 07:34 PM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
comchan is the only way i know

another way would be to record channels to a hash table on join and on part or on quit to remove them from hash table like

/hmake chans 30
/hadd chans $chan ...
/hdel chans $chan etc...


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
#134387 31/10/05 07:35 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Well, if you'll only ever have 1 person for a given mask, then you can just halt your script (use RETURN) if there is a match. If others will also have the same IP in a search and you want to get them as well, then you can store the nicks in a variable and not store the information if they are in the variable...

Code:
        while (%iterator2 <= $ialchan(%mask,%currentChan,0)) {
[color:red]          if (!$istok(%foundnicks,$nick,32)) {[/color]
            echo -at $ialchan(%mask,%currentChan,%iterator2) found matching %mask in %currentChan $+ .
            %foundAtLeastOne = 1
[color:red]            var %foundnicks = %foundnicks $nick
          }[/color]
          inc %iterator2
        }


The red is what I added.


Invision Support
#Invision on irc.irchighway.net
#134388 31/10/05 07:48 PM
A
Anonymous
Unregistered
Anonymous
Unregistered
A
unfortunatly that didn't seem to work. however i guessed what could be the problem so i modified it and now it looks like this.
thanks a lot
:tongue:
Code:
menu channel,status {
  Search IP:{
    %mask = $$?="Enter address mask to search for (ex: *!*@*242.98) :"
    %totalNrOfChannels = $comchan($me,0)
    %foundnicks = 0
    %foundAtLeastOne = 0
    %iterator1 = 1
    while (%iterator1 <= %totalNrOfChannels) {
      %currentChan = $comchan($me,%iterator1)
      %iterator2 = 1
      if ($ialchan(%mask,%currentChan,0) != 0) {
        while (%iterator2 <= $ialchan(%mask,%currentChan,0)) {
         [color:red]  if (!$istok(%foundnicks,$ialchan(%mask,%currentChan,%iterator2).nick,32)) { [/color]
            echo -at ••• 12 $ialchan(%mask,%currentChan,%iterator2) found matching %mask in %currentChan $+ .
            %foundAtLeastOne = 1
 [color:red]           %foundnicks = %foundnicks $ialchan(%mask,%currentChan,%iterator2).nick   [/color]
          }
          inc %iterator2
        }
      }
      inc %iterator1
    }
    if (%foundAtLeastOne == 0) echo -at ••• 12Search found no results matching %mask $+ .
  }
}

#134389 31/10/05 07:56 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Ah, sorry. I didn't look close enough at your script. I just assumed $nick was filled.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard