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 utimer then killutimer

Old posts that have not been replied to for several years.
Locked
s
sdez_

Need help with utimer then killutimer

Post by sdez_ »

first Newbie here

I am tring to start a timer which runs a proc

utimer 120 [proc]

and in the proc that is runs I want to do a

if {"match this" } { do that and "killutimer"} {no match "do this"}

(I know how to "match this" "do That" and "do this" :) )

I have tried all kinds of things that I have read or seen in scripts
but all I come up with are errors

Please help a newbie understand how this works

I may have to post what I have but, I'll start with this Thanks
User avatar
Dedan
Master
Posts: 260
Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis

Post by Dedan »

Timers seem to be a mystery for tcl,
everyone seems to do them differently.

some make a timer in a var and then check for it,
others use different ways to 'search" the timers
for the timer they are looking for,
ie. string match where i use "=="

The below is ripped from my script and works:

*** note ***
be careful that you are searching [utimers] for
second timers and using killutimer
Searching [timers] for minute timers, using killtimer

Code: Select all


timer 30 [list AV_unban $host]

foreach t [timers] {
  if {[lindex $t 1] == "AV_unban"} {
    killtimer [lindex $t end]
  }
}


utimer 37 [list Part_dec $host:$channel]

foreach t [utimers] {
  if {[lindex $t 1] == "Part_dec"} {
    killutimer [lindex $t end]
  }
}
i hope this helps, i am sure others will show you
other ways to do this, give them a try and
see what works for you 8)
I once was an intelligent young man, now i am old and i can not remember who i was.
User avatar
Jil Larner
Voice
Posts: 14
Joined: Fri Aug 20, 2004 8:28 am
Location: France

Post by Jil Larner »

hi,

uh... timer is automatically killed when finished running proc. No ?
D
DayCuts
Voice
Posts: 37
Joined: Tue Jun 15, 2004 8:43 am

Post by DayCuts »

Your right, timers in tcl are not recurring, they run once only, so when your proc is called from the timer, it is automatically stopped. No need for the use of killtimer or any proc to search for it as it wont exist.

However when i need to check and kill a timer, i simple use something like this...

Code: Select all

if {[timerexists proc]!=""} { killtimer [timerexists proc] }
This has worked fine in all cases i have needed to kill a timer. 'proc' is the name of the proc the timer is set to call. [timerexists proc] returns the timer# of the timer. Obviously if you are using a utimer, your commands would be utimerexists and killutimer instead.

But remember that line of code is in its simplest form, in my cases i never have multiple timers set to run the same proc so it works fine. But if you have multiple (u)timers active at the same time, set to call the same proc. You will no doubt get an error because [timerexists proc] would return the timer#'s of more than one timer. (A simple loop would work fine if you wished to kill all timers set for that proc)
s
sdez_

Post by sdez_ »

ok I tried both neither worked

no errors they just didn't kill the utimer
and the

# Commence with the kickban
putlog "$nick did not reply or pass was wrong"
putserv "PRIVMSG $nick :Wrong password or no reply"

still fired
which I don't want to happen
I will post part of the script this time

Please help a newbie out :)

as you will see I have the first reply, to my post, added to the script

# Process the version reply for mirc
proc reply:version_check { nick host hand dest keyword text } {
global ch_pass botnick

set reply [string tolower $text]
if { [string match "*mirc*" "$reply"] } {
putserv "PRIVMSG $nick :Channel Password $ch_pass"
putserv "PRIVMSG $nick : Type /msg $botnick password <channel password> (In 2 minute you will be ban, if you don't reply)"
utimer 120 [list pass_ck $nick $host $hand &text]
}
}

#process the Password reply
bind msg - password pass_ck
proc pass_ck { nick host hand text } {
global channel ch_pass
if { $text == "$ch_pass"} {
foreach t [utimers] { if {[lindex $t 1] == "ch_pass"} { killutimer [lindex $t end] } }
putserv "PRIVMSG $nick :Password accepted"
putlog "$nick Password accepted" } {
# Commence with the kickban
putlog "$nick did not reply or pass was wrong"
putserv "PRIVMSG $nick :Wrong password or no reply"
putquick "MODE $channel +b [maskhost $host]"
putquick "KICK $channel $nick :Scripts are not welcome here."
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Re: Need help with utimer then killutimer

Post by awyeah »

I am tring to start a timer which runs a proc

utimer 120 [proc]
You would have to mention "list" as well.

Code: Select all

utimer 120 [list proc_name arg1 arg2 arg3]
If you don't have any variables to pass then simply use
  • and in the proc that is runs I want to do a

    if {"match this" } { do that and "killutimer"} {no match "do this"}
    For this, you can do something like:

    Code: Select all

    #This command will loop the utimer, make sure it is in the 
    #procedure and not outside it.
    if {(![string match *spam* [utimers]])} { utimer $spamidle spam:cycle }
    
    #To kill all matching utimers
    foreach check_utimer [utimers] {
     if {[string match "awyeah*" [lindex $check_utimer 1]]} {
       killutimer [lindex [split [lindex $check_utimer 2] "\}"] 0]
       }
    }
    
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
Dedan
Master
Posts: 260
Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis

Post by Dedan »

you have:
utimer 120 [list pass_ck $nick $host $hand &text]

foreach t [utimers] { if {[lindex $t 1] == "ch_pass"} { killutimer [lindex $t end] } }


try:
foreach t [utimers] { if {[lindex $t 1] == "pass_ck"} { killutimer [lindex $t end] } }

btw
is &text supposet to be $text?
I once was an intelligent young man, now i am old and i can not remember who i was.
Locked