mIRC Home    About    Download    Register    News    Help

Print Thread
#153464 17/07/06 02:26 PM
Joined: Mar 2006
Posts: 50
T
Tw33ty Offline OP
Babel fish
OP Offline
Babel fish
T
Joined: Mar 2006
Posts: 50
Any1 knows why this doesn't work?

Code:
on *:join:#:{
var %x = 1
inc %x
if ($read(badword.txt,%x) isin $nick) {
kick # $nick Bad Nick!
}
}

#153465 17/07/06 04:59 PM
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
it didnt work because you have a var there that does nothing the way you wrote it.
if you have one word per line in badword.txt:
Code:
on *:join:#:{
var %x = $lines(badword.txt)
while (%x) {
if ($read(badword.txt,%x) isin $nick) {
kick # $nick Bad Nick!
}
dec %x
}


something like this might work, it might have false matches too.
fex: The_Assassin joins
A valid word, but likely to have a match in your file.

there is no good substitute for a good op

#153466 17/07/06 05:14 PM
Joined: Mar 2006
Posts: 50
T
Tw33ty Offline OP
Babel fish
OP Offline
Babel fish
T
Joined: Mar 2006
Posts: 50
thx
but what do while (%x) and dec %x exactly mean?

#153467 17/07/06 05:48 PM
Joined: Apr 2006
Posts: 400
K
Fjord artisan
Offline
Fjord artisan
K
Joined: Apr 2006
Posts: 400
hey MikeChat laugh, "while (%x)" means while %x isn't null (has a value) and dec %x means decrease the value of %x by 1.


-Kurdish_Assass1n
#153468 17/07/06 06:21 PM
Joined: Mar 2006
Posts: 50
T
Tw33ty Offline OP
Babel fish
OP Offline
Babel fish
T
Joined: Mar 2006
Posts: 50
thx
and where is the difference between "dec %x" and "inc %x"?

#153469 17/07/06 06:37 PM
Joined: Apr 2006
Posts: 464
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
dec = decrease (so make smaller, 6, 5, 4, 3, ,2, 1)
inc = increase (so make bigger, 1, 2, 3, 4, 5, 6)

#153470 17/07/06 06:37 PM
Joined: Mar 2003
Posts: 612
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Mar 2003
Posts: 612
dec %x is decresing by one and inc %x is incrementing by one. i personally prefer to inc until a number or condition is met, others prefer to decrement until a number or condition(usually 0) is met.

btk


billythekid
#153471 17/07/06 06:56 PM
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
as was said by Kurdish_Assass1n, the while runs in a loop the commands following it in the script, dec %x reduces the value of %x

on @*:join:#:{
var %x = $lines(badword.txt)
; If your badword.txt has 14 lines, %x has the value "14"
while (%x) {
; /help while loops
; as long as %x has a value bigger than 0 it will perform the commands
if ($read(badword.txt,%x) isin $nick) {
kick # $nick Bad Nick!
}
dec %x
; decreases the value in %x, which started at say 14
; each loop it will decrease just like a $calc would do, then the
;if ($read(badword.txt,%x) will read line 14, then line 13 then line 12 and so on til it
;hits 0, then the loop will exit to any other scripting written in before the
;closeing } of the event

}

#153472 17/07/06 09:33 PM
Joined: Mar 2006
Posts: 50
T
Tw33ty Offline OP
Babel fish
OP Offline
Babel fish
T
Joined: Mar 2006
Posts: 50
all right ... i think I got it ... thx for helping smile

#153473 18/07/06 09:02 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
I sugest doing it this way.

Code:
on @*:join:#:{
 var %max = $lines(badword.txt), %counter = 1
 while (%counter <= %max) {
    if ($read(badword.txt,nt,%counter) isin $nick) { kick $chan $nick Bad Nick! | return }
    inc %counter
  }
}


1st get a %MAX value to go to (total lines in the file), and also set a start value %COUNTER to count up to the %MAX

Check if COUNTER is less or equal to MAX and if so do the contents of the while loop
..Read the word on line number COUNTER of the file and if its in $nick, then kick the nick & RETURN (exits the event) [means u dont carry on]
..Otherwise just add one to COUNTER and repeat the while loop check

* the reason i would start at the begining of the file and work towards the end, is two fold, there is less disk access in reading the first lines of the file vs the last lines, so if the match is located near the start smaller disk access has occured, 2nd reason is more real world logic than fact, the more likely bad words well be in the file first, so its better to start from the front of the file, than the end.

* the reason i store the %MAX value, is becuase every time u do $lines(badword.txt) it must read the whole file to get the number of lines, so its much much better to do it once and store it than compare to it in the while loop.

* the last thing to note is the RETURN following the kick, there is no reason to continue through the rest of the file if the user was kicked.


Link Copied to Clipboard