Skip to content
RustPluginGenerator

OnPlayerDropActiveItem

OnPlayerDropActiveItem is called when a player presses the drop key on the item in their active belt slot, before the item leaves the player. Returning a non-null value cancels the drop.

Signature
object OnPlayerDropActiveItem(BasePlayer player, Item activeItem)

Parameters

Hook parameters
ParameterTypeDescription
playerBasePlayerThe BasePlayer who is trying to drop the item held in the active belt slot.
activeItemItemThe Item currently held in the active slot, fetched from the player before the drop is processed. Use it to check shortname, skin, amount or condition.

Return value

Returning null (or any null value) lets the vanilla drop proceed. Returning any non-null object stops PlayerBelt.DropActive before the item is removed, so the drop is cancelled. The returned object is ignored beyond that check.

How it works

The hook fires inside PlayerBelt.DropActive, which the game runs when a player drops whatever they are currently holding. Right after the method reads the active item, Oxide calls OnPlayerDropActiveItem with the player and that item. If your hook returns a non-null value, the original method exits immediately and nothing is dropped; a null return lets the vanilla drop continue.

Useful parameters:

  • player is the dropper. Check IsAdmin, permissions, currentTeam, building privileges or position here.
  • activeItem is the exact Item that would be dropped. Inspect info.shortname, skin, amount and condition to target specific items.

Declaring BasePlayer matches the real argument, so the signature above is safe. Since the injection carries the active item only, the hook does not fire for dropping items from the inventory screen, and it will not run for non-belt drops. Blocking the drop does not change the item; you must keep the item in place yourself if you cancel. Because this fires only on user input, it is cheap enough to use permission and config lookups inside, but avoid heavy work.

Example plugin: Block dropping valuable items for players without permission

NoDropValuables.cs
using System.Linq;
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;

namespace Oxide.Plugins
{
    [Info("No Drop Valuables", "RustPluginGenerator", "1.0.0")]
    [Description("Blocks dropping configured active belt items unless the player has a bypass permission")]
    public class NoDropValuables : RustPlugin
    {
        private const string PermBypass = "nodropvaluables.bypass";

        private PluginConfig config;
        private HashSet<string> protectedShortnames;

        private class PluginConfig
        {
            [JsonProperty("Protected item shortnames")]
            public List<string> ProtectedItems = new List<string>
            {
                "rocket.launcher",
                "ammo.rocket.basic",
                "explosive.timed",
                "blueprintbase"
            };
        }

        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>
            {
                ["DropBlocked"] = "You are not allowed to drop {0}."
            }, 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);
            protectedShortnames = new HashSet<string>(config.ProtectedItems ?? new List<string>(), StringComparer.OrdinalIgnoreCase);
        }

        private object OnPlayerDropActiveItem(BasePlayer player, Item activeItem)
        {
            if (player == null || activeItem == null || activeItem.info == null)
                return null;

            if (protectedShortnames.Count == 0 || !protectedShortnames.Contains(activeItem.info.shortname))
                return null;

            if (permission.UserHasPermission(player.UserIDString, PermBypass))
                return null;

            player.ChatMessage(Msg("DropBlocked", player.UserIDString, activeItem.info.displayName.english));
            return true;
        }
    }
}

The plugin holds a configurable list of protected shortnames plus a permission (nodropvaluables.bypass). When OnPlayerDropActiveItem fires, it first checks activeItem.info for null and looks the item up in the protected set. If the item is not protected, it returns null and the drop happens normally. If it is protected and the player holds the bypass permission, the drop is also allowed. Otherwise the hook sends a localised chat message telling the player the item cannot be dropped and returns a non-null value to cancel the action. Protected shortnames are returned to the player in the message so admins can confirm the config, and the list is loaded from the plugin config on startup.

Common use cases

  • Protect raid and event items

    Stop players from dropping items like launcher rockets or event currency during a boss fight so they cannot be picked up by teammates as an unintended transfer.

  • Enforce carry restrictions

    Block dropping the item while the player is mounted, building blocked or inside a PvP zone, keeping gameplay rules consistent with the rest of your server.

  • Anti-abuse for gated players

    Restrict dropping certain items for jailed or muted players so they cannot pass items to accounts that are not allowed to trade.

Pitfalls

  • It only covers the active belt slot

    Dropping items from the inventory UI or moving stack items goes through other game paths. Use inventory or OnItemAction style checks if you need full drop coverage.

  • Cancelling leaves the item in hand

    Returning a non-null value aborts the drop before anything moves, so the item stays in the active slot. Do not also try to move it elsewhere in the same hook.

  • Watch for dead or disconnected players

    The player can be null in edge cases such as a death drop chain. Null-check both parameters and return null when either is missing.

Build a plugin with OnPlayerDropActiveItem

Describe what should happen and get a compiled plugin that uses this hook.

Prompt: Protect raid and event items using the OnPlayerDropActiveItem hook, with a config file and a permission
Generate this plugin

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 OnPlayerDropActiveItem

Generate