Failed to compile: The name 'entity' does not exist in the current context | Line: 76, Pos: 8Not An Issue

SimpleNoVehicleFuel - Failed to compile: The name 'entity' does not exist in the current context | Line: 76, Pos: 8

I don't know if you want to do it, but add permissons into the plugin for each vehicle...

Thank You!

On my server I block some vehicles from using free fuel, so I think I fixed it with thsi one...

 if (vehicle is Minicopter || vehicle.PrefabName.Contains("attackhelicopter") || vehicle.PrefabName.Contains("scraptransporthelicopter"))
            {
                return;
            }
using System.Linq;

namespace Oxide.Plugins
{
    [Info("Simple No Vehicle Fuel", "Mabel", "1.0.7")]
    [Description("Removes requirement of fuel in all vehicles")]
    public class SimpleNoVehicleFuel : RustPlugin
    {
        #region Oxide Hooks

        private void Init()
        {
            Unsubscribe(nameof(OnEntitySpawned));
        }

        private void OnServerInitialized()
        {
            Subscribe(nameof(OnEntitySpawned));

            foreach (var entity in BaseNetworkable.serverEntities)
            {
                if (entity is BaseVehicle vehicle)
                {
                    ModifyVehicle(vehicle);
                }
                else if (entity is HotAirBalloon balloon)
                {
                    ModifyBalloon(balloon);
                }
            }
        }

        private void Unload()
        {
            foreach (var entity in BaseNetworkable.serverEntities)
            {
                if (entity is BaseVehicle vehicle)
                {
                    ResetVehicle(vehicle);
                }
                else if (entity is HotAirBalloon balloon)
                {
                    ResetBalloon(balloon);
                }
            }
        }

        private void OnEntitySpawned(BaseVehicle vehicle)
        {
            NextTick(() =>
            {
                if (vehicle.IsValid())
                {
                    ModifyVehicle(vehicle);
                }
            });
        }

        private void OnEntitySpawned(HotAirBalloon balloon)
        {
            NextTick(() =>
            {
                if (balloon.IsValid())
                {
                    ModifyBalloon(balloon);
                }
            });
        }

        #endregion

        #region Core

        private void ModifyVehicle(BaseVehicle vehicle)
        {
            if (vehicle is Minicopter || vehicle.PrefabName.Contains("attackhelicopter") || vehicle.PrefabName.Contains("scraptransporthelicopter"))
            {
                return;
            }
			
            var fuelSystem = vehicle.GetFuelSystem() as EntityFuelSystem;
            var container = fuelSystem?.fuelStorageInstance.Get(true);
            if (container == null)
            {
                container = vehicle.GetComponentsInChildren<StorageContainer>().FirstOrDefault(x => x.inventory.onlyAllowedItems != null);
            }

            if (container == null)
            {
                return;
            }

            var item = container.inventory.GetSlot(0);
            if (item == null)
            {
                item = ItemManager.Create(container.inventory.onlyAllowedItems.FirstOrDefault());
                if (item == null)
                {
                    return;
                }
                item.MoveToContainer(container.inventory);
            }

            item.amount = 200;
            item.skin = 12345;
            item.OnDirty += item1 => Refill(item1);
            item.SetFlag(global::Item.Flag.IsLocked, true);
            container.dropsLoot = false;
            container.inventory.SetFlag(ItemContainer.Flag.IsLocked, true);
            container.SetFlag(BaseEntity.Flags.Locked, true);
        }

        private void ModifyBalloon(HotAirBalloon balloon)
        {
            var fuelSystem = balloon.GetFuelSystem() as EntityFuelSystem;
            var container = fuelSystem?.fuelStorageInstance.Get(true);
            if (container == null)
            {
                container = balloon.GetComponentsInChildren<StorageContainer>().FirstOrDefault(x => x.inventory.onlyAllowedItems != null);
            }

            if (container == null)
            {
                return;
            }

            var item = container.inventory.GetSlot(0);
            if (item == null)
            {
                item = ItemManager.Create(container.inventory.onlyAllowedItems.FirstOrDefault());
                if (item == null)
                {
                    return;
                }
                item.MoveToContainer(container.inventory);
            }

            item.amount = 200;
            item.skin = 12345;
            item.OnDirty += item1 => Refill(item1);
            item.SetFlag(global::Item.Flag.IsLocked, true);
            container.dropsLoot = false;
            container.inventory.SetFlag(ItemContainer.Flag.IsLocked, true);
            container.SetFlag(BaseEntity.Flags.Locked, true);
        }

        private void ResetVehicle(BaseVehicle vehicle)
        {
            var fuelSystem = vehicle.GetFuelSystem() as EntityFuelSystem;
            var container = fuelSystem?.fuelStorageInstance.Get(true);
            if (container == null)
            {
                container = vehicle.GetComponentsInChildren<StorageContainer>().FirstOrDefault(x => x.inventory.onlyAllowedItems != null);
            }

            if (container == null)
            {
                return;
            }

            var item = container.inventory.GetSlot(0);
            if (item != null && item.skin == 12345)
            {
                item.DoRemove();
            }

            container.inventory.SetFlag(ItemContainer.Flag.IsLocked, false);
            container.SetFlag(BaseEntity.Flags.Locked, false);
        }

        private void ResetBalloon(HotAirBalloon balloon)
        {
            var fuelSystem = balloon.GetFuelSystem() as EntityFuelSystem;
            var container = fuelSystem?.fuelStorageInstance.Get(true);
            if (container == null)
            {
                container = balloon.GetComponentsInChildren<StorageContainer>().FirstOrDefault(x => x.inventory.onlyAllowedItems != null);
            }

            if (container == null)
            {
                return;
            }

            var item = container.inventory.GetSlot(0);
            if (item != null && item.skin == 12345)
            {
                item.DoRemove();
            }

            container.inventory.SetFlag(ItemContainer.Flag.IsLocked, false);
            container.SetFlag(BaseEntity.Flags.Locked, false);
        }

        private void Refill(Item item)
        {
            item.amount = 200;
        }

        #endregion
    }
}

When are you getting this failed to compile ? after you have been making changes in the .cs?

Locked automatically