CanDropActiveItem
CanDropActiveItem is called when Rust checks whether a player's currently held item blocks dropping, by way of BasePlayer.ShouldDropActiveItem. Returning false makes the game treat the active item as non-droppable.
object CanDropActiveItem(BasePlayer player)Parameters
| Parameter | Type | Description |
|---|---|---|
player | BasePlayer | The BasePlayer whose active (held) item is being evaluated for dropping. Null-check it before using any member. |
Return value
Return null to let the game's default true apply. Return a bool to replace that result: false marks the active item as not droppable, true leaves normal behavior. Any non-bool return is ignored and the default applies.
How it works
This hook fires inside BasePlayer.ShouldDropActiveItem, a bool method the game calls when it needs to know if the player's active item may be dropped. The base game implementation simply returns true. Oxide intercepts the call and asks every plugin first. If a plugin returns a bool, that value becomes the result; otherwise the original true stands.
The single parameter is the BasePlayer involved. Because the hook is declared as CanDropActiveItem(BasePlayer player), Oxide dispatches it for every player the method runs on; there is no narrower type to declare here since the game already passes a BasePlayer.
The hook does not itself move, remove or drop an item. It only answers a yes/no question. Actual drop handling belongs to OnPlayerDropActiveItem, which fires at the moment the held item is dropped. Use this hook for policy decisions such as blocking drops while handcuffed, while in a safe zone, in specific zones, or on cooldown.
Each call should be cheap: the method can be consulted frequently for active players, so avoid allocation-heavy logic and never log from inside the hook.
Example plugin: Block dropping the held item while handcuffed or in a safe zone
using UnityEngine;
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
namespace Oxide.Plugins
{
[Info("No Drop Active Item", "RustPluginGenerator", "1.0.0")]
[Description("Blocks dropping the held item while handcuffed, in a safe zone, or during a cooldown.")]
public class NoDropActiveItem : RustPlugin
{
private const string PermBypass = "nodropactiveitem.bypass";
private PluginConfig config;
private readonly Dictionary<ulong, float> lastDrop = new Dictionary<ulong, float>();
private class PluginConfig
{
[JsonProperty("Block while handcuffed")]
public bool BlockHandcuffed = true;
[JsonProperty("Block in safe zones")]
public bool BlockSafeZone = true;
[JsonProperty("Drop cooldown (seconds)")]
public float Cooldown = 0f;
}
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>
{
["Cooldown"] = "You can drop your held item again in {0}s."
}, 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 CanDropActiveItem(BasePlayer player)
{
if (player == null || player.IsAdmin) return null;
if (permission.UserHasPermission(player.UserIDString, PermBypass)) return null;
if (!player.IsConnected) return null;
if (player.IsWounded()) return false;
if (config.BlockHandcuffed && player.IsRestrained) return false;
if (config.BlockSafeZone && player.InSafeZone()) return false;
if (config.Cooldown > 0f && lastDrop.TryGetValue(player.userID, out float last))
{
float elapsed = UnityEngine.Time.realtimeSinceStartup - last;
if (elapsed < config.Cooldown) return false;
}
return null;
}
private void OnPlayerDropActiveItem(BasePlayer player, Item item)
{
if (player == null) return;
if (config.Cooldown > 0f)
{
lastDrop[player.userID] = UnityEngine.Time.realtimeSinceStartup;
}
}
private void Unload()
{
lastDrop.Clear();
}
}
}The plugin answers CanDropActiveItem for each player. It returns false when the player is wounded, handcuffed (if enabled in config), in a safe zone (if enabled), or on a cooldown after a previous drop; otherwise it returns null so the vanilla result is used. Admins and players with the permission nodropactiveitem.bypass (registered in Init) are always allowed. The cooldown is stored in a dictionary keyed by player.userID and set in OnPlayerDropActiveItem only when config.Cooldown > 0. Each check compares Time.realtimeSinceStartup against the stored timestamp. The dictionary is cleared in Unload. Config exposes toggles for handcuffed and safe-zone blocking, plus the cooldown in seconds (default 0, which disables the cooldown). A lang message key Cooldown exists but is not used; the plugin otherwise acts silently behind the drop check.
Common use cases
Prevent drops while restrained
Return false for handcuffed players so they cannot shed the item they are holding to escape a search or break a jail scenario.
Keep items locked in event zones
Disallow dropping in a minigame or arena area so participants cannot smuggle gear out of the active loadout.
Add a drop cooldown
Track the last drop time per player and return false briefly afterward to rate-limit item spam and exploit attempts.
Pitfalls
This hook does not perform the drop
Returning true does not drop anything; it only permits the game's own drop logic. To react to an actual drop, use OnPlayerDropActiveItem.
Return a bool or null, nothing else
Only a bool return changes the result. Returning a number, string or object is discarded and the default true applies, so guard against accidental returns.
Keep it lightweight
The check can run often for active players. Avoid heavy lookups, allocation and logging inside the hook; cache per-player state instead.
Build a plugin with CanDropActiveItem
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 CanDropActiveItem
Generate