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.

only one time bet

Help for those learning Tcl or writing their own scripts.
Post Reply
g
gembels
Voice
Posts: 26
Joined: Sat Jul 07, 2012 9:31 pm

only one time bet

Post by gembels »

This 2 peice of code...

Code: Select all

                                        set namae [tgstripcodesdx [strlwr [string trim $nick]]]
                                        set firstone [lsearch $tgwrngansw $namae]
                                        if {$firstone ==-1} {lappend tgwrngansw $namae}
                                        if {$firstone !=-1} {
                                        tggamemsg2 "$nick, only 1 time bet"
                                        return
                                        }
					tggamemsg2 "$nick, bet accepted: $text"

Code: Select all

proc tgstripcodesdx {text} {
        regsub -all -- "(\[0-9\]\[0-9\]?(,\[0-9\]\[0-9\]?)?)?" $text "" text
        regsub -all -- "\t" $text " " text
        set text "[string map -nocase [list "\[" "" "\]" "" "~" ""] $text]"
        return $text
}
In my ircd server we allow to have nick using symbol like []~-_ of course also A-Za-z0-9

the problem is, if nick like "[]Name" or "[the]master" without quote, has always can pass the strict .. can bet 10 times.. the codes should only allow 1 time betting..

another nick like symbol ~-_ and of course also A-Za-z0-9 have no problem with it, everything good (only 1 time bet)

thanks in advance
w
willyw
Revered One
Posts: 1209
Joined: Thu Jan 15, 2009 12:55 am

Re: only one time bet

Post by willyw »

Is $tgwrngansw a proper list?

lsearch is meant for use on lists.
Ref: http://www.tcl.tk/man/tcl8.5/TclCmd/lsearch.htm

If given something else, you may get unexpected and undesirable results.
Ref: http://www.peterre.info/characters.html
Be sure (for now) to read the part about converting between lists and strings.
There is even a snippet of script there, and below it, it says,
"The script choked on nicks that contained [ or {. " :)

Bookmark that - it is worth having.


A guess - and that is all this is - would be:

Code: Select all

set firstone [lsearch [split $tgwrngansw] $namae]

I hope this helps.
g
gembels
Voice
Posts: 26
Joined: Sat Jul 07, 2012 9:31 pm

Re: only one time bet

Post by gembels »

tested with your guess, still can bet more than 1... with nick "[h]"
w
willyw
Revered One
Posts: 1209
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

Post the complete script, or a link where it can be downloaded.

Maybe someone will have time to test it with you.
Post Reply