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 

On join msg; doesn't work when users have no record in bot

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


Joined: 18 Aug 2011
Posts: 6

PostPosted: Thu Aug 18, 2011 7:17 am    Post subject: On join msg; doesn't work when users have no record in bot Reply with quote

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 !!!!!!! Smile


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 Smile Thanks!
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Fri Jun 22, 2012 12:22 pm    Post subject: Trivia with a working onjoin message:) Reply with quote

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
View user's profile Send private message Visit poster's website
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Mon Jul 02, 2012 6:24 pm    Post subject: Re: On join msg; doesn't work when users have no record in b Reply with quote

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
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Tue Jul 03, 2012 2:43 pm    Post subject: Reply with quote

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
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