1. Have a designated person you can call to pick you up in the case that this happens. This way, both you and your friend will get home safely.
2. If you're in a safe/comfortable environment, convince your friend to stay over until the next morning when you'll both be sober.
3. If you're familiar with public transportation in the area, take a bus or taxi home with your friend.