mIRC Home    About    Download    Register    News    Help

Print Thread
#105396 15/12/04 11:54 AM
Joined: Nov 2004
Posts: 84
GogetaX Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2004
Posts: 84
how to make a timer for some code in BoT?
like on *:TEXT:!do:#:{ if the time after 20 secunds after last use, then ..................................... else ........................
}


how to do that?
to make a timer and only after 20 secunds u can use the bot after each use


by the time you finish reading this, you realize you have wasted 5 secundes of your life!
#105397 15/12/04 12:17 PM
Joined: Mar 2004
Posts: 540
A
Fjord artisan
Offline
Fjord artisan
A
Joined: Mar 2004
Posts: 540
on *:text:!do:#scripts: {
if (!%do.this) {
do this
set -u20 %do.this 1
}
}

#105398 15/12/04 12:25 PM
Joined: Nov 2004
Posts: 84
GogetaX Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2004
Posts: 84
huh???
i dont understand a word smile


by the time you finish reading this, you realize you have wasted 5 secundes of your life!
#105399 15/12/04 12:50 PM
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
  • set -u20 %do.this 1
    inc -u20 %do.this (Does the same thing in this case.)

Both set the variable "%do.this" to 1, for 20 seconds.
  • if !%do.this { ... }

Triggers if "%do.this" doesn't exist (or its value is "$false", "$null" or "0")
Code:
on *:text:!do:#:{
  if !%do.this {
    ; if %do.this is 0 or not set, this will trigger
    do stuff
    ; and set the var
    set -u20 %do.this 1
  }
  ; else nothing happens, the var is set, doesn't need anything more
}


Another way
Code:
on *:text:!do{
  if !%do.this {
    do whatever
    set -z %do.this [color:blue]20[/color]
  }
  else echo # !do must wait another $!(%do.this,1) secs
}

This time, the -z means %do.this is set to 20 and reduced by 1 each second, until it is 0, when it is unset. You can know how long until it is unset this way.

#105400 15/12/04 12:51 PM
Joined: Mar 2004
Posts: 540
A
Fjord artisan
Offline
Fjord artisan
A
Joined: Mar 2004
Posts: 540
Quote:
on *:text:!do:#scripts: {
if (!%do.this) {
do this
set -u20 %do.this 1
}
}


the if checks if the variable exists if it doesnt it continues with the command then the set -u20 will unset the variable in 20 seconds so say you wanted to do !hi Joe and have the bot say Hi Joe
on *:text:!* :#scripts: {
if (!%do.this) {
msg $chan Hi $2
set -u20 %do.this 1
}
}

#105401 15/12/04 01:47 PM
Joined: Nov 2004
Posts: 84
GogetaX Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2004
Posts: 84
k.. thx. i think i understand what axacly it doing smile


by the time you finish reading this, you realize you have wasted 5 secundes of your life!

Link Copied to Clipboard