mIRC Homepage
Posted By: davethejackal Timers and $nick - 12/03/14 11:40 AM
I am hacking about some code for an event handler and rather than handling the event straight away, as it does now, I'd like to execute large parts of it after a delay.

So I am using something like:

timername 1 60 aliasnametobeexecuted

However, because the code was created to run normally, without delays, it makes extensive use of $nick and $chan and so on ... so will not work with the timer delay, since it blanks out $nick $chan etc.

Is there any way of setting the values of $nick and $chan so they are preserved across timer events?

So in other words I'd like to be able to do:

Code:
alias timerstart{
  timerX 1 60 hello
}

alias hello(
  msg $chan Hi there $nick!
  ; ... and lots of other code that uses $chan and $nick
}


and not

Code:
alias timerstart{
  timerX 1 60 hello $chan $nick
}

alias hello(
  msg $1 Hi there $2!
}


if at all possible
Posted By: Loki12583 Re: Timers and $nick - 12/03/14 12:33 PM
You may be able to structure your code to sleep instead of using a timer: /sleep 60000 will pause the script at that line for 60 seconds

Code:
alias sleep {
  if ($1 !isnum 1-) return
  var %a = $ticks $+ .vbs
  write %a wscript.sleep $1
  .comopen %a wscript.shell
  if (!$comerr) .comclose %a $com(%a,Run,3,bstr,%a,uint,0,bool,true) 
  .remove %a
}
Posted By: davethejackal Re: Timers and $nick - 12/03/14 03:11 PM
Thanks very much .. but will sleep allow other parts of the code to execute if other events occur?
Posted By: Loki12583 Re: Timers and $nick - 12/03/14 05:28 PM
Yes, other events still take place.
© mIRC Discussion Forums