Skip to content
RustPluginGenerator

OnSteamInventoryUpdated

OnSteamInventoryUpdated is called after a player's Steam inventory has been refreshed from the Steam backend and written into their in-game container.

Signature
void OnSteamInventoryUpdated(SteamInventory steamInventory)

Parameters

Hook parameters
ParameterTypeDescription
steamInventorySteamInventoryThe SteamInventory component whose contents were just refreshed. Use its baseEntity field (a BasePlayer) to identify the owner, and its inventory ItemContainer to read the synced items.

Return value

The game method returns void and ignores the hook return value, so returning anything (or nothing) has no effect on the refresh. Use the hook for observation only; item changes happen regardless of what your plugin returns.

How it works

The hook fires inside SteamInventory.UpdateSteamInventory once the Steam inventory result has been received and applied with SetItems. It runs after the container contents are replaced, and only on the success path where the owner matches and the component's GameObject is still valid; error paths such as an inventory belonging to someone else never reach it.

The single argument steamInventory is the component being updated. Its baseEntity is the owning BasePlayer (and baseEntity.userID identifies them), while inventory is the ItemContainer holding the freshly synced items. Read those members after null-checking baseEntity, since the refresh is asynchronous and the player may have disconnected.

The hook is declared with SteamInventory as the parameter type, so Oxide passes it only when the argument is that type. Declaring a narrower type is not possible here because the argument is a component, not a player; filter on baseEntity yourself.

Treat this as a sync-complete signal rather than a per-item event. It can fire whenever the server refreshes the container, including scheduled or forced updates, so keep the handler cheap and do not assume it only runs once per session.

Example plugin: Warn players when a Steam inventory sync leaves the main container full

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

namespace Oxide.Plugins
{
    [Info("Steam Inventory Sync Monitor", "RustPluginGenerator", "1.0.0")]
    [Description("Warns players when their Steam inventory sync leaves the container full and optionally logs syncs")]
    public class SteamInventorySyncMonitor : RustPlugin
    {
        private const string PermNotify = "steaminventorysyncmonitor.notify";

        private PluginConfig config;
        private readonly Dictionary<ulong, float> lastNotice = new Dictionary<ulong, float>();

        private class PluginConfig
        {
            [JsonProperty("Send sync summary to player")]
            public bool SendSummary { get; set; } = true;

            [JsonProperty("Cooldown seconds between notices")]
            public float CooldownSeconds { get; set; } = 30f;
        }

        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>
            {
                ["Full"] = "Your Steam inventory synced, but the container is full ({0} items). Free space to receive new items.",
                ["Synced"] = "Steam inventory synced: {0} items in the container.",
                ["NoPermission"] = "You do not have permission to receive Steam inventory notices."
            }, 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(PermNotify, this);
        }

        private void OnSteamInventoryUpdated(SteamInventory steamInventory)
        {
            if (steamInventory == null || steamInventory.baseEntity == null) return;

            var player = steamInventory.baseEntity;
            if (player == null || player.IsDestroyed || !player.IsConnected) return;

            var container = player.inventory?.containerMain;
            if (container == null) return;

            if (!config.SendSummary) return;
            if (!permission.UserHasPermission(player.UserIDString, PermNotify)) return;

            float now = UnityEngine.Time.realtimeSinceStartup;
            float last;
            if (lastNotice.TryGetValue(player.userID, out last) && now - last < config.CooldownSeconds) return;
            lastNotice[player.userID] = now;

            int freeSlots = container.capacity - container.itemList.Count;
            if (container.IsFull() || freeSlots <= 0)
            {
                player.ChatMessage(Msg("Full", player.UserIDString, container.itemList.Count));
            }
            else
            {
                player.ChatMessage(Msg("Synced", player.UserIDString, container.itemList.Count));
            }
        }

        private void Unload()
        {
            lastNotice.Clear();
        }
    }
}

The plugin listens for the Steam inventory refresh and identifies the owner through steamInventory.baseEntity. It checks free space in the owner's main inventory container (container.capacity - container.itemList.Count) and sends a chat message. When the container is full or has no free slots, the message tells the player to free space. Otherwise it sends a sync summary with the current item count.

A cooldown keyed by user ID prevents duplicate messages when the inventory updates more than once in a short window. A config flag controls whether notices are sent at all, and a permission (steaminventorysyncmonitor.notify) restricts them to selected players. All player-facing text goes through the language file, and the handler bails out safely if the owner has disconnected or the main container is missing.

Common use cases

  • Notify players when their Steam inventory sync completes

    Send a short confirmation to the owner once items have been written to their container, useful after a manual refresh command on a large server.

  • Detect full Steam inventories

    Inspect the container and warn players whose sync left them with no room, prompting them to free space before the next trade or craft.

  • Audit sync activity

    Record the timestamp and item count of each refresh for admin review when players report missing items.

Pitfalls

  • The owner may be gone

    The refresh is asynchronous, so baseEntity can be destroyed or disconnected by the time the hook runs. Always null-check it and its net.connection before sending chat.

  • It is not a per-item event

    The whole container is replaced before the hook fires, so you cannot tell which specific items changed. Compare against a stored snapshot if you need differences.

  • Multiple fires per session

    The refresh can run more than once, including forced updates. Keep the handler cheap and gate messages with a cooldown to avoid chat spam.

Build a plugin with OnSteamInventoryUpdated

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

Prompt: Notify players when their Steam inventory sync completes using the OnSteamInventoryUpdated 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 OnSteamInventoryUpdated

Generate