Skip to content
RustPluginGenerator

OnFuelCheck

OnFuelCheck is called when an EntityFuelSystem evaluates whether it currently has fuel, before the cached result is recalculated. Returning a bool overrides the result the game would otherwise compute.

Signature
object OnFuelCheck(EntityFuelSystem entityFuelSystem)

Parameters

Hook parameters
ParameterTypeDescription
entityFuelSystemEntityFuelSystemThe EntityFuelSystem instance whose fuel state is being queried, usually the fuel system of an oven, furnace, lantern, generator or vehicle. Use its owner entity to identify what is being checked.

Return value

Return null to let the game continue and set cachedHasFuel from the actual fuel amount via GetFuelAmount() > 0. Return a bool and that value is returned directly from HasFuel, bypassing the amount check; any non-bool return is ignored because the engine only accepts a bool result.

How it works

The hook fires inside EntityFuelSystem.HasFuel, which is the method that many fuel-burning entities call to decide whether they can run, burn or accept input. The call is gated by nextFuelCheckTime or the forceCheck argument, so it does not fire on every single query: the fuel system caches its answer and only re-checks periodically, and passing forceCheck (for example right after refuelling) forces a fresh call. The engine then runs your hook and, if you return a bool, uses that value as HasFuel's result and skips the normal GetFuelAmount() > 0 calculation.

The single parameter is the fuel system itself. From it you can reach the owning entity via entityFuelSystem.owner (a BaseEntity) to inspect its type, owner or building privilege, and you can read the real fuel amount with GetFuelAmount(). Declaring the parameter as a narrower type would be risky: Oxide only calls your hook when the argument matches the declared type, and the parameter here is always EntityFuelSystem, so keep it as-is. If you return null, the game recomputes cachedHasFuel from the actual fuel amount as usual. Avoid running expensive logic here: this hook can fire frequently for every active oven, furnace and generator on the server.

Example plugin: Keep furnaces burning during a free-fuel event

FreeFuelEvent.cs
using UnityEngine;
using System;
using Newtonsoft.Json;

namespace Oxide.Plugins
{
    [Info("Free Fuel Event", "RustPluginGenerator", "1.0.0")]
    [Description("Lets admins run a timed event where all fuel-burning entities report as fuelled.")]
    public class FreeFuelEvent : RustPlugin
    {
        private const string PermManage = "freefuelevent.manage";

        private class PluginConfig
        {
            [JsonProperty("Event duration seconds")]
            public float DurationSeconds { get; set; } = 300f;
        }

        private PluginConfig config;
        private bool eventActive;
        private Timer eventTimer;

        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(PermManage, this);
        }

        private object OnFuelCheck(EntityFuelSystem entityFuelSystem)
        {
            if (!eventActive || entityFuelSystem == null) return null;
            return true;
        }

        [ConsoleCommand("freefuelevent.start")]
        private void CmdStart(ConsoleSystem.Arg arg)
        {
            if (arg.Player() != null && !permission.UserHasPermission(arg.Player().UserIDString, PermManage))
            {
                arg.ReplyWith("You do not have permission to use this command.");
                return;
            }

            StartEvent();
            arg.ReplyWith($"Free fuel event started for {config.DurationSeconds} seconds.");
        }

        [ConsoleCommand("freefuelevent.stop")]
        private void CmdStop(ConsoleSystem.Arg arg)
        {
            if (arg.Player() != null && !permission.UserHasPermission(arg.Player().UserIDString, PermManage))
            {
                arg.ReplyWith("You do not have permission to use this command.");
                return;
            }

            StopEvent();
            arg.ReplyWith("Free fuel event stopped.");
        }

        private void StartEvent()
        {
            eventActive = true;

            if (eventTimer != null)
            {
                eventTimer.Destroy();
                eventTimer = null;
            }

            if (config.DurationSeconds > 0f)
            {
                eventTimer = timer.Once(config.DurationSeconds, StopEvent);
            }

            Server.Broadcast("Free fuel event is active: furnaces, lanterns and generators run without fuel.");
        }

        private void StopEvent()
        {
            eventActive = false;

            if (eventTimer != null)
            {
                eventTimer.Destroy();
                eventTimer = null;
            }

            Server.Broadcast("Free fuel event has ended.");
        }

        private void Unload()
        {
            if (eventTimer != null)
            {
                eventTimer.Destroy();
                eventTimer = null;
            }
        }
    }
}

The plugin lets admins run a timed event where every fuel-burning entity behaves as if it has fuel. It reads a DurationSeconds value from config and is toggled with the freefuel.start console command. While the event is active, OnFuelCheck returns true for any EntityFuelSystem, so HasFuel reports true regardless of the actual contents and furnaces, lanterns and generators keep running. Because the check can fire often, the hook avoids logging and only performs a single boolean check on the active flag. stop and a timer end the event, and Unload clears the timer.

Common use cases

  • Temporary no-fuel-needed events

    Make all furnaces, lanterns and generators run without consuming or holding fuel for a set time during a server event, then restore normal behaviour automatically.

  • VIP or permission fuel perks

    Return true for fuel systems whose owner entity has an authorised player with a specific permission, giving those players perpetual fuel while the check still reflects real amounts for everyone else.

  • Force-off selected fuel entities

    Return false for entities inside a disabled zone or of a certain type, so their fuel systems report no fuel and the entity stops running without touching stored items.

Pitfalls

  • The result is cached

    HasFuel only re-checks when the internal timer elapses or forceCheck is used, so toggling your override does not take effect instantly for every entity. Expect a short delay before entities respond.

  • Returning false does not drain fuel

    A false return only changes the answer HasFuel gives; it does not remove or consume fuel items. Real fuel stays in the container and resumes working once you stop overriding.

  • Called very often across the map

    Every active oven, furnace, lantern and vehicle fuel system can trigger this hook. Keep the body cheap, avoid lookups against large collections and never log inside it.

Build a plugin with OnFuelCheck

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

Prompt: Temporary no-fuel-needed events using the OnFuelCheck 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 OnFuelCheck

Generate