The problem is that the weapon and the price aren't defined. You'll need to have the client send information on the weapon when it sends the trigger. You could also have it send the price but that's a security risk.
My suggestion (since I doubt you want to use NPC registration, which is what I would do) is to have a list of prices for each weapon:
PHP Code:
function onCreated() {
this.price.Sword = 100;
}
function onActionServerSide(cmd, item) {
if (cmd == "buy") {
if (this.price.(@ item) > 0) {
if (player.rupees > this.price.(@ item)) {
player.rupees -= this.price.(@ item);
player.addWeapon(item);
} else {
player.chat = "I don't have enough money to buy this item!";
}
}
}
}