egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

only one time bet

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
gembels
Voice


Joined: 07 Jul 2012
Posts: 26

PostPosted: Wed Jul 31, 2013 8:20 pm    Post subject: only one time bet Reply with quote

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
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Wed Jul 31, 2013 8:40 pm    Post subject: Re: only one time bet Reply with quote

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 {. " Smile

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
View user's profile Send private message
gembels
Voice


Joined: 07 Jul 2012
Posts: 26

PostPosted: Thu Aug 01, 2013 6:02 am    Post subject: Re: only one time bet Reply with quote

tested with your guess, still can bet more than 1... with nick "[h]"
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Thu Aug 01, 2013 8:17 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber