Skip to content
RustPluginGenerator

CanCheckFuel

CanCheckFuel is called when an EntityFuelSystem checks whether a player is close enough to open or use its fuel container. Returning a bool overrides the resulting range check.

Signature
object CanCheckFuel(EntityFuelSystem entityFuelSystem, StorageContainer fuelContainer, BasePlayer player)

Parameters

Hook parameters
ParameterTypeDescription
entityFuelSystemEntityFuelSystemThe EntityFuelSystem instance whose interaction range is being checked. It belongs to the entity (e.g. a fuel generator or vehicle) that would consume the fuel.
fuelContainerStorageContainerThe StorageContainer returned by the fuel system's GetFuelContainer(), or null when no fuel container could be resolved.
playerBasePlayerThe BasePlayer for whom the fuel interaction range is being evaluated.

Return value

Return a bool to replace the game's own range check: true allows the interaction, false blocks it. Return null (or nothing) to let the original distance/range logic decide.

How it works

This hook fires inside EntityFuelSystem.IsInFuelInteractionRange(BasePlayer), which the game calls before allowing a player to interact with the fuel container of a fuel-powered entity. The method first resolves the fuel container via GetFuelContainer(), then calls the hook with the fuel system, that container and the player.

Use player to check permissions, distance, team membership or building authorization. fuelContainer tells you which storage is involved (and may be null, so guard it). entityFuelSystem lets you reach the owning entity if you need distance or ownership data.

Declaring player as a more specific subtype works the same as elsewhere: Oxide only calls your method when the argument is an instance of the declared type. Leave the other parameters as-is. Because the check can run repeatedly while a player stands near a fuelled entity, keep the method cheap and do not log inside it.

Example plugin: Require a permission to open fuel containers

FuelAccessGate.cs
using System;
using Newtonsoft.Json;
using Oxide.Core;

namespace Oxide.Plugins
{
    [Info("Fuel Access Gate", "RustPluginGenerator", "1.0.0")]
    [Description("Restricts access to fuel containers to players holding a permission")]
    public class FuelAccessGate : RustPlugin
    {
        private const string PermUse = "fuelaccessgate.use";

        private PluginConfig config;

        private class PluginConfig
        {
            [JsonProperty("Allow admins to bypass")]
            public bool AdminBypass { 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);

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

        private object CanCheckFuel(EntityFuelSystem entityFuelSystem, StorageContainer fuelContainer, BasePlayer player)
        {
            if (player == null || fuelContainer == null || entityFuelSystem == null)
                return null;

            if (config.AdminBypass && player.IsAdmin)
                return null;

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

            return false;
        }
    }
}

The plugin registers a single permission and overrides CanCheckFuel. When a player approaches a fuelled entity's fuel container, the hook checks whether they hold the permission. Players without it, and admins who are not exempted, are denied by returning false, which stops the interaction without touching the container contents. When the permission is present the hook returns null so the game's normal range logic still applies and nothing else changes. Config allows toggling admin bypass. The hook stays lightweight: one permission lookup and a config read, no logging and no allocations.

Common use cases

  • VIP-only refuelling

    Gate fuel container access behind a permission so only paying players or specific ranks can refuel generators and vehicles.

  • Raid-protection on fuel

    Deny access to fuel containers belonging to entities you control, or when the player lacks building authorization at the entity's position.

  • Event arenas

    During a custom event, block all fuel interactions except for whitelisted players so participants cannot refuel mid-round.

Pitfalls

  • Returning false blocks the whole interaction

    A false return replaces the entire range check, so the player cannot use the fuel container at all until your condition allows it. Make sure blocked players get feedback elsewhere.

  • fuelContainer can be null

    GetFuelContainer() may resolve to null, so always null-check the parameter before reading inventory, entityOwner or similar members.

  • Runs frequently

    The check can be evaluated many times while a player is near a fuelled entity. Avoid logging, LINQ or per-call allocations in this hook.

Build a plugin with CanCheckFuel

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

Prompt: VIP-only refuelling using the CanCheckFuel 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 CanCheckFuel

Generate