Hello, new to the API. Currently starting with something simple and trying to create an auto deposit for players inventories when they break a barrel. I however don't know how to get a ItemContainer from HitInfo. Any suggestions?
namespace Oxide.Plugins
{
[Info("InstaPocket", "Zlaio", "0.0.1")]
class InstaPocket : RustPlugin
{
public readonly string[] barrels =
{
"loot_barrel_1",
"loot_barrel_2",
"loot-barrel-1",
"loot-barrel-2",
"oil_barrel"
};
public Hash<uint,ulong> looters = new Hash<uint, ulong>();
object OnContainerDropItems(ItemContainer container)
{
if (barrels.Contains(container.entityOwner.ShortPrefabName))
{
PrintToChat("Barrel!");
BasePlayer player = BasePlayer.FindByID(looters[container.uid]);
//Just printing for debugging as of now
for (int i = 0; i < container.itemList.Count; i++)
{
PrintToChat(player,container.itemList[i].ToString());
}
return container;
}
return null;
}
object OnMeleeAttack(BasePlayer player, HitInfo info)
{
if (barrels.Contains(info.HitEntity.ShortPrefabName))
{
ItemContainer container = info.HitEntity.GetComponent<ItemContainer>();
looters[container.uid] = player.userID;
}
return null;
}
}
}