mIRC Home    About    Download    Register    News    Help

Print Thread
Page 2 of 2 1 2
Joe_Dean #207119 06/12/08 11:51 PM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Saving to INI files (by using the -i switch on /hsave and /hload) slows the save/load process. You can use any filename and extension that you want.

-genius_at_work

Joe_Dean #207120 06/12/08 11:58 PM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Yes any extension will work. The reason I asked if you were saving/loading using the section name, is that this option is only available when using the -i switch and an ini file.

It forces compatability with the ini file.
If you're only using one section, then you could use the normal /hsave & /hload without worries, however, if you're loading/saving multiple sections, than this can cause problems.

RusselB #207123 07/12/08 03:49 AM
Joined: May 2008
Posts: 127
J
Vogon poet
OP Offline
Vogon poet
J
Joined: May 2008
Posts: 127
Thanks guys - loads and saves very quickly without massive CPU usage. :P laugh

Joe_Dean #207161 08/12/08 04:08 AM
Joined: May 2008
Posts: 127
J
Vogon poet
OP Offline
Vogon poet
J
Joined: May 2008
Posts: 127
Hmm, I have a slight problem. Here's my script:

http://mirc.lvrcr.com/10

Now when someone does !searchip 1.2.3 (wildcard search), the script returns not only nicks who's IP starts with 1.2.3, but also returns nicks with 1.2.3 anywhere in the value.

So if a user has these values: 2.3.4.5,0.1.2.3

The script would return them as a result if I did !searchip 1.2.3

It shouldn't do that though - it should only return results in which have a value that start with 1.2.3 after the comma. I've tried messing around with it, but I can't seem to get it to work.

Last edited by Joe_Dean; 08/12/08 04:12 AM.
Joe_Dean #207162 08/12/08 04:21 AM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Since you are storing multiple IPs together, you need to parse the data before you send it. The easiest way would be to loop through each comma-delimited list of IPs, and only return IPs that match the original search. Like this pseudocode:


search hash for items matching 1.2.3.*
;found value 2.3.4.5,1.2.3.4,5.6.7.8
loop through each IP in the list
IP 2.3.4.5 doesn't match 1.2.3.*, so don't show
IP 1.2.3.4 does match 1.2.3.*, so show
IP 5.6.7.8 doesn't match 1.2.3.*, so don't show


-genius_at_work

Joe_Dean #207175 08/12/08 08:15 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Originally Posted By: Horstl
The problem with a wildcard scan is that it will ignore the comma delimiters, and match on the whole data part.

Try my cumbrous regex approach, or loop the data part (tokens) of each $hfind(w) return to verify the match like genius_at_work suggests, or re-reconsider your method of storing the data (the way genius_at_work did suggest a while ago). smile

Horstl #207224 10/12/08 03:02 AM
Joined: May 2008
Posts: 127
J
Vogon poet
OP Offline
Vogon poet
J
Joined: May 2008
Posts: 127
Ok, right now it's looping through the entire value using $gettok, and if $2 isin or matches the current IP, spits out their name.

Only problem is if someone has numerous IP's in the range you specify, it spits their name out the same amount of times as the number of matching IP's they have. For example:

User 'Joe_Dean' has these IP's: 1.2.89.89,1.2.65.65,1.2.33.33

I type, !searchip 1.2 and the script finds 3 IP's that match the range I specified. It repeats their name 3 times.

So my question is, how do I halt scanning through all their IP's AFTER it finds the first match? Kinda hard putting a halt in the script because it will halt out wanted information...

http://mirc.lvrcr.com/11

Also, how do I add and error to each if no match is found? If I put an else statement right after the 'if ($2 $+ .* iswm...', then it would say "no matches found" if the current IP doesn't match but the rest possibly could. So I'd need an elseif to determine when the script has reached the last IP in the value. Not sure how to do that...

Joe_Dean #207227 10/12/08 03:24 AM
Joined: May 2008
Posts: 127
J
Vogon poet
OP Offline
Vogon poet
J
Joined: May 2008
Posts: 127
elseif (%octet == $gettok($hget(userips,%match),0,44))

seems to work, but I dunno where to place the inc %mmm

If I use it like this:

Code:
if ($gettok($2,0,46) == 2) {
  if ($2 $+ .*.* iswm $gettok($hget(userips,%match),%octet,44)) {
    .notice $nick $cl %mmm $+ . %match [ $+ $gettok($hget(userips,%match),0,44) $+ ] $iif((%isRegged != $null),(registered),(unregistered))
  }
  elseif (%octet == $gettok($hget(userips,%match),0,44)) {
    .notice $nick $cl no matches. | halt
  }
  inc %mmm
}


...then when there are matches, the script shows %mmm to the user and skips a number if that number IP wasn't a match (1,2,3,5,6,8)


----------------------------

EDIT: I fixed it. I just added a new var and only /inc'd it if there was a match.

Code:
%resnum = 1
if ($gettok($2,0,46) == 2) {
  if ($2 $+ .*.* iswm $gettok($hget(userips,%match),%octet,44)) {
    .notice $nick $cl %resnum $+ . %match [ $+ $gettok($hget(userips,%match),0,44) $+ ] $iif((%isRegged != $null),(registered),(unregistered)) | inc %resnum
  }
  elseif (%octet == $gettok($hget(userips,%match),0,44)) { 
    .notice $nick $cl no matches. | halt
  }
  inc %mmm
}

Last edited by Joe_Dean; 10/12/08 03:33 AM.
Joe_Dean #207228 10/12/08 03:38 AM
Joined: May 2008
Posts: 127
J
Vogon poet
OP Offline
Vogon poet
J
Joined: May 2008
Posts: 127
lol, nvm, I feel stupid now. Just ignore my entire previous post. :P

The elseif isn't nick specific (it should check when the last IP is being matched for the same nick). Right now it lists matches for the first nick, displays the error, then halts leaving out the rest of the matches.

Page 2 of 2 1 2

Link Copied to Clipboard