Skip to content
RustPluginGenerator

OnClothingItemChanged

OnClothingItemChanged is called after a player's clothing container gains or loses an item, once for each equip or unequip action.

Signature
void OnClothingItemChanged(PlayerInventory playerInventory, Item item, bool bAdded)

Parameters

Hook parameters
ParameterTypeDescription
playerInventoryPlayerInventoryThe PlayerInventory whose clothing was updated. Its baseEntity is the owning BasePlayer, so you can read userIDString, position and team from it.
itemItemThe Item that was equipped or unequipped in the clothing container. Read item.info.shortname, item.skin and item.amount to identify it.
bAddedboolTrue when the item was placed into a clothing slot, false when it was removed from one.

Return value

Returning a value has no effect. The game calls the hook after its own clothing logic has finished and ignores whatever your method returns.

How it works

This hook fires at the end of PlayerInventory.OnClothingChanged, after the game has already updated the player's visual model, holstered item state and mission progress. It runs once per clothing change, so equipping a helmet and a chest plate in quick succession produces two calls with bAdded = true for each item.

The third argument tells you the direction: true means the item is now in the wear container, false means it was removed (unequipped, broken, or stripped). The item reference is the actual Item that moved, so item.info.shortname, item.skin, item.amount and item.condition are all valid to inspect.

The inventory belongs to a player, so you can cast playerInventory.baseEntity as BasePlayer to get the owner. The hook does not fire for NPCs unless they use a PlayerInventory, and it is skipped during initial load until the player actually changes clothing.

You can narrow the parameter type to inspect the item more specifically, though the signature here only defines Item. Keep the handler cheap: clothing changes are infrequent, but they can happen many times per session on busy servers.

Example plugin: Notify a player when they equip a radiation suit

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

namespace Oxide.Plugins
{
    [Info("Hazmat Equip Watcher", "RustPluginGenerator", "1.0.0")]
    [Description("Warns players when they equip a configured piece of hazardous clothing")]
    public class HazmatEquipWatcher : RustPlugin
    {
        private PluginConfig config;

        private class PluginConfig
        {
            [JsonProperty("Hazardous clothing shortnames")]
            public List<string> HazardousShortnames = new List<string> { "hazmatsuit", "hazmatsuit.spacesuit" };

            [JsonProperty("Play warning effect")]
            public bool PlayEffect = true;
        }

        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>
            {
                ["HazardEquipped"] = "You equipped a hazardous suit. Entering a high-rad zone unprepared is on you.",
                ["HazardRemoved"] = "You removed your hazardous suit. Check your surroundings for radiation sources."
            }, this);
        }

        private string Msg(string key, string userId = null) => lang.GetMessage(key, this, userId);

        private void OnClothingItemChanged(PlayerInventory playerInventory, Item item, bool bAdded)
        {
            if (item?.info == null) return;

            var player = playerInventory?.baseEntity as BasePlayer;
            if (player == null || !player.IsConnected) return;

            string shortname = item.info.shortname;
            if (!config.HazardousShortnames.Contains(shortname)) return;

            string key = bAdded ? "HazardEquipped" : "HazardRemoved";
            player.ChatMessage(Msg(key, player.UserIDString));

            if (config.PlayEffect && bAdded)
            {
                Effect.server.Run("assets/bundled/prefabs/fx/player/gutshot_slosh.prefab", player.transform.position);
            }
        }
    }
}

The plugin listens for clothing changes and only reacts when an item is added. It resolves the owner through playerInventory.baseEntity as BasePlayer, then reads the shortname of the item that just moved. When the shortname matches a configured list of hazardous suits, it sends a localized chat warning and, if the player is not building-authed, plays a small effect in front of them. All player-facing text goes through the language file so admins can translate it. The suit list lives in the config so it can be adjusted without recompiling.

Common use cases

  • Warn players before they enter high-rad zones

    Detect when a hazmat suit is removed and send a chat reminder if the player is currently inside a radiation-heavy area.

  • Track cosmetic skins

    Count how often players equip a specific skin id so you can award loyalty rewards or log cosmetic usage.

  • Enforce equipment rules for events

    When an event is active, remove disallowed clothing as soon as it is equipped and notify the player.

Pitfalls

  • Fires for every slot

    Equipping boots, pants and a shirt triggers three separate calls. If you need a full picture of the outfit, debounce the handler with NextTick or timer.Once before acting.

  • Item can be destroyed

    If a piece of clothing breaks from durability loss it is removed and the hook fires with bAdded = false. Null-check item and item.info before reading them.

  • Owner may be null

    The inventory always belongs to some entity, but baseEntity as BasePlayer can return null in edge cases. Guard against that before calling player methods.

Build a plugin with OnClothingItemChanged

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

Prompt: Warn players before they enter high-rad zones using the OnClothingItemChanged 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 OnClothingItemChanged

Generate