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 

Global Vars [Help] {Solved}

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


Joined: 04 Aug 2007
Posts: 61

PostPosted: Sat Oct 04, 2008 2:53 pm    Post subject: Global Vars [Help] {Solved} Reply with quote

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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat Oct 04, 2008 2:57 pm    Post subject: Reply with quote

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
View user's profile Send private message
Branden
Halfop


Joined: 04 Aug 2007
Posts: 61

PostPosted: Sat Oct 04, 2008 3:06 pm    Post subject: Reply with quote

I'm getting this error AFTER the fact that LockDown or UnLock has been called on.
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat Oct 04, 2008 3:10 pm    Post subject: Reply with quote

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