typefighter wrote:Hi guys
Havin a problem (again)
Code: Select all
proc check:devoice {nick host hand chan text} {
set devoicenick [lindex $text 0]
if {[matchattr $nick -|m $chan] || [$devoicenick == $nick]} {
putserv "MODE $chan -v $devoicenick"
return 0
} else {
puthelp "NOTICE $nick :Permission denied."
}
return 0
}
It's meant to check if the user who is carrying out the devoice command has either an "m" flag in the channel (which works) or if it is their own nick. I can get it to check if they have the m flag fine - it's the other bit I'm having problems with. I have tried all I can fink of and looked at other peoples scripts.
Thanks in advance.
- type.
Your problem lays in: [$devoicenick == $nick]
[]'s are used to evaluate TCL commands, not expressions in 'if' statements.
You simply want: ($devoicenick == $nick)
(Parentheses group them together, making the code logic look better)
And a suggestion... You should have a case insensitive comparison..
ie.
([string tolower $devoicenick] == [string tolower $nick])
Note how we use []'s to evaluate the command "string tolower", and leave the expression, == , out of the []'s .
I know this probably sounds/looks confusing.. But try going over some of the TCL tutorial sites (like suninet's) again and again till you start to see.
Edit:
Noticed another possible downfall... (that is so rampant on this forum it seems)
the usage of a list operation on a string.. (set devoicenick [lindex $text 0])
$text is a string ...
lindex is a list operation ...
You need to first convert text into a list before doing a list operation on it..
This is done with "split" ..
set devoicenick [lindex [split $text] 0]
and since lindex returns an element in this case which is a string, devoicenick will be a string as well.
This will help avoid problems you may have encountered with user's who have special characters in their nicks.
Hope this helps...
