I forgot to mention the most important one of all in my last post, being that this snippet does not work in a multi-server environment. It only gives the nicks from the server window where you issued, and even this result is incorrect.
Let's say you have 2 server windows open, 2 different networks.
Network 1: dalnet
Channels:
#a = 2
#b = 2
#c = 2
Network 2: undernet
Channels:
#d = 5
Issuing $users on server 1, will result in %users being: 7 instead of 11, because $dde returns all channels, including #d, but you're not on #d in network 1, so the code does an inc with $nick(#d,0) being $null, which increments with 1 (default if no amount is specified)
Issuing $users on server 2, will result in %users being 8 instead of 11, for the same reason.
One other thing, channel names can contain a * in their name, so using a global $remove on a channel name would also remove those and corrupt the results.
I'd perhaps go for something like:
alias users {
var %users
scon -at var $(%a = 1 |,) while $!chan(%a) $({ inc %users $nick($v1,0) |,) inc $(%a },)
return %users
}
Greets