Improved version of both /amsg and /ame. Easy enough to use: Paste into remotes [alt+r] & executed by "/amsg " [or] "/ame "
alias amsg {
if (!$1) echo $color(info) * /amsg: Invalid syntax [/amsg <msg>]
elseif ($1) {
var %t = 1
while (%t <= $scon(0)) {
scid %t
var %c = $chan(0)
while (%c) {
msg $chan(%c) $1-
dec %c
}
inc %t
}
}
}
alias ame {
if (!$1) echo $color(info) * /ame: Invalid syntax [/ame <action>]
elseif ($1) {
var %t = 1
while (%t <= $scon(0)) {
scid %t
var %c = $chan(0)
while (%c) {
describe $chan(%c) $1-
dec %c
}
inc %t
}
}
}
Btw the same recursion happens for example with filter and the -k flag.
Try:
alias test filter -fk $mircini test
Basically, the same case where the alias is called but not directly from the alias, rather it\'s filter that calls test here, which in term calls the filter again, which in term calls test again, etc, infinite recursion, making your mIRC crash.
Same example as the /scon or /scid case.
Here\'s another fun one:
alias test1 test2
alias test2 test1
(the above example used to work fine in older versions for 500 calls or something then it stopped, but in the current version it just crashes instantly)
Oh btw, I forgot to mention, there is a HUGE mistake in your code.
$scon(0) returns the total amount of open server windows. Let\'s say this is 3.
You are looping from %t = 1 till 3 then, with %t being 1, 2, 3.
You then do: scid %t, which will set the active server window to the one that has as $cid the value %t.
BUT!!!
The $cid of a server window, is a gloval variable in mIRC internal\'s, that is not reset until you close mIRC. When you open a new server window, mIRC checks this value, increments it, and assigns the new value as the $cid to this server window.
Let me illustrate where I am going with this:
->You have 2 server windows open, with $cid\'s 1 and 2.
->You close server window 2, and then open a new one.
-> The new one now has $cid 3, but you still only have 2 server windows open, with $cid\'s 1 and 3.
Do you notice how when you are looping, you will try to do \"scid 2\" which will try to set the active connection to a server window that doesn\'t exist!
The trick here is not to use /scid, but to use /scon. /scid takes a $cid, whilst /scon takes a number that represents the N\'th window, which is what you are looking for.
In our example, when you do scon %c, it will set it to the second server window, which is the one with $cid 3.
You can simply do:
alias amsgx var %msg = $1- | scon -at1 amsg % $+ msg
alias amex var %msg = $1- | scon -at1 ame % $+ msg
It\'s really a bad idea to name your aliases the same as the built-in aliases, because now when someone does an /ame, it will do it on all server windows.
The reason that I use a variable and escape it in the code like that, is because there is danger of dubble evaluation when using the scon/scid commands. This is illustrated when doing: //scon -a echo -a $!me
Additionally, you are not checking $status on each server, which will result into an error when you try to describe or message a channel on an offline server window.
Also, as I stated in another comment section, $chan() doesn\'t make a distinction between channels that you are in, and those that were left open after a disconnect (channels you are no longer in, in other words), so you should loop with $comchan($me,%x)
But anyway, like said, looping isn\'t needed at all.
Btw if you decided to recreate the aliases to use scon -at1 ame/amsg, then you MUST escape the ame/amsg commands by prefixing them with a ! or it would close your mIRC because of infinite recursion.
Example:
alias amsg var %msg = $1- | scon -at1 !amsg % $+ msg
alias ame var %msg = $1- | scon -at1 !ame % $+ msg
Ah, okay xDaeMon. I never tested the script without the /halt, assuming that the regular /amsg [or /ame] command would get in the way. Also, I didn\'t really give the first parameter a thought since I made this mainly for my own use [figured others may enjoy], and I don\'t normally check my own commands [since I know how to use them, etc.] Thanks for the pointers though, :P