Skip to content
RustPluginGenerator

How to make a Rust unlimited vehicle fuel plugin (permission based)

Stops fuel drain on vehicles driven by players with a permission, limited to the vehicle types listed in config. It uses the OnFuelConsume hook to refund the fuel the engine is about to burn.

Every vehicle in Rust burns low grade fuel while it runs, so long patrol sessions and taxi setups eat through fuel quickly. The usual workaround is handing out endless fuel items, but that also fuels furnaces, quarries and generators. A cleaner approach is to intercept the moment a vehicle engine consumes fuel and give that unit back, only for the players and vehicle prefabs you choose.

The plugin below hooks OnFuelConsume, checks whether the burning entity's ShortPrefabName is in the configured list, walks the parent chain to find a mounted player, and tests their permission. If both checks pass, the consumed amount is added back to a matching stack in the engine's inventory, or a fresh item is created when no stack has room. A chat command reports status and a console command toggles the feature at runtime.

The plugin code

FuelFreeVehicles.cs
using System.Linq;
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("FuelFreeVehicles", "RustPluginGenerator", "1.0.0")]
    [Description("Permitted players do not consume fuel in configured vehicles.")]
    public class FuelFreeVehicles : RustPlugin
    {
        private const string PermUse = "fuelfreevehicles.use";
        private const string PermAdmin = "fuelfreevehicles.admin";

        private PluginConfig config;

        private class PluginConfig
        {
            [JsonProperty("Enabled")]
            public bool Enabled = true;

            [JsonProperty("RefundFuel")]
            public bool RefundFuel = true;

            [JsonProperty("AffectedPrefabs")]
            public List<string> AffectedPrefabs = new List<string>
            {
                "minicopter.entity",
                "scraptransporthelicopter.entity",
                "modularcar",
                "rowboat",
                "rhib"
            };
        }

        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>
            {
                ["StatusOn"] = "Unlimited vehicle fuel is ENABLED. You have the driver permission: {0}.",
                ["StatusOff"] = "Unlimited vehicle fuel is DISABLED.",
                ["Toggled"] = "Unlimited vehicle fuel is now {0}.",
                ["NoPermission"] = "You do not have permission to use this command."
            }, 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);
            permission.RegisterPermission(PermAdmin, this);
        }

        private bool IsVehiclePrefab(string shortPrefabName)
        {
            if (string.IsNullOrEmpty(shortPrefabName) || config.AffectedPrefabs == null) return false;
            foreach (var prefab in config.AffectedPrefabs)
            {
                if (string.Equals(prefab, shortPrefabName, StringComparison.OrdinalIgnoreCase)) return true;
            }
            return false;
        }

        private object OnFuelConsume(BaseOven oven, Item fuel, ItemModBurnable burnable)
        {
            if (!config.Enabled || !config.RefundFuel) return null;
            if (oven == null || burnable == null || oven.inventory == null) return null;
            if (oven.IsDestroyed || !IsVehiclePrefab(oven.ShortPrefabName)) return null;

            var driver = FindDriver(oven);
            if (driver == null || driver.IsNpc) return null;
            if (!permission.UserHasPermission(driver.UserIDString, PermUse)) return null;

            var fuelDef = fuel?.info;
            if (fuelDef == null) return null;

            int amount = Mathf.RoundToInt(burnable.fuelAmount);
            if (amount <= 0) return null;

            foreach (var item in oven.inventory.itemList)
            {
                if (item == null || item.info == null) continue;
                if (item.info.itemid != fuelDef.itemid || item.amount >= item.MaxStackable()) continue;
                int room = item.MaxStackable() - item.amount;
                if (room <= 0) continue;
                item.amount += Mathf.Min(room, amount);
                item.MarkDirty();
                return null;
            }

            var created = ItemManager.CreateByItemID(fuelDef.itemid, amount);
            if (created != null && !oven.inventory.IsFull())
            {
                if (!created.MoveToContainer(oven.inventory)) created.Remove();
                oven.inventory.MarkDirty();
            }

            return null;
        }

        private BasePlayer FindDriver(BaseEntity entity)
        {
            var current = entity;
            for (int i = 0; i < 4 && current != null; i++)
            {
                if (current is BasePlayer player) return player;
                if (current is BaseVehicle vehicle)
                {
                    var mounted = vehicle.GetDriver();
                    if (mounted != null) return mounted;
                }
                current = current.GetParentEntity();
            }
            return null;
        }

        [ChatCommand("fuelfree")]
        private void CmdFuelFree(BasePlayer player, string command, string[] args)
        {
            if (player == null) return;
            if (!permission.UserHasPermission(player.UserIDString, PermUse))
            {
                player.ChatMessage(Msg("NoPermission", player.UserIDString));
                return;
            }

            if (!config.Enabled)
            {
                player.ChatMessage(Msg("StatusOff", player.UserIDString));
                return;
            }

            player.ChatMessage(Msg("StatusOn", player.UserIDString, "yes"));
        }

        [ConsoleCommand("fuelfreevehicles.toggle")]
        private void CcmdToggle(ConsoleSystem.Arg arg)
        {
            var player = arg.Player();
            if (player != null && !permission.UserHasPermission(player.UserIDString, PermAdmin))
            {
                arg.ReplyWith(Msg("NoPermission", player.UserIDString));
                return;
            }

            config.Enabled = !config.Enabled;
            SaveConfig();

            var state = config.Enabled ? "enabled" : "disabled";
            var message = Msg("Toggled", null, state);
            if (player != null) player.ChatMessage(message);
            else arg.ReplyWith(message);
            Server.Broadcast(message);
        }

        private void Unload()
        {
            SaveConfig();
        }
    }
}

