Man allegedly caught selling pills to undercover cop