I'm trying to code a hat system, and I'm having a little bit of trouble. To bring up the shop GUI with all the information on the hat, you have to click the hat image in the level. All of the hat images have the same class joined to them, object_hat. Now, I'm using a triggeraction when the player clicks the buy button, and instead of the player buying just that hat, all the NPC's in the level with the class joined to them get the triggeraction too, and I end up buying 6 or 7 hats.
PHP Code:
function onActionBuyHat() {
temp.hat_name = params[1];
temp.hat_price = params[2];
if (temp.hat_name in clientr.questhats.tokenize(",")) {
return;
} else {
if (!(player.rupees => temp.hat_price)) {
echo(player.account SPC "doesn't have enough!");
} else {
player.rupees -= temp.hat_price;
player.clientr.questhats.add(temp.hat_name);
}
}
}
This is the triggeraction.
PHP Code:
triggeraction(this.x,this.y,"BuyHat","",this.hat_name,this.hat_price);
I don't want all the NPC's with the class joined to receive the triggeraction.
Am I doing something wrong? Also, I tend to script something and get it working and then clean the script up a bit, so it's a little messy :P