Skip to content
RustPluginGenerator

OnXmasLootDistribute

OnXmasLootDistribute is called when the Christmas refill component (XMasRefill) finishes its server-side setup and is about to start handing out loot to players and stockings. Returning a non-null value cancels that distribution.

Signature
object OnXmasLootDistribute(XMasRefill xMasRefill)

Parameters

Hook parameters
ParameterTypeDescription
xMasRefillXMasRefillThe XMasRefill component whose ServerInit is distributing Christmas loot. Use it as a component reference if you need to inspect the entity it belongs to.

Return value

Return null to let the vanilla distribution run as usual. Returning any non-null object (for example true) cancels the repeating loot distribution and bell sound for this refill component; the original ServerInit method returns immediately without scheduling DistributeLoot or SendBells.

How it works

The hook fires inside XMasRefill.ServerInit, after the component has collected the list of active players and registered stockings and scheduled its cleanup timer. Immediately after the hook returns, the game would normally start the repeating DistributeLoot timer (roughly every 0.02s, first tick after 3s) and queue SendBells half a second later. That means this hook is the last point where you can stop the entire Christmas giveaway for that refill component.

xMasRefill is the component running the distribution; it is a plain XMasRefill reference, so you can use it to read transform.position or its owning entity if you need location context. Declaring the parameter as a base type such as BaseNetworkable or Component would make Oxide skip the call, because the argument is only dispatched when it matches your declared type.

On a normal Rust server with the holiday event active this runs when the XMas refill initializes. On servers that run custom loot or economy events, use it to suppress the vanilla drop and replace it with your own logic.

Example plugin: Suppress vanilla Christmas loot on specific servers

XmasLootBlock.cs
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;

namespace Oxide.Plugins
{
    [Info("Xmas Loot Block", "RustPluginGenerator", "1.0.0")]
    [Description("Cancels vanilla Christmas loot distribution based on config and permission.")]
    public class XmasLootBlock : RustPlugin
    {
        private const string PermBlock = "xmaslootblock.block";

        private PluginConfig config;

        private class PluginConfig
        {
            [JsonProperty("Suppress vanilla loot globally")]
            public bool SuppressGlobally { get; set; } = false;

            [JsonProperty("Suppress for permitted owners only")]
            public bool SuppressForPermittedOwners { get; set; } = 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>
            {
                ["Suppressed"] = "Vanilla Christmas loot distribution has been suppressed."
            }, 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(PermBlock, this);
        }

        private object OnXmasLootDistribute(XMasRefill xMasRefill)
        {
            if (xMasRefill == null) return null;

            if (config.SuppressGlobally)
            {
                PrintWarning(Msg("Suppressed"));
                return true;
            }

            if (!config.SuppressForPermittedOwners) return null;

            var entity = xMasRefill.GetComponent<BaseEntity>();
            if (entity == null || entity.OwnerID == 0) return null;

            if (permission.UserHasPermission(entity.OwnerID.ToString(), PermBlock))
            {
                PrintWarning(Msg("Suppressed"));
                return true;
            }

            return null;
        }
    }
}

The plugin registers a config flag and a permission, then checks them in OnXmasLootDistribute. If SuppressVanillaLoot is enabled and the player who owns the refill entity has the xmaslootblock.block permission, the hook returns true, which stops the vanilla DistributeLoot and SendBells invocations. Because the component's OwnerID may be zero on world-spawned objects, that path also honors the config flag. Config is validated on load; messages go through the language layer and broadcast a reminder when suppression kicks in via PrintWarning on startup only.

Common use cases

  • Replace vanilla Christmas loot with a custom drop system

    Return a non-null value to stop the built-in distribution and run your own timer that gives players themed items or rewards.

  • Disable the event entirely on PvP servers

    Return true unconditionally when a config flag is set, so no stockings or player giveaways happen during the holiday window.

  • Gate the giveaway by permission or team

    Inspect the refill's owning entity or OwnerID and cancel distribution for players who should not receive free holiday loot.

Pitfalls

  • The hook only fires from ServerInit

    It is not called for every individual loot drop, only once when the refill component initializes. Use OnXmasGiftsDistribute or OnXmasStockingFill for per-item logic.

  • Returning false still cancels

    Oxide treats any non-null return as a cancel here, so return false stops distribution same as return true. Return null to keep vanilla behavior.

  • Cancelling also skips bell sounds

    SendBells is scheduled inside the same conditional, so cancelling the loot distribution also removes the bell sound for that refill.

Build a plugin with OnXmasLootDistribute

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

Prompt: Replace vanilla Christmas loot with a custom drop system using the OnXmasLootDistribute 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 OnXmasLootDistribute

Generate