Extra calcium is usually the solution for muscle spasms or muscle cramps in many nocturnal cases. The extra requirements for calcium may be a result of high protein or phosphate levels (kidney disease, poor diet), hormonal diseases or imbalances, nutritional imbalances (high Mg/Ca ratio.)
When high calcium is suspected but no resources are available to measure cellular calcium levels (serum calcium cannot be used for that purpose), an acidifying approach may be tried such as taking a very large amount of Vitamin C for a few days.
If the muscle spasms or cramps get worse, then at least one can assume that calcium was likely on the low side, and one needs to increase its dietary intake, and/or use calcium supplementation.
If on the other hand the muscle cramps or spasms improve, then calcium is likely too high and requires co-factors to make it more bioavailable by supplementing either magnesium, or a phosphorus source such as lecithin, a higher daily intake of Vitamin C, or one could increase one's protein intake as
another option.