Skip to content
RustPluginGenerator

OnResearchCostDetermine

OnResearchCostDetermine is called when the Research Table calculates how much scrap a blueprint research will cost, letting you override the returned amount.

Signature
object OnResearchCostDetermine(Item item)

Parameters

Hook parameters
ParameterTypeDescription
itemItemThe item or item definition being researched. When the hook fires from the item path it is an Item instance; when fired from the definition path it is an ItemDefinition. Cast or type-check to know which.

Return value

Return an int to set the scrap cost directly: the injected check if (obj is int) returns it immediately and the vanilla calculation never runs. Return null (or any non-int) to fall through to the original ScrapForResearch logic so the default price is used.

How it works

The hook fires from ResearchTable.ScrapForResearch, which the game calls before a player performs a research to work out the scrap price of the resulting blueprint. It is invoked twice by the same static method: once with an Item (the item the player put in the research slot, path 1) and, as a fallback, once with its ItemDefinition (path 2) when the first call did not return an int. Returning a non-null int from your hook short-circuits the original method, so the game uses your number and skips the vanilla calculation. Return null (or anything that is not an int) to let vanilla pricing apply.

Declaring Item narrows the hook to the item path only; declare ItemDefinition to catch the definition fallback. Because both use the same hook name, a single class can only host one signature — returning an int from either is enough to set the price. Values are scrap counts, so a negative or zero return effectively makes research free.

Other signatures

Oxide also calls OnResearchCostDetermine from other places in the game with these parameter types. Declare the overload you need, or several:

  • object OnResearchCostDetermine(ItemDefinition info)

Example plugin: Flat research price with VIP discount

ResearchCostFlat.cs
using System.Linq;
using System;
using Newtonsoft.Json;
using Oxide.Core;

namespace Oxide.Plugins
{
    [Info("Research Cost Flat", "RustPluginGenerator", "1.0.0")]
    [Description("Replaces vanilla research scrap cost with a configurable flat price and an optional permission discount.")]
    public class ResearchCostFlat : RustPlugin
    {
        private const string PermDiscount = "researchcostflat.discount";

        private PluginConfig config;

        private class PluginConfig
        {
            [JsonProperty("Flat scrap cost")]
            public int FlatCost { get; set; } = 75;

            [JsonProperty("Discount percent for permitted players")]
            public int DiscountPercent { get; set; } = 50;
        }

        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);

        private void Init()
        {
            permission.RegisterPermission(PermDiscount, this);
        }

        private object OnResearchCostDetermine(Item item)
        {
            if (item == null || config == null) return null;

            int cost = GetPrice(item);
            if (cost < 0) return null;
            return (int)cost;
        }

        private int GetPrice(Item item)
        {
            if (config.FlatCost < 1) return -1;

            BasePlayer owner = item.GetOwnerPlayer();
            if (owner != null && owner.IsConnected && !owner.IsNpc
                && permission.UserHasPermission(owner.UserIDString, PermDiscount))
            {
                double discount = 1.0 - Math.Min(100, Math.Max(0, config.DiscountPercent)) / 100.0;
                return (int)Math.Round(config.FlatCost * discount);
            }

            return config.FlatCost;
        }
    }
}

The plugin replaces vanilla research pricing with one configurable flat cost and gives players with a permission a percentage discount off that cost. OnResearchCostDetermine receives the item, checks whether its owner has the researchcostflat.discount permission, and returns either the discounted or full flat scrap amount. Because it returns an int, the game skips its own scrap calculation entirely. All values come from the config file, so admins can tune the economy without recompiling, and returning null from GetPrice when config is invalid leaves the default price intact.

Common use cases

  • Flat research economy

    Push every blueprint to the same scrap cost so server economy is uniform, regardless of the item's tier.

  • VIP or rank discounts

    Return a reduced int for players holding a permission, giving donors cheaper research without touching vanilla values.

  • Event pricing

    Temporarily raise or lower research costs during a weekend event by flipping a config flag and returning a different int.

Pitfalls

  • Both signatures cannot coexist

    Item and ItemDefinition share the hook name. A class can only declare one of them, so pick whichever path your override needs — returning int from the Item path is enough because it short-circuits before the definition fallback.

  • Non-int returns are ignored

    Only a boxed int short-circuits. Returning 0L, a float, or true passes through to vanilla pricing, so cast explicitly with (int) on your result.

  • Zero makes research free

    Returning 0 or a negative int gives free (or refunded) research. Guard against bad config values so a typo does not wipe your scrap economy.

Build a plugin with OnResearchCostDetermine

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

Prompt: Flat research economy using the OnResearchCostDetermine 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 OnResearchCostDetermine

Generate