Skip to content
RustPluginGenerator

OnPlayerStudyBlueprint

OnPlayerStudyBlueprint is called when a player uses a blueprint item to learn a recipe, right after the game checks whether the blueprint is already unlocked. Returning a non-null value cancels the study.

Signature
object OnPlayerStudyBlueprint(BasePlayer player, Item item)

Parameters

Hook parameters
ParameterTypeDescription
playerBasePlayerThe BasePlayer who triggered the study action by using a blueprint item from their inventory. Null-check before use.
itemItemThe blueprint Item being studied. Its amount matters: when greater than one, the game consumes only a single unit after the hook allows it.

Return value

Returning null (or letting the method fall through) lets the game continue and unlock the blueprint. Returning any non-null object stops the study path, so the blueprint is not learned and the item is not consumed.

How it works

The hook fires inside ItemModStudyBlueprint.ServerCommand, the code path that runs when a player activates a blueprint item (for example a blueprint in the belt or inventory). The game first checks IsBlueprintUnlocked for the player and the target recipe; only when that check fails does it call OnPlayerStudyBlueprint. So the hook only sees attempts to learn a blueprint the player does not already know.

player is the studying player and item is the blueprint item itself. From item.info you get the shortname and display name of the item definition, and item.amount tells you how many blueprints are stacked in that slot. After the hook returns without a value, the game decrements or removes the item and unlocks the recipe.

There is a single injection site, so the hook is narrow and reliable: one call per study attempt. Returning any non-null object stops the original method before the item is consumed, which makes this the correct place to block blueprint learning. You do not need a more specific parameter type here because the game already passes exact BasePlayer and Item instances.

Example plugin: Require permission before studying blueprints

BlueprintStudyPermission.cs
using System;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Oxide.Plugins
{
    [Info("Blueprint Study Permission", "RustPluginGenerator", "1.0.0")]
    [Description("Restricts blueprint studying to players who hold a permission.")]
    public class BlueprintStudyPermission : RustPlugin
    {
        private const string PermUse = "blueprintstudypermission.use";

        private PluginConfig config;

        private class PluginConfig
        {
            [JsonProperty("Allow admins to bypass")]
            public bool AllowAdmins { get; set; } = true;

            [JsonProperty("Bypass when server has no permission users")]
            public bool AllowWhenNobodyHasPermission { 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>
            {
                ["Blocked"] = "You do not have permission to study blueprints.",
                ["Allowed"] = "You are allowed to study blueprints.",
                ["Help"] = "Usage: /bpstudy status - shows whether you can study blueprints."
            }, 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);
        }

        [ChatCommand("bpstudy")]
        private void CmdBpStudy(BasePlayer player, string command, string[] args)
        {
            if (player == null) return;

            string key = CanStudy(player) ? "Allowed" : "Blocked";
            player.ChatMessage(Msg(key, player.UserIDString));
        }

        private bool CanStudy(BasePlayer player)
        {
            if (config.AllowAdmins && player.IsAdmin) return true;
            return permission.UserHasPermission(player.UserIDString, PermUse);
        }

        private object OnPlayerStudyBlueprint(BasePlayer player, Item item)
        {
            if (player == null || item == null) return null;

            if (CanStudy(player)) return null;

            player.ChatMessage(Msg("Blocked", player.UserIDString));
            return true;
        }
    }
}

The plugin registers a single permission, blueprintstudypermission.use, and checks it inside OnPlayerStudyBlueprint. Players with the permission fall through the hook (return null) and learn blueprints normally. Players without it get a localised chat message and the hook returns a non-null object, which makes the game stop before it consumes the blueprint, so the item stays in their inventory. Admins bypass the check via player.IsAdmin so server staff can still test recipes. The permission is registered in Init, the message text lives in the language file, and a quick chat command lets players check their current status.

Common use cases

  • Gate blueprint learning behind a permission or group

    Only allow members of a VIP group or a specific permission to study blueprints, blocking everyone else with a message.

  • Limit blueprints by progression

    Compare the blueprint's shortname against a configurable allowlist and block recipes the server wants players to discover through other means.

  • Log or audit recipe unlocks

    Record which player learned which recipe and when, without printing to console during the hook; write into a data file or notify a monitoring plugin.

Pitfalls

  • The hook only runs for locked recipes

    If the player already knows the blueprint, IsBlueprintUnlocked short-circuits and OnPlayerStudyBlueprint never fires, so you cannot use it to detect every blueprint use.

  • Returning a truthy object blocks the study

    Any non-null return value cancels the action, not just true. Return null explicitly when you want the default behaviour to run.

  • Refund and UI state are not handled by the hook

    Blocking the study keeps the original item in place, but if you do anything custom (moving items, granting rewards) do it in the hook body and remember the game will not run its consumption code when you return non-null.

Build a plugin with OnPlayerStudyBlueprint

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

Prompt: Gate blueprint learning behind a permission or group using the OnPlayerStudyBlueprint 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 OnPlayerStudyBlueprint

Generate