| View previous topic :: View next topic |
| Author |
Message |
rapattack Voice
Joined: 18 Aug 2011 Posts: 6
|
Posted: Thu Aug 18, 2011 7:17 am Post subject: On join msg; doesn't work when users have no record in bot |
|
|
Dear all,
I was creating something that mentions which score a user has and also which rank he has got when he joins the trivia chan.
Below is the code:
| Code: | proc tgjoinmsg {nick host hand chan} {
global botnick tgplaying tgcmdhelp tgcmdstart tgflagsstart tgcmdstop tgflagsstop tgchan tgscoresbyname tgranksbyname
if {$nick != $botnick} {
set _msg ""
append _msg "Welcome $nick! You're on the [tgcolmisc2][ordnumber $tgranksbyname([strlwr $nick])][tgcolmisc1] rank with [tgcolmisc2]$tgscoresbyname([strlwr $nick])[tgcolmisc1] points."
if {$tgplaying==1} {
append _msg ""
} else {
append _msg ""
}
if {[matchattr $hand $tgflagsstart $tgchan]&&$tgplaying==0} {
append _msg "!!!Enter !start to start the game!!!"
}
append _msg ""
[tgpriv] $chan "$_msg"
}
} |
It works when the user already has a score (1 or above), but it doesn't work for unknown users... I'd like the bot to say Welcome to the new user, and tell him that he currently doesn't have any scores.
Thanks for all help in advance !!!!!!!
Oh yeah this is the error I get when an unknown user joins the channel:
[13:09:20] Tcl error [tgjoinmsg]: can't read "tgranksbyname(maagd15m)": no such element in array
But I don't know how to fix it Thanks! |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Fri Jun 22, 2012 12:22 pm Post subject: Trivia with a working onjoin message:) |
|
|
Try BogusTrivia for a trivia game with a working on join message for unknown players. _________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Mon Jul 02, 2012 6:24 pm Post subject: Re: On join msg; doesn't work when users have no record in b |
|
|
| rapattack wrote: | | It works when the user already has a score (1 or above), but it doesn't work for unknown users... I'd like the bot to say Welcome to the new user, and tell him that he currently doesn't have any scores. |
| Code: | proc tgjoinmsg {nick host hand chan} {
global tgscoresbyname tgranksbyname tgflagsstart tgplaying tgchan
# is it the trivia channel?
if {![string equal $chan $tgchan]} { return }
# yes, is it the bots nickname?
if {![botnick $nick]} {
# no, does an entry exist for this nickname?
if {[info exists tgranksbyname([strlwr $nick])]} {
# yes, set the message
set _msg "Welcome $nick! You're on the [tgcolmisc2][ordnumber $tgranksbyname([strlwr $nick])][tgcolmisc1] rank with [tgcolmisc2]$tgscoresbyname([strlwr $nick])[tgcolmisc1] points."
# is trivia off, but this person can start it?
if {[matchattr $hand $tgflagsstart $tgchan]&&$tgplaying==0} {
# yes, append the message
append _msg " !!!Enter !start to start the game!!!"
}
} else {
# no, an entry doesn't exist for this person, set the message
set _msg "Welcome $nick. You currently have no score for trivia."
}
# output
tgpriv $chan "$_msg"
}
} |
_________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Tue Jul 03, 2012 2:43 pm Post subject: |
|
|
Why not call only the tgchan variable and if the channel is it the trivia channel proceed with also calling the rest of the variables? In theory should save up precious some resources.
Also, why not store nick in a lower format (strlwr $nick) and use it instead of transforming it 3 times. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
|