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.

what is wrong with this script?

Old posts that have not been replied to for several years.
Locked
a
ahv

Post by ahv »

Can anybody tell me what is wrong with this script?

It doesn't calculate:

Code: Select all

# listen to all ahv commands in channels 
bind pub - ahv pub:ahv 

# limit the chans to listen in by filling them in here ( more chans goes this way {#chan1 #chan2} 
set enabledchans {#ahv #nike #bbs #equinox1 #equinox2 #equinox3 #equinox4 #equinox5 #antisocial #lotus} 

# procedure to check if chan where command is used is listed chan 
proc isenabledchan { channel } { 
   global enabledchans 
   # compare each chan in $enabledchans with current chan and return 1 (true) if chan is listed 
   foreach enablechan $enabledchans { 
      if { $channel == $enablechan } { 
         return 1 
      } 
   } 
   return 0 
} 

# main procedure to handle the ahv commands 
proc pub:ahv { nick uhost handle channel arg } { 
   # check if command should work in this chan 
   set chan [string tolower $channel]    
   if { ![isenabledchan $chan] } { 
      return 1 
   } 
   # check if valid command (calc)
   if { [llength $arg] == 0 } { 
      putserv "PRIVMSG $channel :Unable to perform request, give command." 
   } else { 
      # get command and compare it to "xp" 
      set command [lindex $arg 0] 
      set command [string tolower $command] 
      if { [string compare $command xp] == 0 } { 
         # check if valid number of arguments 
         if { [llength $arg] < 2 } { 
            putserv "PRIVMSG $channel :Please check the help function if you don't know how to use this command." 
         # command syntax is ok, process request 
         } else { 
            set calc_a [lindex $arg 1] 
            set calc_b [lindex $arg 1]
            if { $calc_b == "" } { set $calc_b 24 }
              { set $calc_temp [expr $calc_a / 1.01 * $calc_b] }
              { putserv "PRIVMSG $channel :After $calc_b hours in the bank, $calc_a gold will be $calc_temp gold." }
         }
   }
} 
_________________


<font size=-1>[ This Message was edited by: ahv on 2002-05-30 03:58 ]</font>
D
Darude

Post by Darude »

I guess it's ...
set calc_temp [expr $calc_a / 1.01 * $calc_b]
... and not set $calc_temp ...
a
ahv

Post by ahv »

Ok i changed that. but it still doesn't work
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

if { ![isenabledchan $chan] } {
return 1
}


is'nt that supposed to "return 0"?
or

if { [isenabledchan $chan] } {
return 1
}

Elen sila lúmenn' omentielvo
a
ahv

Post by ahv »

I have a script that uses the same setup as that.

That script works just fine.

The script i posted here, will be added to that script so i can use more commands after ahv (which is the name of my bot)
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

If the other script uses the same setup (bind pub - ahv) then only one of them can be loaded at the same time.

If you want to add more commands, you should edit the original script, not try to add a new one.
a
ahv

Post by ahv »

i know that.

This script is used on a test bot that doesn't have the main script loaded
Locked