The last four if rungs use $$3
OR better to use elseif statements

also not your issue but
$2 == $null same as !$2 etc etc
you could shorten $true and $false
conditions in a simular manner
$time(HH.nn.ss) could be just $time

As far as exists identifer question:
you could use $readini to access the
mirc.ini file and see what is loaded
OR maybe better use $script(filename.ext)