Skip to content
RustPluginGenerator

OnInterferenceUpdate

OnInterferenceUpdate is called when an AutoTurret recalculates whether something is interfering with it, before the vanilla interference check runs. Returning a bool replaces the result; returning null lets the game decide.

Signature
object OnInterferenceUpdate(AutoTurret autoTurret)

Parameters

Hook parameters
ParameterTypeDescription
autoTurretAutoTurretThe AutoTurret whose interference state is being recalculated. Inspect its position, owner, authorization list, or current target to decide what the result should be.

Return value

Returning a bool replaces the result of the original RecalculateInterference call, so true reports interference and false reports a clear turret. Returning null (the default) lets the vanilla check run unchanged.

How it works

The hook fires inside AutoTurret.RecalculateInterference, a method the turret uses to work out whether something is currently blocking it — typically another entity sitting in front of the turret's line of fire. It runs whenever the turret refreshes that state, for example after scanning for a new target or after its surroundings change.

The single parameter is the AutoTurret instance being evaluated. Because the hook fires before the vanilla check, the turret's flags and current target may not match the value you are about to return — read position and authorization state instead of relying on HasInterference.

The method returns bool, so a returned bool becomes the new result: true means the turret treats itself as interfered with, false clears it. Returning null falls through to the original check. You cannot narrow the parameter type here; something other than an AutoTurret never reaches this hook. Keep the body cheap — turrets recalculate often on busy servers, so avoid allocation, database reads, and chat output.

Example plugin: Disable turret interference in a safe zone

TurretNoInterferenceZone.cs
using System;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("Turret No Interference Zone", "RustPluginGenerator", "1.0.0")]
    [Description("Turns off AutoTurret interference checks inside a configured square zone.")]
    public class TurretNoInterferenceZone : RustPlugin
    {
        private const string PermAdmin = "turretnointerferencezone.admin";

        private PluginConfig config;

        private class PluginConfig
        {
            [JsonProperty("Zone center X")]
            public float CenterX = 0f;

            [JsonProperty("Zone center Z")]
            public float CenterZ = 0f;

            [JsonProperty("Zone half size (meters)")]
            public float HalfSize = 50f;

            [JsonProperty("Enabled")]
            public bool Enabled = 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(PermAdmin, this);
        }

        private object OnInterferenceUpdate(AutoTurret autoTurret)
        {
            if (!config.Enabled || autoTurret == null || autoTurret.IsDestroyed) return null;

            Vector3 pos = autoTurret.transform.position;
            if (Mathf.Abs(pos.x - config.CenterX) > config.HalfSize) return null;
            if (Mathf.Abs(pos.z - config.CenterZ) > config.HalfSize) return null;

            return false;
        }

        [ChatCommand("turretzone")]
        private void CmdTurretZone(BasePlayer player, string command, string[] args)
        {
            if (player == null) return;
            if (!player.IsAdmin && !permission.UserHasPermission(player.UserIDString, PermAdmin))
            {
                player.ChatMessage("You do not have permission to use this command.");
                return;
            }

            if (args.Length > 0 && args[0] == "toggle")
            {
                config.Enabled = !config.Enabled;
                SaveConfig();
            }

            player.ChatMessage(string.Format(
                "Turret interference zone: {0}. Center {1} / {2}, half size {3}m.",
                config.Enabled ? "enabled" : "disabled",
                config.CenterX, config.CenterZ, config.HalfSize));
        }
    }
}

The plugin defines a square safe zone from config and turns off turret interference for any AutoTurret whose position falls inside it. OnInterferenceUpdate checks whether the turret is inside the configured bounds; if it is, the hook returns false, so the turret never reports itself as blocked and keeps firing. Turrets outside the bounds get null, which leaves the vanilla check untouched. An admin chat command prints the active bounds so the setting can be verified in game, and the zone is validated on load so a bad config cannot break turrets server-wide.

Common use cases

  • Safe-zone turrets that never jam

    Return false for turrets inside a designated area so players cannot park a deployable in front of a monument turret to disable it.

  • Event arena turrets

    Force interference off for turrets spawned by an event plugin, so arena setups behave predictably regardless of what players build nearby.

  • Debugging turret behavior

    Temporarily log or override the result for specific turrets while diagnosing why a base defence is not engaging targets.

Pitfalls

  • It does not create the interference check

    The hook only overrides the result of a check the turret already performs. Returning false does not make a turret aim at targets behind walls; it only clears the interference flag.

  • Fires frequently

    Turrets recalculate interference often, so keep the hook allocation-free and never send chat messages or write data inside it.

  • Only AutoTurret reaches the hook

    Declaring a narrower or different parameter type means your method is never called, since Oxide dispatches on the argument being an instance of the declared type.

Build a plugin with OnInterferenceUpdate

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

Prompt: Safe-zone turrets that never jam using the OnInterferenceUpdate 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 OnInterferenceUpdate

Generate