mIRC Home    About    Download    Register    News    Help

Print Thread
#105426 16/12/04 12:24 AM
Joined: Dec 2004
Posts: 4
C
Self-satisified door
OP Offline
Self-satisified door
C
Joined: Dec 2004
Posts: 4
Hello,

Can someone give me a good example of how to queue up user voice requests?

For example say I have the following script:

on *:TEXT:voice me:?: {
if ( $nick !isvoice #channel ) { /mode #channel +v $nick }
}

What I would like to do is put the voice requests into a queue of some sort and have them execute in the order they are recieved, however, I always like to have at least a 5 second delay before between each person being voiced.

so if 10 people sent me the request to be voiced, it would voice the first person in the queue, wait 5 seconds, voice the next person, wait 5 seconds, voice the next person, etc... etc... and this would continue until all the requests for voice have been completed.

Anyone have a good suggestion with an example of how this can be done?

confused

Joined: Dec 2004
Posts: 23
E
Ameglian cow
Offline
Ameglian cow
E
Joined: Dec 2004
Posts: 23
make a command that has a variable set at all times... if the var is set to 1,2,3,4 (the amount of people who have asked to be voiced) then set a timervoice $+ $nick 1 $calc(%var *5) mode # +v $nick then a timer to dec the variable each time a person is voice.... timerdecvoice $+ $nick dec %var

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Code:
on *:TEXT:voice me:?: {
  if ( $nick !isvoice #channel ) && ( $timer(.vmt. [ $+ [ $nick ] ]) == $null ) {
    inc -z %vmt.delay 5
    .timer.vmt. [ $+ [ $nick ] ] 1 %vmt.delay mode #channel +v $nick 
  }
}

The event checks if $nick is not voiced already and has no timer already in progress, and then increments a delay counter by 5 and sets a timer to voice that $nick with a delay using the value in the delay counter (%vmt.delay).
The trick used here is the "-z" option (first time i found a good use for it), this decreases the value of delay counter by 1 every second, so its counting down also. would look like this
12:00:00 john asks for voice, delay = 0 + 5 , john to be voiced in 5 seconds
12:00:03 peter asks for voice, delay = 2 + 5, peter to be voiced in 7 seconds
12:00:05 john voiced
12:00:10 peter voiced

Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Slight refinement smile
Code:
on *:text:voice me:?: {
  if $me isop #channel && $nick !isvoice $v2 && !$timer(.vmt. $+ $nick) {
    .timer.vmt. $+ $nick 1 $iif(%vmt.delay,$v1,0) if ($me isop #channel) mode #channel +v $nick
    inc -z $vmt.delay 5
  }
}

Joined: Dec 2004
Posts: 4
C
Self-satisified door
OP Offline
Self-satisified door
C
Joined: Dec 2004
Posts: 4
Thank you everyone for your help with this. I appreciate the help. cool

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Nice catch on checking for OP stats, he didnt put it in so i couldnt be bothered (actually i didnt even think about it).

Oon the inital requester waiting 5 seconds, i thought oh who cares its only 5 seconds. i would have donethis for that tho likely (not confirmed to be) less task overhead than a $iif

inc -z %vmt.delay 0
.timer.vmt. $+ $nick 1 %vmt.delay if ($me isop #channel) mode #channel +v $nick
inc -z %vmt.delay 5

(ohhh typo in your line "inc -z $vmt.delay 5") smile


Link Copied to Clipboard