Lose all the variables for a start.
Code:
if ($chr(126) isin $3) && ($islower($3)) && ($3 isalpha) && ($len($3) > 8) {
  ctcp $6 PING
  echo -s 12 $6 has this userid:4 $3
}
You haven't shown any code to explain why the variables need to be set so unless you want to store that information for another purpose it is just slowing down the script for no reason.

Also: $chr(126) = "~"