Skip to content

Container opening for multiple Players?

Gooday all,

Given: Container to be looted.
At least two Players trying to access the same container.

Player 1 accesses/opens a container and generates random stuff to be looted. Before Player1 has looted or closed the container, Player 2 accesses/opens the same container.

How would make it so that Player1 still has the loot he has generated in the container and Player2 generates his own an only sees the items that he has generated. Thus not being able to see or access the other players generated items.

Thank you for you time,

DJ-WoW























Comments

  • ForSeriousForSerious Member Posts: 466
    I don't think you can.
    The best you could do is force player 1 to put the items back if they grab them.
    It's probably more work than it's worth to implement that.

    I have not tested it, because I would need someone to help, but OnOpen shouldn't fire in the case you mentioned.
    Player 2 would have to wait until player 1 leaves, then close and reopen the container to get OnOpen to fire. That is assuming the that you use OnOpen to generate the treasure. You could use OnUsed, but then, it would play out exactly as you described.
  • DJ_WoWDJ_WoW Member Posts: 51
    Thank for your insight. Your time and effort are greatly appreciated.

    DJ-WoW
  • FlapjackFlapjack Member Posts: 1
    I can think of a clunky way this would be possible, though I wouldn't know specifics.

    There is a Banking script on the vault that creates a new container with the "vault" of the associated CD key when the player uses an object or triggers it through a conversation. It would spawn an invisible container that would open for the triggering player.

    You could have a usable chest object that triggers this script, creating a container with loot for the individual players that use it. The issue you might encounter, and the reason I never used the banking script, is that other players could see and use the created containers.
  • MelkiorMelkior Member Posts: 204
    What I'd do is get whoever opened the chest and add their unique object ID as a variable to each created item with SetLocalObject. Then I'd use the OnInventoryDisturb of the chest to check the item taken and who took it and match the object ID of the player who took the item against the object ID stored on the taken item.

    If they match, delete the player's object ID from the item. If they don't match, run a TakeItem to grab the item back. Optionally also run a SpeakString on either the chest or the player who took the item, stating that it's not theirs. If there's no player object ID on the item, then treat it as though it's a match no matter who took the item. You could do that by checking that the player referred to by the retrieved object ID is a valid object (GetIsObjectValid).

    If you want to allow the taking of left-over objects by other players, have a heartbeat script which counts down before erasing all player IDs from all items still in the chest. Not perfect, but better than nothing.

    If you want to get a bit more complicated, you could have the chest maintain a list of player object IDs on the chest and on each heartbeat it could loop through them and check whether or not the player is still present (within 10 metres, for example) and if not, erase that player ID from any objects left for them in the chest so anyone can take the leftover items.
  • DJ_WoWDJ_WoW Member Posts: 51
    Gooday all,

    Thank you for your insightful ideas. I haven't been able to keep up on my posts. Sorry it took so much time to respond to these new suggestions.

    I was thinking along the lines of variable PC Id. Thanks for letting me see that this is how another person would tackle this puzzle.

    Again, thank you for your time and effort.

    DJ-WoW
  • NeverwinterWightsNeverwinterWights Member Posts: 339
    What most people do for scripting in this situation is to make it so that the chest the players use doesn't actually have inventory, but rather is just a useable "middle man" object that forces the players to interact with another created invisible object that has each players unique inventory. No need for variables or players putting items back, etc. There are systems on the vault have what you need. Can't remember which ones off the top of my head. I can look when I get home.

    https://neverwintervault.org/
Sign In or Register to comment.