RustTip

OnCowMilked

OxideCarbonAnimal
void OnCowMilked(Rust.Ai.Gen2.Cow cow, BasePlayer player, object l1)
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

cow
Rust.Ai.Gen2.Cow
player
BasePlayer
l1
object

Return value

voidThe return value is ignored — the hook only notifies.

Example

private void OnCowMilked(Rust.Ai.Gen2.Cow cow, BasePlayer player, object l1)
{
    Puts("OnCowMilked");
}

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

Injection point

Rust.opj (Oxide)
bool Rust.Ai.Gen2.Cow.TryMilk(BasePlayer)

Passes: Rust.Ai.Gen2.Cow cow, BasePlayer player, object l1

Method changed — checkReturnBehavior: ContinueArgumentBehavior: UseArgumentString (this, a0, l1)Assembly-CSharp.dll

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

// …
MilkCharges = Mathf.Max(0, MilkCharges - 1);
RefreshProduction();
if (MilkDef != null)
{
	int num = MilkedAmount();
	player.GiveItem(ItemManager.Create(MilkDef, num, 0uL, isServerSide: true, 0uL));
	if (MilkEffect != null && MilkEffect.isValid)
	{
		Interface.CallHook("OnCowMilked", this, player, local1);
		Effect.server.Run(MilkEffect.resourcePath, this, 0u, Vector3.zero, Vector3.zero);
	}
	Analytics.Azure.OnLivestockCowMilked(player, this, num);
}
if (!TrustsToHandle(player))
{
	ReactToUntrustedHandling(player);
}
// …

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.