Skip to content
RustPluginGenerator

CanBeAwardedAdventGift

CanBeAwardedAdventGift is called when an AdventCalendar checks whether it should award today's present to a player. Returning a bool overrides the calendar's own answer.

Signature
object CanBeAwardedAdventGift(AdventCalendar adventCalendar, BasePlayer player)

Parameters

Hook parameters
ParameterTypeDescription
adventCalendarAdventCalendarThe AdventCalendar entity that is running the gift check. Use it for position, owner or network ID when you need to scope a rule to one calendar.
playerBasePlayerThe BasePlayer the calendar is trying to hand today's gift to. May be null in theory, so null-check before reading UserIDString or position.

Return value

Returning null (or a non-bool value) lets the original reward-history check decide. Returning a bool stops the original code path: the value is negated for the game's answer, so true blocks the gift and false forces the calendar to consider a gift still available.

How it works

The hook fires inside AdventCalendar.WasAwardedTodaysGift, which the game calls when a player interacts with (opens or loots) an advent calendar and the server needs to decide whether a gift is due. The original code looks at the calendar's per-player reward history and the current day, then returns true if the player still has a gift for today.

The patched call passes the calendar entity and the player. Returning a bool inverts cleanly into the game's answer: the patched code returns !(bool)obj, so a true from your plugin makes the game treat the player as already awarded, and a false means a gift is still available. Returning null leaves the vanilla history check untouched.

Use this hook to gate advent gifts by permission, group, team, playtime or a custom event flag. Because the check runs per interaction, keep it cheap: no data file reads or network calls. The player and the calendar can both be useful for distance or ownership rules.

Example plugin: Limit advent gifts to a permission group

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

namespace Oxide.Plugins
{
    [Info("Advent Gift Permission", "RustPluginGenerator", "1.0.0")]
    [Description("Restricts advent calendar gifts to players with a permission")]
    public class AdventGiftPermission : RustPlugin
    {
        private const string PermUse = "adventgiftpermission.use";

        private PluginConfig config;

        private class PluginConfig
        {
            [JsonProperty("Require permission to receive advent gifts")]
            public bool RequirePermission = 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>
            {
                ["NoPermission"] = "You need the advent calendar permission to claim today's gift."
            }, 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(PermUse, this);
        }

        private object CanBeAwardedAdventGift(AdventCalendar adventCalendar, BasePlayer player)
        {
            if (!config.RequirePermission) return null;
            if (player == null) return null;

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

            // Returning true tells the calendar the gift is already awarded.
            return true;
        }
    }
}

The plugin registers a single permission, adventgiftpermission.use, and lets admins choose via config whether an unpermitted player is blocked outright or just forced to wait. In CanBeAwardedAdventGift it null-checks the player, reads the permission once and returns true (block the gift) when the player lacks access. A player with permission gets null, so the vanilla day/history logic runs normally and the gift is handed out as usual. The config uses a nested PluginConfig class with a default that blocks access, and messages go through the language file so the block notice can be edited without recompiling.

Common use cases

  • VIP-only advent calendars

    Require a permission before a player can claim daily presents, so donor or event groups get a seasonal bonus while everyone else waits.

  • Disable advent gifts on a custom event server

    Return true unconditionally to turn off advent calendar rewards when you run a modded event such as a wipe-day hunt instead.

  • Tie gifts to playtime or team

    Check the player's team or session data and block the gift until they meet your server's activity requirement for the day.

Pitfalls

  • The bool is inverted

    The patched method returns !(bool)obj, so returning true blocks the gift rather than granting one. Returning false is what makes the game treat a gift as still available.

  • Runs on every calendar interaction

    The hook fires each time a player checks the calendar, not just once per day. Avoid data file reads, Puts or PrintWarning calls inside it.

  • Do not break the daily reset

    Force-returning false for a player who already claimed today's gift can let them keep claiming. Combine custom rules with the player's reward history rather than overriding always.

Build a plugin with CanBeAwardedAdventGift

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

Prompt: VIP-only advent calendars using the CanBeAwardedAdventGift 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 CanBeAwardedAdventGift

Generate