mIRC Homepage
Posted By: Uragano Comand /wait - 17/12/11 11:40 AM
Hello,

it would be very helpfull to indroduce a comand /wait seconds
so when it is necessary in a script you can have a "pause".

I know there is a similar comand... /timer but I think /wait is a great idea.

P.S: Sorry for my english.
Posted By: Modoc Re: Comand /wait - 17/12/11 03:51 PM
How do I Pause a script. Will you can't. But there is a work around.
You need to use a alias. And pass the info to that alias on a timer.

Example 1: I wish to see if the person is still in the channel 5 sec
after they say something

The timer passes on the users nick as $1 and the channels name as $2


;Remote
on *:text:*:#: {
.timer 1 5 usercheck $nick #
}

;Alias
userscheck {
if ($1 ison $2) {
commands
}
}



Example 2: You wish to pass on the name of the person the channel And what the person sead.

The timer passes on the users nick as $1 and the channels name as $2 And the Text is $3-

;Remote
on *:text:*:#: {
.timer 1 5 usersecho $nick # $1-
}

;Alias
usersecho {
if ($1 ison $2) {
echo 12 $2 $1 sead $3-
}
}

I hope this helps you out with adding a pause in your scripts.

You should note the rest of the script will fire. You are not halting anything just delaying it.


Modoc Efnet @#mIRC
Posted By: Uragano Re: Comand /wait - 17/12/11 06:43 PM
Thanks for the examples.
Well, I use alias but in many cases I need "really" to pause the script.
There isn't always the possibility to use aliases to work around the problem...

Sometimes, imho, I think it is much pretty to have a command like /wait 5 so that the script waits 5 seconds and then go on....

Anyway thanks you again for answering. wink
Posted By: FroggieDaFrog Re: Comand /wait - 17/12/11 07:16 PM
To start off, mIRC is a single process single threaded program. If a command such as /wait were introduced then one of two things would occur:

A: mIRC would save the state prior to waiting, remember where in the script mIRC is, then start an internal timer to pick up where it left off when the timer expires. Essentially the timer/alias approach but done internally.

or

B: mIRC would freeze for the duration of the /wait, sort of like what happens in a very long loop.

Neither is a good option, 'A' can be scripted, and 'B' having the fault of mIRC freezing
Posted By: argv0 Re: Comand /wait - 17/12/11 10:08 PM
You don't "really" need to pause the script. You most likely need a timer, but you just don't understand how a /wait would translate into a timer command. There *is* always a possibility to use aliases to workaround this waiting problem.

For instance:

Code:
alias foo {
  command1
  wait 5
  command2
}


Would just be:

Code:
alias foo {
  command1
  .timer 1 5 command2
}


If you had more than one command, it would be:

Code:
alias foo {
  command1
  .timer 1 5 foo_continue
}

alias foo_continue {
  command2
  command3
  command4
  ...
}


As shown, there is always a way to replace a hypothetical /wait with /timers. You most likely want to do this in all cases anyway, since it allows mIRC to process events while "waiting". Something a /wait could never do.
Posted By: Wolfpatch Re: Comand /wait - 20/03/14 05:56 PM
You can make a timer of your own and call it as you like. Be careful though; test your scripts thoroughly to make sure this doesn't conflict with other scripts that might be running. It will stop the normal processing of some events like ON CONNECT. mIrc does not join your auto join channels until any ON CONNECT scripts are finished.

This Alias accepts time in milliseconds
e.g. ]Wait 1000] will wait for 1 second before returning to the script.

Code:
Remote:
Alias Wait {
  Var %compairTime = $uptime(mirc) + $1
  While ($uptime(mirc) < %compairTime) {
  }
  Return $null
}
© mIRC Discussion Forums