@Wulf
What is the appropriate way to disable or remove items from spawning when using OnCollectiblePickup(CollectibleEntity collectible, BasePlayer player)?
item.amount = 0; //works, but throws a warning in console:
Creating item with less than 1 amount! (Cloth)
Creating item with less than 1 amount! (Hemp Seed)and I've read elsewhere that it is not the preferred method. I had tried converting the ItemAmount object to an Item object, so that I could use the item.Remove() function, but type errors prevented that route as well as it cannot convert between the two types. I looked at the assemblies for ItemDefinition and ItemAmount and didn't see anything in there that led me to believe it would remove the item / prevent collection / disable it. I've disassembled a few different plugins hoping to find clues as to how to accomplish this, but haven't found anything that was obvious.
It occured to me that I could check player inventory for a static item identifier after the item had already been given to the player, but that seems more resource intensive than necessary, and would still show the user that they recieved x of an item and then it was removed.
Is there a cleaner way to perform this than I have written below?
private void OnCollectiblePickup(CollectibleEntity collectible, BasePlayer player)
{
foreach (ItemAmount item in collectible.itemList)
{
var name = item.itemDef.name;
Puts(name);
if (name == "metal_ore.item")
{
_metal(player);
_silver(player);
}
if (name == "cloth.item")
{
item.amount = 0;
}
if (name == "hemp_seed.item")
{
item.amount = 0;
_hemp(player);
}
}
}