I have had the same problem in the past - both with legs cramping at night and hands cramping intermittently during the day. The problem began when I had my right kidney removed for a large tumor - possibly cancerous. Don't worry, that is most likely not an issue with you. A few months after the surgery I began getting severe leg cramps at night and hand cramps after going out to eat. I checked various medical websites on the internet, but got the same answer: "Cause unknown. Consult your local physician." I talked with several doctors, but got no definitive answer. I then searched the blogs for people who had had the problem or were related to someone who had. Two problems kept surfacing - dehydration and too much sugar. I treated patients in the Navy as a Corpsman, and I always considered dehydration as what the doctor told you when he/she could not figure out the problem, and too much sugar as the opinion of some people who consider anything that tastes good to be bad for you.
Then one night after working outside in the back yard in July, I got the severe cramps again, and it occurred to me that there might be something to the dehydration issue after all. So I got up, drank a coke, and went back to bed. The cramps got worse. Bummer. I was working outside every day, so the next night I drank several glasses of water right before going to bed. I still got the cramps. Just having one kidney, I figured it probably took a while for the water to do its work, so the next night I drank several glasses of water 2 hours before going to bed. NO CRAMPS! ZERO! So for the next few weeks I alternated no water, water, and various types of sweetened drinks before going to bed. With 1 or 2 glasses of water 1-2 hours before going to bed I consistently had no cramps, but with drinking no water or drinking sweetened drinks I consistently got cramps. The worst drinks beginning with the worst were orange juice, apple juice and sodas (cokes, etc). I once got the cramps after drinking diet coke, but drinking diet drinks afterwards did not result in cramps except sometimes while eating out. In those cases the cramps were always in my hands, and I think the waiters just gave me the real thing by mistake. This was a solid solution for me - no ifs, buts, or maybes.
Your problem is likely not nearly as bad as mine as long as you have no kidney problems. Also elderly people can suffer different degrees of kidney malfunction just from age, resulting in intermittent cramps. But the solution is easy. Young people in perfect health can still get dehydrated and/or drink too much sugar. I was on the wrestling team in high school, and we had to weigh in before a match, and if we weighed too much, we would not be able to compete. So on instructions from the coach we could go into the shower room, turn on the hot water, run in the shower so we would sweat off some weight (please excuse me for not having a video), weigh in again, then drink some orange juice for energy. One night after doing that, I was in a match and on the way to an easy win, when suddenly I had extreme, paralyzing cramps so that I could not even move, and I lost the match. Dehydration plus orange juice -- BAAAD!
I think that for you if you make sure you don't drink any sweetened drinks for a while before playing the guitar you should be ok. If not, drinking at least a half glass or more of water 30-60 minutes before playing should help.
Here is my medical reasoning based on what I learned in the 5th grade and in the Navy.
(I was a slow learner, and I never went to kindergarten, so I had to wait until the 5th grade to learn everything I needed to know in life.)
(1) A person can live 3 weeks without food and 3 days without water, but only 3 minutes without air.
(2) When a person goes to sleep, the body focuses primarily on digestion and internal needs. So it reduces the circulation to the extremities (arms, hands, fingers - including guitar fingers, leg - especially lower legs, feet and toes).
Where I work in the computer industry we do nightly backups on our processors while most users are off the system so the response will be faster, though anyone who works at night may see a much slower response.
So since the volume of blood in your body is extremely critical, when that volume gets lower than desired, the body has to make a decision. Oxygen transfer is the most critical function and requires virtually no loss of fluids, whereas picking up waste products from the cells requires running the blood through the kidneys and excreting the waste products using lots of water for urine. That's a No-NO during dehydration, so the body reduces the blood flow through the kidneys, leaving substantial waste products in the blood, resulting in body cramps - sometimes severe, but you still remain alive and oxygenated.
Adding to this misery is the fact that if you are lying down, the blood flow through your extremeties is reduced, adding to the cramps. I also noticed that the body seems to detect vertical/horizontal position of the extremities independently of each other. So I don't get lower leg cramps when sitting down (while dehydrated) because my lower legs are vertical, but I often get cramps in my hands and fingers while sitting at the table or driving in my car because my arms are horizontal. I usually always drink water when eating out, so my hands don't cramp.
Note: I don't have an MD after my name, but this solution works for me - every time. I have tested all of this over and over and can produce or resolve the cramps at will. I still drink orange juice and other drinks as long as it is not just before bed and I drink water afterwards. Of course Half-Price shake night at Sonic is hard to resist and requires me to stay up a little later to wait for the water I drink afterward to do its thing.
If this helps anyone, please let others know so they can benefit also.