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.

Need help with variables

Help for those learning Tcl or writing their own scripts.
Post Reply
_
_TURBO_
Voice
Posts: 1
Joined: Tue Jan 19, 2010 3:14 pm

Need help with variables

Post by _TURBO_ »

hi, need some help whit this script.

Code: Select all

set badversion {"logoscript" "script"}


bind ctcr - VERSION clientinf
proc clientinf {nick uhost hand dest key arg} {
	global badversion
	foreach version $badversion {
		if {[string match "*[string tolower $version]*" [string tolower $arg]]} {
			global script
			set script "1"
			putserv "privmsg #test :using script var: $script"
		}
	}
}

bind RAW - 671 whois:ssl
proc whois:ssl {from key text} {
	global "ssl"
	set ssl "[lindex [split $text " "] 4]"
	putserv "privmsg #test :using ssl var  $ssl"
}

bind pub - "!sendpass" sp

proc sp {nick uhost hand chan arg} {
	global "ssl" "script"
	putquick "whois $nick $nick"
	putserv "PRIVMSG $nick :\001VERSION\001"
	if {$script == "1"} {
		puthelp "privmsg #test :dont use script"
		if {$ssl != "a"} {
		puthelp "privmsg #test :please use ssl" }
	} else {
		puthelp "privmsg #test :Ok sending pass"
		
	}
}
Bot says Tcl error [sp]: can't read "script": no such variable
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

The part of your code below will only globalise the variable script and set it to 1 when the 'if' statement is passed. When the 'if' statement fails, the variable script does not exist. Rethink the logic.

Code: Select all

    if {[string match "*[string tolower $version]*" [string tolower $arg]]} { 
        global script 
        set script "1" 
        putserv "privmsg #test :using script var: $script" 
    }
I must have had nothing to do
Post Reply