| View previous topic :: View next topic |
| Author |
Message |
gembels Voice
Joined: 07 Jul 2012 Posts: 26
|
Posted: Wed Jul 31, 2013 8:20 pm Post subject: only one time bet |
|
|
This 2 peice of code...
| Code: | 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: | 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 |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Wed Jul 31, 2013 8:40 pm Post subject: Re: only one time bet |
|
|
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: |
set firstone [lsearch [split $tgwrngansw] $namae]
|
I hope this helps. |
|
| Back to top |
|
 |
gembels Voice
Joined: 07 Jul 2012 Posts: 26
|
Posted: Thu Aug 01, 2013 6:02 am Post subject: Re: only one time bet |
|
|
| tested with your guess, still can bet more than 1... with nick "[h]" |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Thu Aug 01, 2013 8:17 am Post subject: |
|
|
Post the complete script, or a link where it can be downloaded.
Maybe someone will have time to test it with you. |
|
| Back to top |
|
 |
|