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.

weird thing concerning variables and timers

Old posts that have not been replied to for several years.
Locked
User avatar
SaPrOuZy
Halfop
Posts: 75
Joined: Wed Mar 24, 2004 7:38 am
Location: Lebanon

weird thing concerning variables and timers

Post by SaPrOuZy »

am trying to do this delayed on join message
it's not working, i get $chan not defined
i did it in other ways but i bumped into another prob
with is if 2 users join within less than 10 seconds
the last to join gets messaged twice
any one can help with that?

Code: Select all

bind join - * join_am


proc join_am { nick host hand chan rest } {

utimer 10 {
      if {![isop $nick $chan] && $nick != "xx" && $nick != "yy"   } { 
      	if {((![isbotnick $nick]) && (![isbotnick [hand2nick $hand $chan]]))} {
         if {(([onchan $nick $chan]) && ("[getchanhost $nick $chan]" == "$host"))  || (![isop $nick $chan])} {
            # They still have the nick they joined with.
            putserv "PRIVMSG [hand2nick $hand $chan] :Hi, Please \002DO NOT REPLY\002: just checking if you are infected."
		
         } elseif {((![onchan $nick $chan]) && ([handonchan $hand $chan]) || (![isop [hand2nick $hand $chan] $chan])))} {
            # They most likely changed nicks after joining.
            putserv "PRIVMSG [hand2nick $hand $chan] :Hi, Please \002DO NOT REPLY\002: just checking if you are infected."
    
         }
      }
   }
   }
}
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

The code passed to utimer is executed in the global namespace, so to avoid name conflicts and polluting the global namespace you should create a second proc that you invoke from the timer...

Code: Select all

bind join - * join_am
proc join_am {nick host hand chan} {
	utimer 10 [list join_am2 $nick $host $hand $chan]
}
proc join_am2 {nick host hand chan} {
	# add all that other code here
}
Have you ever read "The Manual"?
User avatar
SaPrOuZy
Halfop
Posts: 75
Joined: Wed Mar 24, 2004 7:38 am
Location: Lebanon

weird thing concerning variables and timers

Post by SaPrOuZy »

thx it works,
i did that before but i didn't use [list proc...]
i think i kind of understood what it does
if anyone has a good tcl scripting tutorial other
thank the one by Marijn van Zon i'll be thanksfull
if you give me a link or something.
thanks
Locked