It's asking a LOT to diagnose your snake online, I hope you realize? Not really possible, can only make suggestions & you haven't given much info. Is this your only snake?

You also mention (reading between the lines here) that your friends have snakes too & you "haven't gotten any new snakes lately" so you have others? This could also be
something contagious that you transferred to him by not washing hands etc between handling him & others. His problem (internal pain?) could also be internal parasites-
you'd need to take a fresh stool sample to the vet to diagnose & get the right medicine. Seeing a reptile vet is still your best bet for him to survive & not be "in pain". Only
so much we can do here. You owe this snake proper care, & promptly as you'd want if it were you.