something is Wrong to this code

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
Thanhas
Op
Posts: 124
Joined: Sat Sep 02, 2006 11:14 am
Location: Ottawa, Canada

something is Wrong to this code

Post by Thanhas »

Code: Select all

# Change this binding if you want.

bind pub - !help pub_help

# }------------------------------------------------------------------{
# You shouldnt need to change anything from hereon.

global helpcount
set helpcount 0

proc decr {var} {
	return [expr $var -1]
}

proc addhelp {modes usage info} {
	global helpmodes helpusage helpinfo helpcount
	
	set helpmodes($helpcount) $modes
	set helpusage($helpcount) $usage
	set helpinfo($helpcount) $info
	set helpcount [incr helpcount]
	return 1
}

proc pub_help {nick uhost hand chan args} {
	global helpmodes helpusage helpinfo helpcount
	
	set helptotal [decr $helpcount]
	if { $helptotal == "-1" } {
		putserv "NOTICE $nick :No commands for $chan documented...sorry =("
		return 0
	}
	
	putserv "NOTICE $nick :\002Commands available to you on $chan\002"
	
	set i 0
	while { 1 } {
		if { [matchattr $hand $helpmodes($i)] || $helpmodes($i) == "" } {
			# Ok, the user has access to this one..display it
			putserv "NOTICE $nick :Usage: \002$helpusage($i)\002"
			putserv "NOTICE $nick :  $helpinfo($i)"
		}
		# If not, oh well...they wont care.
		
		# Increment the count
		set i [incr i]
		
		if { [decr $i] == $helptotal } {
			# Yep...we're past due..
			break
		}
		# Otherwise, just let the loop flow.
	}
	
	# End the help.
	
	putserv "NOTICE $nick :\002 --- Thats all --- \002"
	return 0
}

addhelp "" "!help" "--- My Useful Commands ---"
addhelp "" "\002!google\002 <define:|spell:> <search terms> \002!images\002 <search terms> \002!groups\002 <search terms> \002!local\002 <what> near <where> \002 !QL \002 <General Quotes> \002 !mash \002 <Quotes of mash>"
addhelp "" "\002!print\002 <search term> \002!video\002 <search terms> \002!fight\002 <word(s) one> vs <word(s) two> \002!stat\002 <This is to know about ur stats on Channel>"
addhelp "" "\002!top10\002 <For General Stats of the Channel> \002!ip\002 <Nick/host/IP ---- an easy way to know about the address \002!ip\002 <Nick/host/IP - an easy way to know about the address"
addhelp "" "\002!ip\002 <Nick/host/IP ---- an easy way to know about the address \002 !QL \002 <General Quotes> \002 !mash \002 <Quotes of mash>"

putlog "Global-Hel. v1.00 by BLuEPhYsH Successfully loaded!"

The Errors are

Code: Select all

[06:10] Tcl error in file 'HosTer.conf':
[06:10] wrong # args: should be "addhelp modes usage info"
    while executing
"addhelp "" "\002!google\002 <define:|spell:> <search terms> \002!images\002 <search terms> \002!groups\002 <search terms> \002!local\002 <what> near <..."
    (file "scripts/chelp.tcl" line 92)
    invoked from within
"source scripts/chelp.tcl"
    (file "HosTer.conf" line 248)
[06:10] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)
it should not show one thing thats it

Code: Select all

-HosTer- Usage: !help
-HosTer-   --- My Useful Commands ---
-HosTer- Usage: !google
-HosTer-   <define:|spell:> <search terms> !images <search terms> !groups <search terms> !local <what> near <where>

it shuold not do 2 notices for one line :((
Usage:etc please Remove this things
i will be so glad if helped :P
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Read here about how to load scripts without crashing the bot and getting more useful debug output from it:

http://forum.egghelp.org/viewtopic.php?p=63899#63899

The info you posted isn't really helpful in debugging that script..

If all you want is a basic help file type thing, here's an example of what I use:

Code: Select all

bind pub - !help pub:help

proc pub:help{nick uhost hand chan text} {
        global botnick
        if {$chan == "privmsg"} {set chan $nick}
        if {[onchan $nick]} {
                puthelp "PRIVMSG $nick :\00310Fun & Games\003"
                puthelp "PRIVMSG $nick :blackjack: Blackjack/21 card game. Type .bjhelp for usage."
                puthelp "PRIVMSG $nick :.bofh    : Bastard Operator From Hell Excuse Generator!"                
                puthelp "PRIVMSG $nick :.deliver : Send a friend some ascii art! /msg $botnick deliver help"
                puthelp "PRIVMSG $nick :.dice    : Advanced dice rolling script - Type .dice help for usage"
                puthelp "PRIVMSG $nick :.fhoro   : Funny Horoscopes - Type .fhoro <sign> in channel."       
                puthelp "PRIVMSG $nick :.greet   : Greet script - Set a custom greeting when you join"      
                return
        }
}
#-antiword-wrap-##############################################################################################     
Now go read some basic tcl scripting and eggdrop documentation so you can learn how to add/edit the lines to say whatever you want for your help file.
User avatar
Thanhas
Op
Posts: 124
Joined: Sat Sep 02, 2006 11:14 am
Location: Ottawa, Canada

:(

Post by Thanhas »

invalid command name "\rtf1\fbidis\ansi\ansicpg1256\deff0\deflang1025{\fonttbl{\f0\froman\fcharset0 Times New Roman;}{\f1\fswiss\fcharset0 Arial;}}
[04:07:47:p:30:Oct] <(HosTer> {\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\ltrpar\sb100\sa100\lang1033\f0\fs24 bind pub - !help pub:help \line\line proc pub:help\{nick uhost hand chan text\} \{ \line global botnick \line if \{$chan == "privmsg"\} \{set chan $nick\} \line if \{[onchan $nick]\} \{ \line puthelp "PRIVMSG $nick :\\00310Fun & Games\\003" \line puth
[04:07:47:p:30:Oct] <(HosTer> [11:37] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)
[04:07:47:p:30:Oct] <(HosTer> [12] Chat closed
thats the error of ur fiven code :((
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Re: :(

Post by user »

Thanhas wrote:thats the error of ur fiven code :((
No. That error is caused by you saving the script in some weird format. (looks like wordpad rtf)
Have you ever read "The Manual"?
Post Reply