Opening a virtual box?Solved

I have seen these plugins that skin your items that use a container to hold the items being skinned. My question is how do they do the whole make and access a box thing? I have been looking at the Skins plugin by misticos and I came up with this:

[ChatCommand("test")]
void testcommand(BasePlayer player, string command, string[] args) {
 ItemContainer itemcont = new ItemContainer {
  entityOwner = player,
   capacity = 36,
   isServer = true,
   allowedContents = ItemContainer.ContentsType.Generic
 };
 itemcont.GiveUID();
 timer.Once(0.5 f, () => test(player, itemcont));
}

public void test(BasePlayer Owner, ItemContainer container) {
 var loot = Owner.inventory.loot;
 loot.Clear();
 loot.PositionChecks = false;
 loot.entitySource = Owner;
 loot.itemSource = null;
 loot.AddContainer(container);
 loot.SendImmediate();

 Owner.ClientRPCPlayer(null, Owner, "RPC_OpenLootPanel", "generic");
}

This briefly opens a container and fires the OnPlayerLootEnd event but it disappears after that. Any help and suggestions would be much appreciated.

You need to spawn actual entity (StorageContainer for example) and access its inventory.
ok then why does something similar work in the plugin? Also how could I create a storagecontainer in regards to scripting?
Durgen
ok then why does something similar work in the plugin? Also how could I create a storagecontainer in regards to scripting?
GameManager.server.CreateEntity <- method to create new object.

I dont see any examples where container works without actual entity being spawned, because it's impossible.
2CHEVSKII is wrong. It's possible and implemented in skins and backpack:). Please, DM me in Discord so I can explain u faster. There is a hook you also must handle to allow using fake virtual container.

Merged post

misticos#2334
Locked automatically