| View previous topic :: View next topic |
| Author |
Message |
CP1832 Halfop
Joined: 09 Oct 2014 Posts: 68
|
Posted: Wed Oct 22, 2014 9:43 am Post subject: utimer loop help |
|
|
Hi guys:
I am having issues with a simple code that would repeat a given test a few times once every ten seconds. What I would want to achieve is: | Code: | <user>!annoy bored
+10 seconds <bot>bored
+10 seconds <bot>bored
+10 seconds <bot>bored
+10 seconds <bot>bored
+10 seconds <bot>bored | I wrote this code: | Code: | bind pub - !annoy annoy
proc annoy {nick host handle chan text} {
set i 0
while { $i < 6 } {
utimer 10 [list talk $chan $text]
incr i
}
}
proc talk {chan text} {
putquick "PRIVMSG $chan :$text"
} | But utimer is only waiting to print out the text the first time (I don't know why) and then the text goes as soon as possible. What am I doing wrong? |
|
| Back to top |
|
 |
CP1832 Halfop
Joined: 09 Oct 2014 Posts: 68
|
Posted: Wed Oct 22, 2014 10:43 am Post subject: |
|
|
I was given a solution. Here's the code if it helps. | Code: | bind pub - !annoy annoy
proc annoy {nick uhost handle chan text} {
global i
if {![info exists i]} {
set i 0
}
if {$i < 6} {
putserv "privmsg $chan :$text"
utimer 10 [list annoy $nick $uhost $handle $chan $text]
incr i
} else {
set i 0
}
return 1
} |
|
|
| Back to top |
|
 |
|