Well... after removing pretty much EVERYTHING from this rather annoying cap file... I've still got problems. Trying to add 1 to my global variable damage and remove 18 from the global variable Gold. But it multiplies everything by 3. Earlier I was having lag and it would only remove the requested amount if I moved the mouse quickly away after clicking on the button. But only on the first time, after that it would remove 3x the amount again.
But anyways... here's the cap file. Any solutions or work arounds or pointing out whatever stupid mistake I've made would be way appreciated. I think I've spent a good 5 hours trying to figure out different ways to do this... without any luck. I've even tried at one point writing it in python, with the exact same result.