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 

utimer loop help

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


Joined: 09 Oct 2014
Posts: 68

PostPosted: Wed Oct 22, 2014 9:43 am    Post subject: utimer loop help Reply with quote

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


Joined: 09 Oct 2014
Posts: 68

PostPosted: Wed Oct 22, 2014 10:43 am    Post subject: Reply with quote

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