When someone parts this will say a message and tell the number of people that have parted. Have fun. :)
on *:PART:#:/inc %Counter | /msg $chan Everyone, $nick has partted. He/she is number %counter to leave the channel.
Bielie, I don't know where you get the idea for the quit event with a # prefix to it. There's no $chan in the quit event. You either need to put the #chan by itself or loop through the $comchan:
on !*:part:#:{
inc $+(%,p,#,$nick)
inc $+(%,p,$nick)
msg # $($+(%,p,$nick),2) has parted # $+ . $&
$nick has parted $iif($($+(%,p,#,$nick),2) = 1,$v1 time.,$v1 times.)
}
on !*:quit:{
var %q $comchan($nick,0)
while (%q) {
if $me ison $comchan($nick,%q) {
inc $+(%,q,$v2,$nick)
inc $+(%,q,$nick)
msg $v2 $($+(%,q,$v2,$nick),2) has parted $v2 $+ . $&
$nick has quit $iif($($+(%,q,$v2,$nick),2) = 1,$v1 time.,$v1 times.)
}
dec %q
}
}
on *:part:#:{
inc %part [ $+ [ $chan ] ]
inc %part1 [ $+ [ $nick ] ]
msg # %part [ $+ [ $chan ] ] people have parted $chan $+ . $1 Parted %part1 [ $+ [ $nick ] ] times.
halt
}
on *:quit:#:{
inc %quit [ $+ [ $chan ] ]
inc %quit1 [ $+ [ $nick ] ]
msg # %quit [ $+ [ $chan ] ] people have quited $chan $+ . $1 Quited %quit1 [ $+ [ $nick ] ] times.
halt
}
I found this one on one of my old bots.
You overlooked a couple of factors:
You don't want to count the client that runs the code by adding an exclamation mark in front of that part event.
In fact, I think it's best to use hash tables for the counting task:
on *:start:loadcounter
on *:connect:loadcounter
on *:exit:hsave -o counter counter.hsh
on *:disconnect:hsave -o counter counter.hsh
alias -l loadcounter {
if $isfile(counter.hsh) && !$hget(counter) {
hmake counter 100
hload counter counter.hsh
}
}
on !*:part:#:{
hinc -m counter $nick
msg # Everyone, $nick has partted the $ord($hget(counter,$nick)) time!
}