Is there a pill that can prevent hangovers?

No. You can start by not drinking more than 5 alcoholic drinks (of normal size) a night. No more than 3 in a 2 hour period. You also want to make sure you have had at least 5 cups of water & a full meal before you drink alcohol. Another thing that may help is to alternate your alcohol with water (beer, water, beer, water; for example). Stick to light alcohols, and to the same type (don't switch).
Nice try . There are meds that would likely make you feel better after a night of heavy drinking, but it would only lead to more problems and addiction risk. The best cure for hangovers is to avoid them in the first place.