1. Hey guys I'm wondering if there's a way to detect when a chest has been opened? Perhaps load data from elsewhere? I'm trying to make a banking system in lua, inside a safe zone. Where there will be one chest people can store limited items they don't want to lose.

    Any more information on this idea would be great.

    EDIT: Let me clarify, it won't actually be a chest in the traditional sense. The object will be there but when the player opens it it'll show the normal chest opening etc but all the contents will be loaded dynamically for that one person. Every person that opens the chest will see different items, to emulate a storage system.

    Is it possible?
     
    Last edited by a moderator: Jun 10, 2015
  2. Calytic

    Calytic Community Admin Community Mod

    Yes and no.

    When a player opens a loot container, the OnPlayerLoot(playerloot, targetentity) hook is triggered. However, displaying different loot in the same chest for different players is a going to be tricky and may require a significant amount of code depending on how the server handles these packets(which I do not yet fully understand). It is possible this might work if you isolate the network updates which send container data to the client.

    You will likely also have to isolate network updates related to adding and removing items as the built-in server validation is probably written to check for an items existence whereas the items in your chests wont actually exist in the chest but be projected into it via some networking magic.
     
  3. Speaking from a C# perspective,

    Why not wipe the crate, initialize a List and each item that the player adds is then pushed in to the List, the List then is stored in a JSON data file tied to the persons UserID or GUID.

    Add detection so that after wiping the crate it checks to see if the JSON value is Not null, if it isn't null then it re-populates the box from that list, otherwise it does nothing until he adds items.
     
  4. Calytic

    Calytic Community Admin Community Mod