Use this serverside to modify a clientr var.
PHP Code:
function onActionServerSide(){
if(params[0] == "ammo"){
clientr.whatever = 100;
}
}
Then on the clientside to trigger it.
PHP Code:
triggerserver("weapon", this.name, "ammo");
Also as I have learnt, style you're code.
Google JavaScript beautifier and run you're code through it.