There is a list of entities in memory, models have "bones" for animation purposes, knowing the address of entity in memory you can find out if it's an enemy player (compare team ids), where the head bone origin is, and you also can read the view angles of your own player to see where you're looking. The tricky part would be doing a ray cast to see that you can actually hit the enemy and not shoot a wall - internal cheats can just call builtin game functions, externals can't.