mIRC Homepage
Posted By: Brolaire Count people currently using the channel - 30/03/15 02:43 AM
Hello,
I wanted to implement a command that makes the bot say how many people are only at the moment.
The way I was thinking of doing it was to make the bot check the /names list, set the number of names to %variable and then say the %variable.

Is there a better way of doing this? How do I make it count the names?
$nick(#,0)
Posted By: Kooky Re: Count people currently using the channel - 02/04/15 08:57 PM
Is there an actual code snippet to go along with doing this? I also haven't figured it out yet.
Code:
on *:text:!count:#:msg # $nick(#,0)
Posted By: Kooky Re: Count people currently using the channel - 02/04/15 10:36 PM
Code:
on *:TEXT:*!Count*:#MyRoom: {
msg $nick There are # $nick(#,0) users in this channel. } 
}
}


I think that should work with !count in a #channel
But it doesn't.

I'd like to get it so I could /msg BotName !count
and the bot would tell me the count of 8 users in #MyRoom1 2 users in #MyRoom2
Showing how many people are in each room that the bot is in.

Any help would be appreciated. Hopefully it helps the one who created the thread too.
Posted By: Nillen Re: Count people currently using the channel - 03/04/15 07:39 AM
Code:
on *:text:!count*:?: { 
if ($nick != YOURNICK) return
var %channel $iif($2,$2,#DEFAULTCHANNEL)
var %users $nick(%channel,0)
msg $nick There are %users users in %channel $+ .
}
Replace #DEFAULTCHANNEL with the channel you'll be using the most, and replace YOURNICK with your nick. Then message the bot !count or !count #channel.

!count returns the default channel's users, and !count #channel returns that #channel's users.
Originally Posted By: Kooky

I think that should work with !count in a #channel
But it doesn't.

I'd like to get it so I could /msg BotName !count
and the bot would tell me the count of 8 users in #MyRoom1 2 users in #MyRoom2
Showing how many people are in each room that the bot is in.

Code:
on *:text:*:?: {
if ($strip($1) == !count) {
var %x = 1 
while (%x <= $comchan($me,0)) {
.timer 1 $calc(%x + 1) msg $nick There Are $nick($comchan($me,%x),0) In $comchan($me,%x) .
inc %x
}
}
}

Try this code smile Put it in an empty remote file. I Have tested it and works just like you wanted it smile


((( I think that i replied to the wrong person LOL )))
Posted By: Kooky Re: Count people currently using the channel - 03/04/15 09:57 PM
Originally Posted By: Nillen
Code:
on *:text:!count*:?: { 
if ($nick != YOURNICK) return
var %channel $iif($2,$2,#DEFAULTCHANNEL)
var %users $nick(%channel,0)
msg $nick There are %users users in %channel $+ .
}
Replace #DEFAULTCHANNEL with the channel you'll be using the most, and replace YOURNICK with your nick. Then message the bot !count or !count #channel.

!count returns the default channel's users, and !count #channel returns that #channel's users.



I did that and it worked great. I like this one more than the snip posted below it, no offense.. It's easier for me to follow and modify. But I did find an issue. I tried to make a room list that the bot is in, and -1 for the count so it doesn't count the bot as a user. So far it's not working though... Where'd I go wrong?

Code:
on *:text:!count*:?: { 
if ($nick != YOURNICK) return
var %channel $iif($2,$2,#DEFAULTCHANNEL,#OTHERCHANNEL,#ANOTHER)
var %users $nick(%channel,0, -1)
msg $nick There are %users users in %channel $+ .
}


Any advice?
var %users $nick(%channel,0, -1)

This is wrong.
Posted By: Nillen Re: Count people currently using the channel - 04/04/15 06:14 AM
Code:
var %channel $iif($2,$2,#DEFAULTCHANNEL,#OTHERCHANNEL,#ANOTHER)
var %users $nick(%channel,0, -1)
Both of these lines are wrong. I don't know how #OTHERCHANNEL would ever work in an $iif.

Code:
var %channel $iif($2,$2,#DEFAULTCHANNEL)
var %users $calc($nick(%channel,0) - 1)


Regarding the script OrFeAsGr posted, it will return the amount of users on all channels your bot is currently on, looping through $comchan - which returns how many channels and channelnames the bot is currently on.
Posted By: Kooky Re: Count people currently using the channel - 05/04/15 01:20 AM
Thanks a ton to everyone, and especially you. I'm finally getting on track with it doing what I need it to, and it's a huge HUGE help. This works until I can figure out how to get it to do the other things regarding the same command. Yay for tweaking! I really appreciate the start. And moreso, the work put into doing this for me and helping me along. <3

Loki thanks for the code to get me started!
OrFeAsGr thanks!! You did soooo much for me with that snippet!

And thank you too Nillen as you've helped and responded to most of my posts, and I've been learning a great deal from you especially.

Everyone keep up the great work!
this wont look very different from what you've already seen but I felt it Needed some very minor changes

on *:text:!count*:#: {
if ((%floodcount) || ($($+(%,floodcount.,$nick),2))) { return }
set -u10 %floodcount On
set -u30 %floodcount. $+ $nick On
if ($nick isop #DEFULTCHANNEL) return
var %channel $iif($2,$2,#DEFULTCHANNEL)
var %users $calc($nick(%channel,0) - 1)
msg $chan $nick There are %users users in %channel $+ .
}

If you have people modding for you, only you and those people that you /mod can use this command.

The Flood thingy (I'm so technical) will prevent anyone spamming the command.

It shouldn't count, you the mods, or your bot.

Hope you enjoy smile
© mIRC Discussion Forums