To clarify on what Dusty said, you really should have a player class with some basic item functions, e.g.
PHP Code:
public function addItem(item, quantity) {
// checks to make sure quantity is valid, etc.
this.clientr.item.(@ item) += quantity;
this.addWeapon(item);
// perhaps some logging?
}
public function removeItem(item, quantity) {
// checks to make sure quantity is valid
this.clientr.item.(@ item) = max(0, this.clientr.item.(@ item) - quantity); // the 'max' prevents the quantity from falling below zero
if (this.clientr.item.(@ item) <= 0) {
this.removeWeapon(item);
}
// perhaps some logging?
}
public function getItemQuantity(item) {
return this.clientr.item.(@ item);
}
You would create a class called "player" or so, then join it to the player in the
onActionPlayerOnline function in the Control-NPC, like...
PHP Code:
function onActionPlayerOnline() {
player.join("player");
}
You could then do stuff like
PHP Code:
temp.prizes = {"Treasure/Map", "Treasure/Chest", "Treasure/Key"};
player.addItem(randomstring(prizes), 1);
which would automatically handle adding the weapon, changing the quantity, and logging (if you added that).
Also, you should use
player.level.name, not
player.level. The former is a string, which is what you want, while the latter is an object. Unfortunately, Graal does some funny stuff which will let that work, but it's poor scripting to do so.