| View previous topic :: View next topic |
| Author |
Message |
Branden Halfop
Joined: 04 Aug 2007 Posts: 61
|
Posted: Sat Oct 04, 2008 2:53 pm Post subject: Global Vars [Help] {Solved} |
|
|
Hi there,
I'm having an issue with vars, one proc is making the var, and I want another proc to be able to read that var.
| Code: |
bind pub m|m "!LockDown" LockDown
bind pub m|m "!UnLock" UnLock
bind pubm - "*CONNECT*" CONNECTLOCKDOWN
proc LockDown { nick host hand chan text } {
global botnick LockDown
set LockDown on
putquick "MODE $botnick +s +cFs"
foreach chan [channels] {
putquick "MODE $chan +mNipCRS"
putquick "MODE $chan +k LockDownModeInitiated"
putquick "PRIVMSG $chan Network is going into lockdown mode, from this point until LockDown is removed, no one will be able to connect to this network."
}
}
proc UnLock { nick host hand chan text } {
global botnick LockDown
set LockDown off
putquick "MODE $botnick -s -cFs"
foreach chan [channels] {
putquick "MODE $chan -mNipCRS"
putquick "MODE $chan -k LockDownModeInitiated"
putquick "PRIVMSG $chan Network is off of LockDown, everything is back to normal."
}
}
proc CONNECTLOCKDOWN { nick host hand chan text } {
global LockDown
set User [lindex [split $text] 3]
if {$chan == "#4ct1v1ty" && $LockDown == "on"} {
putserv "GLINE [stripcodes bcruag $User] 5m :Network is in lockdown mode, this ban will expire in 5 minuets, please reconnect at that time"
} else {
return
}
}
|
I get this error:
| Quote: |
[10/04/08][14:48:04] <NightCrawler> [11:41] Tcl error [CONNECT]: can't read "LockDown": no such variable
|
Last edited by Branden on Sat Oct 04, 2008 3:13 pm; edited 1 time in total |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sat Oct 04, 2008 2:57 pm Post subject: |
|
|
This is because the variable isn't declared yet. The global command only links the variable name in the local namespace to the one in globalspace, or simply, "myvar" is translated to "::myvar". You still have to create ::myvar.
In your case, it is most likely due to neither LockDown or UnLock being called yet. Easy fix would be to instantiate the variable as the script loads:
| Code: | ...
bind pubm - "*CONNECT*" CONNECTLOCKDOWN
set LockDown off
...
|
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Branden Halfop
Joined: 04 Aug 2007 Posts: 61
|
Posted: Sat Oct 04, 2008 3:06 pm Post subject: |
|
|
| I'm getting this error AFTER the fact that LockDown or UnLock has been called on. |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sat Oct 04, 2008 3:10 pm Post subject: |
|
|
Looking a bit further, it seems the error is not in CONNECTLOCKDOWN, but in a proc named CONNECT. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
|