RustTip

OnDispenserGathered

OxideCarbonResource

Called when a dispenser is gathered.

void OnDispenserGathered(ResourceDispenser resourceDispenser, BasePlayer entity, Item local7)
Works — the game method in this build is the one the hook was written for.

Parameters

resourceDispenser
ResourceDispenser
entity
BasePlayer
local7
Item

Return value

voidThe return value is ignored — the hook only notifies.

Example

private void OnDispenserGathered(ResourceDispenser resourceDispenser, BasePlayer entity, Item local7)
{
    Puts("OnDispenserGathered");
}

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

Injection point

Rust.opj (Oxide)
void ResourceDispenser.GiveResourceFromItem(BasePlayer, ItemAmount, float, float, AttackEntity)

Passes: ResourceDispenser resourceDispenser, BasePlayer entity, Item local7

WorksReturnBehavior: ContinueArgumentBehavior: UseArgumentString (this, a0, l7)Assembly-CSharp.dll

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

// …
	if (item != null)
	{
		ApplyItemOwnership(entity, item);
		OverrideOwnership(item, attackWeapon);
		Analytics.Azure.OnGatherItem(item.info.shortname, item.amount, baseEntity, entity, attackWeapon);
		while (item.amount > item.MaxStackable())
		{
			Item item2 = item.SplitItem(item.MaxStackable());
			Interface.CallHook("OnDispenserGathered", this, entity, item);
			entity.GiveItem(item2, BaseEntity.GiveItemReason.ResourceHarvested, GiveItemOptions.BackpackOverflow);
		}
		entity.GiveItem(item, BaseEntity.GiveItemReason.ResourceHarvested, GiveItemOptions.BackpackOverflow);
	}
}

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.