CanCatchFish
CanCatchFish is called when a fishing rod finishes its catch process and a fish item has just been created, before the catch is announced through OnFishCatch. Returning false aborts the catch.
object CanCatchFish(BasePlayer ownerPlayer, BaseFishingRod fishingRod, Item item)Parameters
| Parameter | Type | Description |
|---|---|---|
ownerPlayer | BasePlayer | The BasePlayer who owns the fishing rod and is reeling in the catch. Can be null in edge cases where the rod has no player owner. |
fishingRod | BaseFishingRod | The BaseFishingRod entity that just finished the catch process. Use it to read rod state or the position of the catch. |
item | Item | The freshly created Item for the caught fish (from the rod's current fish target). It is server-side only and not yet given to the player. |
Return value
Return null (or anything other than a bool) to keep normal behavior. Returning false stops the original method before OnFishCatch is called, so the fish item is created but never awarded or announced. Returning true has no effect and the catch continues.
How it works
The hook fires inside BaseFishingRod.CatchProcessBudgeted at the moment the rod sets its state to Caught and creates the fish Item from currentFishTarget. At that point the item already has fishing ownership assigned to the rod's player, but it has not yet been handed over or announced; the OnFishCatch hook runs immediately after this one.
ownerPlayer is the angler (read UserIDString for permissions or config lookups). fishingRod lets you inspect where the catch happened (transform.position) or which entity produced it. item is the actual fish Item — check item.info.shortname to see what was caught and to filter by species.
Oxide dispatch: the hook is only invoked when every argument matches your declared parameter types. Declaring BasePlayer for the first parameter is the natural choice; declaring a narrower type such as a specific rod subclass would make Oxide skip calls where the argument is a different type.
Practical uses: whitelist or blacklist fish species, enforce a permission before a player can catch, apply server-wide cooldowns, or drop extra rewards. The hook does not run when the rod's catch is empty (no currentFishTarget).
Example plugin: Restrict rare fish to a permission
using System.Linq;
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
namespace Oxide.Plugins
{
[Info("Fishing Species Control", "RustPluginGenerator", "1.0.0")]
[Description("Restricts selected fish species behind a permission that bypasses the restriction.")]
public class FishingSpeciesControl : RustPlugin
{
private const string PermBypass = "fishingspeciescontrol.bypass";
private PluginConfig config;
private class PluginConfig
{
[JsonProperty("Restricted fish shortnames")]
public List<string> RestrictedFish = new List<string> { "anchovy" };
}
protected override void LoadDefaultConfig() => config = new PluginConfig();
protected override void LoadConfig()
{
base.LoadConfig();
try
{
config = Config.ReadObject<PluginConfig>();
if (config == null) throw new Exception();
}
catch
{
PrintWarning("Configuration file is invalid, using defaults");
LoadDefaultConfig();
}
SaveConfig();
}
protected override void SaveConfig() => Config.WriteObject(config);
protected override void LoadDefaultMessages()
{
lang.RegisterMessages(new Dictionary<string, string>
{
["Restricted"] = "The {0} is reserved for permitted anglers and slipped off your hook."
}, this);
}
private string Msg(string key, string userId = null, params object[] args) =>
string.Format(lang.GetMessage(key, this, userId), args);
private void Init()
{
permission.RegisterPermission(PermBypass, this);
}
private object CanCatchFish(BasePlayer ownerPlayer, BaseFishingRod fishingRod, Item item)
{
if (item?.info == null || config == null) return null;
if (config.RestrictedFish == null || !config.RestrictedFish.Contains(item.info.shortname)) return null;
if (ownerPlayer == null || !ownerPlayer.IsConnected) return false;
if (permission.UserHasPermission(ownerPlayer.UserIDString, PermBypass)) return null;
ownerPlayer.ChatMessage(Msg("Restricted", ownerPlayer.UserIDString, item.info.displayName.english));
return false;
}
}
}The plugin defines a config with a list of restricted fish shortnames (for example anchovy or other rare catches) and a permission that lets a player bypass the restriction. In CanCatchFish, the hook checks the owner and the item, then verifies whether the item's shortname is on the list. If it is, the player's UserHasPermission result decides: holders return true, everyone else returns false and the catch is dropped before OnFishCatch fires. A lang message is sent to the player telling them the species was restricted. Config and the permission are registered in Init and LoadDefaultConfig, so admins can edit the list without recompiling.
Common use cases
Block rare fish for non-VIPs
Return false when the caught species is in a restricted list and the player lacks a permission, so only donors or staff can land those fish.
Apply a server-wide cooldown
Track the last catch time per player id in a dictionary and reject catches that arrive too soon, keeping a reference to the timer that clears entries.
Reward specific species
Use the fish
item.info.shortnameto decide whether to give bonus items viaGiveItemor trigger a chat announcement.
Pitfalls
The item is not yet in inventory
At hook time the fish has just been created with
isServerSidetrue and ownership set, but it is not in the player's container. Do not attempt to move or remove it; just approve or reject the catch.The hook does not fire for every reel-in
If
currentFishTargetis null the hook is skipped entirely, so logic keyed on this hook should not assume every rod completion reaches it.Null owner player
Always null-check
ownerPlayerbefore calling permission methods or sending messages; a rod can exist without a connected owner.
Build a plugin with CanCatchFish
Describe what should happen and get a compiled plugin that uses this hook.
Edit the prompt on the next screen. 2 free plugins a month, no card.
Last updated Oct 26, 2026. Found a mistake? Email support@rustplugingenerator.com.
Build a plugin with CanCatchFish
Generate