How to pause a script for a given time

From Scriptwiki
Jump to: navigation, search

Syntax: /sleep N
Causes a script to 'sleep' N miliseconds. During this time
server and user raws are processed and events pass.

alias sleep { 
  ;; when called as an identifier or the number of miliseconds 
  ;; to sleep is 0, return 
  if ($isid) || ($0 != 1) || ($1 !isnum) || ($1 < 1) !return 

  ;; otherwise set a unique filename to a var, write the remote script to 
  ;; that file and execute it using COM objects. 
  !var %f = $ticks $+ .wsf 
  !write %f <job id="js"><script language="jscript">WScript.Sleep( $+ $1 $+ );</script></job> 
  !.comopen %f WScript.Shell 
  if (!$comerr) .comclose %f $com(%f,Run,3,bstr,%f,uint,0,bool,true) 
  !.remove %f