Here is a shorter script, but note that this maximum value has always been known, the maximum value used to be 10001, it's 10007 since mIRC version 7.53 because the number was made to be a prime number.

Code
alias test_hash_size {
  var %s 1
  echo -ag [Test Hash Size] Starting test...
  hfree -w testhashtable*
  while (testhashtable $+ $ticksqpc) {
    hmake $v1 %s
    hfree $v1
    inc %s
  }
  :error
  if ($error) && (hmake isin $v1) {
    reseterror
    dec %s
    echo -ag [Test Hash Size] Test complete. Maximum successful size (number of buckets): %s
    hfree -w testhashtable*
    return
  }
}


#mircscripting @ irc.swiftirc.net == the best mIRC help channel