Code:
on ^*:TEXT:*:#: {
  haltdef
  if $+(*, $me, *) iswm $1- {
    echo $chan $chr(3) 4 $timestamp $+($chr(40), $nick, $chr(41)) $1-
  }
  else {
    echo $chan $chr(3) 0 $timestamp $+($chr(40), $nick, $chr(41)) $1-
  }
}


Try it.

For other option, there is some option by default in mIRC with new verions. Can't remember name. Maybe someone should help. You can use it for every event.