RustTip

OnItemAddedToContainer

OxideCarbonItem

Called when item added to container occurs.

void OnItemAddedToContainer(ItemContainer itemContainer, Item item, BasePlayer sourcePlayer)
Method changed — check — the game method differs from the one the hook is recorded for in Oxide. The hook is still called, but its place may have shifted — worth checking after an update.

Parameters

itemContainer
ItemContainer
item
Item
sourcePlayer
BasePlayer

Return value

voidThe return value is ignored — the hook only notifies.

Example

private void OnItemAddedToContainer(ItemContainer itemContainer, Item item, BasePlayer sourcePlayer)
{
    Puts("OnItemAddedToContainer");
}

Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.

Injection point

Rust.opj (Oxide)
bool ItemContainer.Insert(Item, BasePlayer)

Passes: ItemContainer itemContainer, Item item, BasePlayer sourcePlayer

Method changed — checkReturnBehavior: ContinueArgumentBehavior: AllAssembly-CSharp.dll

Where it is called (this branch's game code)

// …
		}
		itemsWithOnCycle.Add(item);
	}
	ItemContainer itemContainer = parent?.parent;
	if (itemContainer != null && itemContainer.onItemContentsChanged != null)
	{
		itemContainer.onItemContentsChanged(item, arg2: true, sourcePlayer);
	}
	Interface.CallHook("OnItemAddedToContainer", this, item, sourcePlayer);
	return true;
}

Sources: Rust.opj from OxideMod/Oxide.Rust (MIT) and hook metadata of the Carbon documentation (MIT). Method code is decompiled from this branch's server.