This is specifically about leg cramps because I think I might actually have something useful for you in this specific case. Much of this applies to other cramps, but legs were (and are) the worst for me. Despite massively painful incidents for me and my players, no one ever told me any of this stuff. I am passing it along in hopes that it helps.
First and immediately, if you have a leg cramp, you need to use your own muscles in the foot, ankle and entire leg to straighten your leg and pull your toes up toward your knee -- and do this with all of your strength without giving up or giving in!!!! You have to jump on this with all of your quickness, strength, determination, and perseverance -- even if it doesn't seem to be working. Persevere and try even harder until you beat it!!!
I am calling this the "toe pull battle" -- and it is a battle! (But you can win!)
The advice above is the #1 thing I wanted to pass along to you -- all in the first paragraph. Believe me, I have tried almost every contortion, rubbing, stretching, salve, putting weight on it, mustard swallowing, pickle juice drinking, salt pill, etc. "remedy" you have heard of!!! The instantaneous "strength vs. strength" toe pull is the best answer I have ever come up with.
Unlike the "straighten it out and stick with it" or "try to put massive amounts of weight on it" methods, this requires you to consciously pull that toe up and stick with it. Do not use your hands to pull back (if you could reach them anyway). Use your own leg muscles and overcome the cramping. This may involve a few minutes of pain, but it is nothing compared to the cramps. If you get quick enough (see diagram above), you can catch the cramp before it grabs you badly.
Look at the diagram above, though, if you don't think you need to jump up this the instant you feel the cramp coming!!! Those are milliseconds!
Don't give up, either. This does work!
OK, now that you are done with the urgent stuff, here are some pointers to keep this from happening as frequently in the future:
Stay very hydrated. Water is so good for you! It is free and will help you athletically and mentally. If you fall asleep in class or meetings, just try drinking more water. If you want to be sharper for a big test or big meeting, drink some water. (If you drink too much alcohol at night, drink more water before bedtime to minimize a hangover.) If you are trying to lose weight, drink some water every time you think you are hungry. Don't drink "sugar water" like standard Gatorade -- you don't need the empty calories or expense. You can find good no-calorie drinks with electrolytes -- but the key is just plain old water.
I just recently discovered this myself, and it is available in almost all stores that sell medicine of any sort. Again, I am not getting paid to advertise this. It is simply a very effective product. I used it to release the muscle pain from a very severe cramp. I am not going to travel or stay anywhere without access to it in the future. https://theraworxrelief.com/how-to-use/
Their website also recommends heat, warm baths, and soaking in epsom salts if you have severe residual muscle pain.
These are great: https://www.amazon.com/gp/product/B07VZTQM23/ref=ppx_yo_dt_b_asin_title_o06_s02?ie=UTF8&psc=1
(And, no, I'm not making any money off of these or anything on this entire website.)
Take a few before going to bed if you have had a super strenuous day. Take a few before a big practice or big game/race.
Sorry if this advice seems too simple after all of your struggles your whole life (mine too), but the "toe pull battle", water and magnesium+ strategies are probably all you are going to need 99% of the time.
I had been told all of the following for 50 years of my life:
1. Take salt pills -- which don't work and aren't good for you.
2. People told me to take Quinine and Quinine water -- which seemed to work but also seem to have negative effects on your health. Check with your doctor if you plan to try this -- but why bother with all of the other remedies available.
2. Eat bananas for Potassium -- which works somewhat and they are good for you.
3. Drink pickle juice -- which Duke Basketball recommends and works somewhat.
4. Squirt massive amounts of yellow mustard into my mouth -- which works fairly well but none of my basketball players ever trusted me enough to let me try on them.
5. Use Highlands homeopathic pills and ointment https://www.amazon.com/Tablets-Hylands-Nighttime-Formula-Natural/dp/B002YXUPGK or Arnicare https://www.amazon.com/gp/product/B07HRV26YJ/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1 -- which work fairly well.
6. Rub CBD, Blue Emu, Aspercreme, Amish Oil, and other creams -- which all work fairly well.
Try combinations of the above to see if they can help as well.
So, I hope you will find this helpful. I have had so many painful incidents with cramps that were, now that I know the above, not necessary. You really don't need to miss large parts of your key game if you will drink water and take the magnesium+ mentioned above. Worst case, your instant reaction and strength with the "toe pull battle" will keep the cramp from debilitating you and get you back in the game.