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
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.
{
"Enabled": true,
"RefundFuel": true,
"AffectedPrefabs": [
"minicopter.entity",
"scraptransporthelicopter.entity",
"modularcar",
"rowboat",
"rhib"
]
}Commands and permissions
| Command | What it does | Permission |
|---|---|---|
/fuelfree | Reports whether unlimited vehicle fuel is currently enabled. | fuelfreevehicles.use |
fuelfreevehicles.toggle | Turns the feature on or off at runtime and saves the config. | Everyone |
| Permission | Grants |
|---|---|
fuelfreevehicles.use | Vehicles driven by players with this permission do not consume fuel. |
fuelfreevehicles.admin | Allows players to run the fuelfreevehicles.toggle console command from the client. |
How the code works
Config: master switch, refund flag and prefab list
PluginConfighas three fields:Enabled(runtime switch),RefundFuel(whether the burned fuel is put back), andAffectedPrefabs, a string list defaulting tominicopter.entity,scraptransporthelicopter.entity,modularcar,rowboatandrhib.LoadDefaultConfigbuilds fresh defaults, andLoadConfigreads the file, warns once and falls back to defaults if parsing fails.IsVehiclePrefabcompares each entry toShortPrefabNamewithStringComparison.OrdinalIgnoreCase, so case never matters.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 withnullwhen the feature is off, refunds are disabled,oven,burnableoroven.inventoryis null, the entity is destroyed, orIsVehiclePrefab(oven.ShortPrefabName)is false. Returningnullleaves normal vanilla fuel consumption untouched.Resolving the driver from the engine
FindDriverstarts at the oven and loops at most four times: it returns the entity itself if it is aBasePlayer, otherwise checksBaseVehicle.GetDriver()when the entity is aBaseVehicleand returns that player if present, otherwise steps up viaGetParentEntity(). If nothing is found the vehicle is treated as unmanned and the hook returnsnull, so idle vehicles keep draining fuel.Permission check and the fuel refund
After the driver is found, NPCs are rejected with
driver.IsNpcand the permission is tested withpermission.UserHasPermission(driver.UserIDString, PermUse). The refund amount isMathf.RoundToInt(burnable.fuelAmount). The plugin first scansoven.inventory.itemListfor a stack whoseitem.info.itemidequals the consumedfuel.info.itemidand has room underMaxStackable(), adds the smaller of the room and the refund, and callsitem.MarkDirty().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 withMoveToContainer(oven.inventory); if that fails the item is removed, andoven.inventory.MarkDirty()is called afterwards. Both paths returnnull, so vanilla consumption runs against a tank that has just been topped back up.Status command and runtime toggle
/fuelfreeis a[ChatCommand]that checksPermUseand prints either the enabled or disabled status line.fuelfreevehicles.toggleis a[ConsoleCommand]: whenarg.Player()is not null it verifiesPermAdmin, flipsconfig.Enabled, callsSaveConfig, replies to that player and broadcasts the new state withServer.Broadcast. A null player (RCON or server console) skips the permission check and receives the reply viaarg.ReplyWith.
Install it on your server
Save FuelFreeVehicles.cs
Keep the file name exactly as the class name. Oxide matches them.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.Edit the config if you want
On first load the default config is written tooxide/config/FuelFreeVehicles.json(Carbon:carbon/configs/FuelFreeVehicles.json). After editing, reload it:oxide.reload FuelFreeVehicles c.reload FuelFreeVehicles # CarbonGrant the permission
Give it to every player, or swapdefaultfor a group such asvip: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 versionFuel discount instead of free fuel
Returns half of the consumed fuel so tanks drain slower but still drain.
Generate this versionTeam-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.
Edit the prompt on the next screen. 2 free plugins a month, no card.
More vehicles plugins
- Car spawn commandAdds a /car command that spawns a modular car with configured modules in front of the player, enforcing a permission, a spawn cooldown and a strictโฆOnEntityKill
- Horse spawn commandAdds a /horse command that spawns a ridable horse beside the player, tracks one horse per player, removes that player's previous horse and enforcesโฆOnServerInitializedOnEntityKill
- No vehicle decayScales or disables decay damage on minicopters, boats, horses and modular cars per vehicle type, optionally only while inside a tool cupboard radius.OnEntityTakeDamage
Last updated Oct 26, 2026.
Customize unlimited vehicle fuel
Customize