Not everyone is worthy of gambling, not because of financial limitations, but because of mindset limitations. A person can lose the wealth he has accumulated over a long time in 1 day due to gambling & the reason behind it is definitely about self-control. Referring to your story, you should stop & not go back to gambling again. If your friends are the reason you go back to gambling, then you should cut off them, start doing activities alone & reflect on yourself.
Not going back to gambling is easier said than done, we have seen countless cases where people relapse while in the process of trying to quit. The best thing an addicted gambler can do is to find a way to limit himself by cutting down the amount and time spent on gambling. And like you added, cutting off his friends would also be a good idea because those are triggers to what makes him gamble irresponsibly.
Even if people get out of gambling for a while, they will definitely go back to gambling later. If the limits are not maintained from the beginning, then it will easily get out of control later, temptation is a very bad thing, there are many friends who tempt you to gamble more, and there are many friends who give honest advice to get out of it. So it depends on their type, but the most important thing is to be aware of yourself, if you can maintain the limits well on your own, then the chances of addiction and the activity getting out of control are greatly reduced.