You need to use $comchan() for this, then filter out the quit messages you dont want to se. This code is untested, but should work, but you need to add the filter you want.
on ^*:quit: {
haltdef
var %x = 1
while ($comchan($nick,%x)) {
echo -mt $comchan($nick,%x) $address quit $1-
inc %x
}
}
For the join part you only need to use:
on ^*:join:#: {
haltdef
;add filter
;make the echo on who joined.
}