Not all IRCds support the +h mode.

So maybe something like:

Code:
/mode $comchan($nick,%i) $+(+v,$iif(% isin $prefix,h $me)) $me


Without testing your code, I don't know how well it works but looking at this line:

Code:
if (r isincs $chan($chan).mode) {


$chan wouldn't have a value in the On Quit event.