mIRC Homepage
Posted By: testuser123 How do I add a cooldown to this code? - 06/06/16 05:19 AM
on *:TEXT:!top10:#:{ run_top10 # }
alias run_top10 {
window -h @. | var %i 1
while $ini(points.ini,%i) {
var %n $v1
if ($+(*,$1,*) iswm %n) {
aline @. $gettok($remove(%n,[,]),2,46) $readini(points.ini,%n,points)
}
inc %i
}
filter -cetuww 2 32 @. @.
var %i 1 | while %i <= 10 {
var %list $addtok(%list,$line(@.,%i),44)
inc %i
}
msg $1 Top 10 point are: $replace(%list,$chr(44),$+($chr(44),$chr(32)))
window -c @.
}
Posted By: argv0 Re: How do I add a cooldown to this code? - 06/06/16 06:37 AM
One of the simplest ways is to use groups (/help groups) with /enable and /disable.

Example:

Code:
#mygroup on

on *:TEXT:*:#: {
  .disable #mygroup
  .timer 1 5 .enable #mygroup

  ; do your event stuff here
}

#mygroup end


You can do the same with a %variable that gets unset after a certain amount of time (see /set -uN) and an if guard:

Code:
on *:TEXT:*:#: {
  if (%mygroup_disabled) return
  set -u5 %mygroup_disabled $true

  ; do your event stuff here
}
© mIRC Discussion Forums