Due to the non-relational nature of mIRC colors (there is no pattern) I think it would be very difficult (or impossible) to make an actual mathematical conversion script. I tried making a converter based on the decimal value of each mIRC color compared to the decimal value of the hex code. The results made no sense. Here is the code I used:

Code:
<mirc> <hex> <order> <dec>
; 00 FFFFFF F 16777215
; 01 000000 0 00000000
; 02 000066 1 00000102
; 03 009900 3 00039168
; 04 FF0000 B 16711680
; 05 660000 7 06684672
; 06 990099 9 10027161
; 07 FF6600 D 16737792
; 08 FFFF00 E 16776960
; 09 00FF00 5 00065280
; 10 009999 4 00039321
; 11 00FFFF 6 00065535
; 12 0000FF 2 00000255
; 13 FF00FF C 16711935
; 14 666666 8 06710886
; 15 CCCCCC A 13421772

alias hextomirc {
  var %x = $base($remove($1,$chr(35)),16,10)
  var %h = 000000,000066,0000FF,009900,009999,00FF00,00FFFF,660000,666666,990099,CCCCCC,FF0000,FF00FF,FF6600,FFFF00,FFFFFF
  var %m = 01,02,12,03,10,09,11,05,14,06,15,04,13,07,08,00

  var %i = 0, %ii = 15, %a, %b, %c
  while (%i < %ii) {
    inc %i
    %a = $base($gettok(%h,%i,44),16,10)
    %b = $base($gettok(%h,$calc(%i + 1),44),16,10)
    %c = $+(%a,-,%b)

    if (%x isnum %c) { 
      if ($calc(%x - %a) < $calc(%b - %x)) var %z = %i
      else var %z = $calc(%i + 1)
      break
    }
    else continue
  }
  echo -a Input H: $1
  echo -a Input D: %x
  echo -a Output M: $gettok(%m,%z,44) 
  echo -a Output H: $gettok(%h,%z,44)
  echo -a Output D: $base($gettok(%h,%z,44),16,10)

  if (%z != $null) return $gettok(%m,%z,44)
  else echo -a Invalid hex value
}





The most reliable method for converting from hex to mIRC colors would be to make a table of ranges to determine which hex colors should be changed into which mIRC colors.

-genius_at_work