Hooks used: OnFuelConsume

Config file

Created automatically on first load at oxide/config/FuelFreeVehicles.json.

FuelFreeVehicles.json
{
  "Enabled": true,
  "RefundFuel": true,
  "AffectedPrefabs": [
    "minicopter.entity",
    "scraptransporthelicopter.entity",
    "modularcar",
    "rowboat",
    "rhib"
  ]
}

Commands and permissions

Chat and console commands
CommandWhat it doesPermission
/fuelfreeReports whether unlimited vehicle fuel is currently enabled.fuelfreevehicles.use
fuelfreevehicles.toggleTurns the feature on or off at runtime and saves the config.Everyone
Permissions
PermissionGrants
fuelfreevehicles.useVehicles driven by players with this permission do not consume fuel.
fuelfreevehicles.adminAllows players to run the fuelfreevehicles.toggle console command from the client.

How the code works

  1. Config: master switch, refund flag and prefab list

    PluginConfig has three fields: Enabled (runtime switch), RefundFuel (whether the burned fuel is put back), and AffectedPrefabs, a string list defaulting to minicopter.entity, scraptransporthelicopter.entity, modularcar, rowboat and rhib. LoadDefaultConfig builds fresh defaults, and LoadConfig reads the file, warns once and falls back to defaults if parsing fails. IsVehiclePrefab compares each entry to ShortPrefabName with StringComparison.OrdinalIgnoreCase, so case never matters.

  2. The OnFuelConsume entry point

    object OnFuelConsume(BaseOven oven, Item fuel, ItemModBurnable burnable) fires on the entity that is about to burn the item. The method returns early with null when the feature is off, refunds are disabled, oven, burnable or oven.inventory is null, the entity is destroyed, or IsVehiclePrefab(oven.ShortPrefabName) is false. Returning null leaves normal vanilla fuel consumption untouched.

  3. Resolving the driver from the engine

    FindDriver starts at the oven and loops at most four times: it returns the entity itself if it is a BasePlayer, otherwise checks BaseVehicle.GetDriver() when the entity is a BaseVehicle and returns that player if present, otherwise steps up via GetParentEntity(). If nothing is found the vehicle is treated as unmanned and the hook returns null, so idle vehicles keep draining fuel.

  4. Permission check and the fuel refund

    After the driver is found, NPCs are rejected with driver.IsNpc and the permission is tested with permission.UserHasPermission(driver.UserIDString, PermUse). The refund amount is Mathf.RoundToInt(burnable.fuelAmount). The plugin first scans oven.inventory.itemList for a stack whose item.info.itemid equals the consumed fuel.info.itemid and has room under MaxStackable(), adds the smaller of the room and the refund, and calls item.MarkDirty().

  5. Fallback when no stack has room

    If no existing stack can take the fuel, the plugin calls ItemManager.CreateByItemID(fuel.info.itemid, amount). The new item is placed with MoveToContainer(oven.inventory); if that fails the item is removed, and oven.inventory.MarkDirty() is called afterwards. Both paths return null, so vanilla consumption runs against a tank that has just been topped back up.

  6. Status command and runtime toggle

    /fuelfree is a [ChatCommand] that checks PermUse and prints either the enabled or disabled status line. fuelfreevehicles.toggle is a [ConsoleCommand]: when arg.Player() is not null it verifies PermAdmin, flips config.Enabled, calls SaveConfig, replies to that player and broadcasts the new state with Server.Broadcast. A null player (RCON or server console) skips the permission check and receives the reply via arg.ReplyWith.

