This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Help with || (or).

Old posts that have not been replied to for several years.
Locked
t
typefighter

Help with || (or).

Post by typefighter »

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.
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Re: Help with || (or).

Post by strikelight »

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...
:)
t
typefighter

Post by typefighter »

Hi strikelight.

Thanks :) It works now, I understand what you said. That would explain the ERROR message I was getting.

- type
Locked