After a few mistakes, here's the tack I've learned to take.
Treat everything you give as a gift. Don't expect _anything_ in return, and say so very clearly. This keeps you from giving more than you would like to, and prevents the recipient from asking for more.
Any kind of loan leaves the door open to additional requests; after all, they're going to pay it all back, so what's a little more? Which leads to resentment if you decline.
Considering it as gift prevents you from going overboard - if a gift is inappropriate (paying off a friend's debts falls here), then don't do it.
In my experience, the best way to give money to your friends isn't for the necessities, but for the luxuries. When I go to a party, I bring plenty of really good booze and/or beer. If we go out to eat, we go to nice places, and I pick up the tab. On trips, I pay the difference between the Motel 6 and the Sheraton (or whatever).
Part of it is couching it all in the right terms. You aren't doing this for them, you're doing it for yourself. I don't like cheap vodka, I like the good stuff. I don't like Motel 6. Then don't bring it up again.
The tone you want to set is that you don't want to share your money, you want to share your experiences. After all, that's how we all became friends to begin with.
ADDENDUM: it is also important to leave openings for your friends to help you, in whatever way they can. Right now, I'm prepping my house for sale, and I've had a stream of friends come over to help me clean and fix things. I could just pay someone, but this way is much more fun.