I imagine you might be needing to know which player to "attackplayer"
Code:
on *:text:!attack*:#:{
  if ($2 == $null) { randattack }
  elseif ($read(test.txt, w, $+(*,$2,*))) { attackplayer $2 }
  else { msg $chan The character $2 is not in our database }
}