You can prevent yourself from spending too much by bringing a certain amount of money, if you lose then nothing is left and you cant spend further since your money is limited.
Greed is the reason why a gambler is tempted to keep trying even he is losing his money, he want to chase the losses hoping to get it back.
Self discipline is important and dont expect to win, accept if you lose and move on.
This is one of the better ways to bring a certain amount of money, but again our greed will draw in and maybe lend (or manage money at such a time) and spend again. I'm afraid there is no right solution.