You need to store 'this.inside' in a DB-NPC and use chestid to make 'this.inside' unique.
I.e: this.("chest_" @ this.chestid)
The Chest GUI should be created in the weapon npc.
1. Player Touches Chest
2. Call 'Chest Weapon' with Chest ID to load chest.
I.e: findweapon("-GUI/Chest").loadChest(this.chestid);
3. Trigger Server: Get contents of Chest ID (optional: Check Chest Owner)
I.e: triggerserver("gui", this.name, "loadChest", this.chestid);
4. Trigger Client: Contents of Chest ID
I.e: player.triggerclient(this.name, "chestContents", this.contents);
5. Store Contents on Clientside and Draw Chest GUI
I.e: this.contents = params[1];
I'd store the data in a DB-NPC called DB_Chests and use public functions to access and modify the data. I.e:
PHP Code:
public function getChest(chestid) {
// Return contents of chest
return this.("chest_" @ chestid);
}
public function addToChest(chestid, weaponName) {
// Add Weapon to Chest
this.("chest_" @ chestid).add(weaponName);
}
public function removeFromChest(chestid, weaponName) {
// Remove Weapon From Chest
this.("chest_" @ chestid).remove(weaponName);
}
public function hasInChest(chestid, weaponName) {
// Check if Weapon is in Chest
return weaponName in this.("chest_" @ chestid);
}
Then you can use:
DB_Chests.getChest(chestid);
DB_Chests.addToChest(chestid, weaponName);
DB_Chests.removeFromChest(chestid, weaponName);
DB_Chests.hasInChest(chestid, weaponName);
To access and modify the contents of chests.
Also keep in mind that variables you set on the server-side are inaccessible on the client-side, I would recommend using attrs to get around that. I.e:
In your chest class:
PHP Code:
function onCreated() {
this.attr[2] = this.chestid;
this.attr[3] = this.chestowner; // (optional)
}
//#CLIENTSIDE
function loadChest() {
temp.chestid = this.attr[2];
temp.chestowner = this.attr[3];
// do stuff with it.
}
// your other code...