Yes, using a loop to read through hundreds of lines will be slow. You should use $read()'s built in search functions. (/help $read)
if ($nick ison $chan) {
var %relay notice $nick
var %relay2 msg $chan
goto seen
}
if ($nick !ison $chan) {
var %relay msg $nick
var %relat2 msg $nick
goto seen
}
Could be changed to something like:
if (#) {
var %relay notice $nick
var %relay2 msg $chan
}
else {
var %relay msg $nick
var %relay2 msg $nick
;I'm assuming "relat2" was a typo here.
;There's no reason to use 'goto seen'.
}
'goto seen_true' should really just be 'break' to exit the loop.
You can get rid of a lot of variables here:
var %hostname_seen $address($nick,2)
var %hostname-minus-front_seen $remove(%hostname_seen,*!*@)
var %hostname-minus-back_seen $remove(%hostname-minus-front_seen,.users.netgamers.org)
var %access_seen $readini(adata.ini,%hostname-minus-back_seen,access)
equals:
var %access_seen $remove($address($nick,2),*!*@,.users.netgamers.org)
var %access_seen $readini(adata.ini,%access_seen,access)
$chr(19) in the hostmask is strange, I don't think I've seen that before.
if (%access_seen == hc || %access_seen == bc || %access_seen == scanner || %access_seen == member) {
;could be
if ($istok(hc bc scanner member, %access_seen, 32)) {
Rather than using a bunch of halts in the main body, just use elseif (). (syntax: /help if then else)
I think /filter would be a better solution than /fopen $fread...
var %x 1
var %totallines $lines(users.txt)
while (%x <= %totallines) {
if ($2 isin $read(users.txt,%x)) {
var %search $addtok(%search,$read(users.txt,%x),32)
}
inc %x
}
Should be equivalent to:
filter -fkg users.txt user_search $2
;
alias -l user_search set -u %search $addtok(%search, $1, 32)
Thanks for that! Do you know why the while loops are causing mIRC to crash? Is it because the txt file contains too much data for it to loop?