Install it on your server

  1. Save FuelFreeVehicles.cs

    Keep the file name exactly as the class name. Oxide matches them.
  2. Upload it to the plugins folder

    Oxide: oxide/plugins/. Carbon: carbon/plugins/. The server compiles and loads it within a few seconds, no restart needed.
  3. Edit the config if you want

    On first load the default config is written to oxide/config/FuelFreeVehicles.json (Carbon: carbon/configs/FuelFreeVehicles.json). After editing, reload it:oxide.reload FuelFreeVehicles c.reload FuelFreeVehicles # Carbon
  4. Grant the permission

    Give it to every player, or swap default for a group such as vip:oxide.grant group default fuelfreevehicles.use c.grant group default fuelfreevehicles.use # Carbon

Variations

Each one opens the generator with a ready prompt you can tweak.

  • Only minicopters and scrap helicopters

    Restricts the feature to flight vehicles so ground convoys still burn fuel.

    Generate this version
  • Fuel discount instead of free fuel

    Returns half of the consumed fuel so tanks drain slower but still drain.

    Generate this version
  • Team-based fuel exemption

    Applies the perk to the whole team of permitted players instead of individuals.

    Generate this version

FAQ

Does this also stop fuel use in furnaces and quarries?

No. The hook fires for every BaseOven, but the plugin only acts when ShortPrefabName matches an entry in AffectedPrefabs. Furnaces, campfires, refineries and quarries are not listed by default, so they keep burning fuel normally. Leave AffectedPrefabs limited to actual vehicle engine prefabs.

How do I install it on Oxide or Carbon?

Drop the .cs file into oxide/plugins, or the Carbon plugins folder, and let it compile. Edit oxide/config/FuelFreeVehicles.json to list the prefabs you want, then reload the plugin or restart the server. Grant fuelfreevehicles.use with oxide.grant user <steamid> fuelfreevehicles.use.

What prefab names should I put in the list?

Use the engine short prefab names already in the defaults, such as minicopter.entity, scraptransporthelicopter.entity, modularcar, rowboat and rhib. To find one, inspect the vehicle's ShortPrefabName with admin tools. Matching in IsVehiclePrefab is case-insensitive, so exact casing is not required.

Why does an unmanned vehicle still burn fuel?

Fuel is only refunded when FindDriver locates a mounted player in the parent chain. Vehicles left running without a driver keep draining, because no permission holder is responsible. This keeps parked, looted or NPC-controlled vehicles behaving normally and avoids giving the server free fuel anywhere.

Does the fuel gauge still move?

With RefundFuel enabled the tank is topped back up on the same tick the fuel would be consumed, so the gauge stays near full. Each encounter touches the inventory and calls MarkDirty(). Setting RefundFuel to false makes the hook return immediately without touching oven.inventory at all.

Customize it for your server

Change the reward, add a cooldown, restrict it to VIPs. Start from this prompt and edit anything.

Prompt: Create an Oxide Rust plugin called FuelFreeVehicles with config Enabled, RefundFuel and AffectedPrefabs (minicopter.entity, scraptransporthelicopter.entity, modularcar, rowboat, rhib), using OnFuelConsume to refund fuel for permitted mounted drivers, plus /fuelfree and fuelfreevehicles.toggle.
Customize for my server

Edit the prompt on the next screen. 2 free plugins a month, no card.

Last updated Oct 26, 2026.

Customize unlimited vehicle fuel

Customize