RustTip

OnItemUpgrade

OxideCarbonItem

Called when an item upgrades.

void OnItemUpgrade(Item item, Item local0, BasePlayer player)
Works — the game method in this build is the one the hook was written for.

Parameters

item
Item
local0
Item
player
BasePlayer

Return value

voidThe return value is ignored — the hook only notifies.

Example

private void OnItemUpgrade(Item item, Item local0, BasePlayer player)
{
    Puts("OnItemUpgrade");
}

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

Injection point

Rust.opj (Oxide)
void ItemModUpgrade.ServerCommand(Item, string, BasePlayer)

Passes: Item item, Item local0, BasePlayer player

WorksReturnBehavior: ContinueArgumentBehavior: UseArgumentString (a0, l0, a2)Assembly-CSharp.dll

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

// …
if (!(command == "upgrade_item") || item.amount < numForUpgrade)
{
	return;
}
if (Random.Range(0f, 1f) <= upgradeSuccessChance)
{
	item.UseItem(numForUpgrade);
	Item item2 = ItemManager.Create(upgradedItem, numUpgradedItem, 0uL, isServerSide: true, 0uL);
	Interface.CallHook("OnItemUpgrade", item, item2, player);
	item2.SetItemOwnership(player, ItemOwnershipPhrases.UpgradeItem);
	if (!item2.MoveToContainer(player.inventory.containerMain))
	{
		item2.Drop(player.GetDropPosition(), player.GetDropVelocity());
	}
	if (successEffect.isValid)
	{
		Effect.server.Run(successEffect.resourcePath, player.eyes.position);
// …

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.