RustTip

OnFishCatch

OxideCarbonFishing

Called when fish catch occurs.

object OnFishCatch(Item item, BaseFishingRod baseFishingRod, BasePlayer basePlayer)
Works — the game method in this build is the one the hook was written for.

Parameters

item
Item
baseFishingRod
BaseFishingRod
basePlayer
BasePlayer

Return value

objectThe result is checked in a special way — see the call code below.

Example

object — you can affect the game: return a value to change or cancel the action.

private object OnFishCatch(Item item, BaseFishingRod baseFishingRod, BasePlayer basePlayer)
{
    Puts("OnFishCatch");

    // change nothing — the game continues as usual
    return null;

    // to affect the game:
    // return null; // null — the game continues as usual
}

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

Injection point

Rust.opj (Oxide)
void BaseFishingRod.CatchProcessBudgeted()

Passes: Item item, BaseFishingRod baseFishingRod, BasePlayer basePlayer

WorksReturnBehavior: CustomAssembly-CSharp.dll

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

// …
CurrentState = CatchState.Caught;
if (currentFishTarget != null)
{
	Item item = ItemManager.Create(currentFishTarget, 1, 0uL, isServerSide: true, 0uL);
	item.SetItemOwnership(ownerPlayer, ItemOwnershipPhrases.Fishing);
	ownerPlayer.GiveItem(item, GiveItemReason.Crafted);
	if (currentFishTarget.shortname == "skull.human")
	{
		object result = Interface.CallHook("OnFishCatch", item, this, ownerPlayer);
		// … проверка результата (Modify-хук, см. Rust.opj)
		item.name = RandomUsernames.Get(Random.Range(0, 1000));
	}
	if (GameInfo.HasAchievements && !string.IsNullOrEmpty(fishableModifier.SteamStatName))
	{
		ownerPlayer.stats.Add(fishableModifier.SteamStatName, 1);
		ownerPlayer.stats.Save(forceSteamSave: true);
		FishLookup.Instance.CheckCatchAllAchievement(ownerPlayer);
// …

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.