The pain is caused by damage to muscle cells. By taking a medication that lessens the myotonia, you can stop some of the pain. But you also have to learn not to push against the stiffness. Wait for the muscles to relax if you can.
Here are some of the medications that have helped myotonia:
Mexiletine
Flecainide
Lamotrigene
Acetazolamide
Phenytoin
Carbamazepine (I don't recommend this one)
Quinine Sulfate
Ask your doctor about trying one of these. Also it can help reduce the inflammation from the muscle damage to take ibuprofen regularly.