Skip to content
RustPluginGenerator

OnInputUpdate

OnInputUpdate is called on an IOEntity right before it processes an incoming electrical signal on one of its input ports, letting you cancel that processing by returning a non-null value.

Signature
object OnInputUpdate(IOEntity iOEntity, int inputAmount, int inputSlot)

Parameters

Hook parameters
ParameterTypeDescription
iOEntityIOEntityThe electrical entity receiving the signal, e.g. a counter, timer, door controller or logic gate. Cast it to the concrete type to inspect its state before deciding whether to allow the update.
inputAmountintThe power value arriving on that input for this frame (0 for off, non-zero when powered). For industrial-style inputs this can carry a larger value rather than a simple on/off.
inputSlotintIndex into the entity's input array identifying which input port received the signal. Entities can have several inputs, so use it to target one specific port.

Return value

Returning null (the default) lets the entity process the input as usual. Returning any non-null object makes the hook stop the original method, so the input is ignored and the entity's state does not change for that update.

How it works

The hook fires inside IOEntity.UpdateFromInput, which the game calls whenever an input on an electrical entity changes state or is re-evaluated for the current frame. That covers anything wired into a power grid: counters, timers, logic gates, door controllers, blockers and similar deployables. The iOEntity parameter is the receiver itself, so you can inspect its fields (for counters the current value, for doors the open state) before the update is applied. inputAmount is the incoming power value and inputSlot tells you which port it arrived on.

Declaring a narrower type such as Counter or Door makes Oxide skip the hook for every other entity, which is the simplest way to keep this high-frequency hook cheap. Because it runs per input update per entity, keep the body short: avoid logging, allocations and iterating over all players. If you need to block a signal, return any non-null object; returning null lets the game continue normally.

Example plugin: Block power to doors during a server event

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

namespace Oxide.Plugins
{
    [Info("Power Lockdown", "RustPluginGenerator", "1.0.0")]
    [Description("Blocks incoming power on door entities while a server-wide lockdown is enabled")]
    public class PowerLockdown : RustPlugin
    {
        private const string PermAdmin = "powerlockdown.admin";

        private PluginConfig config;

        public class PluginConfig
        {
            [JsonProperty("Lockdown enabled")]
            public bool LockdownEnabled { get; set; } = false;
        }

        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>
            {
                ["Enabled"] = "Power lockdown is now ON. Doors will not receive power.",
                ["Disabled"] = "Power lockdown is now OFF. Doors work normally again.",
                ["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(PermAdmin, this);
        }

        private object OnInputUpdate(Door door, int inputAmount, int inputSlot)
        {
            if (door == null || !config.LockdownEnabled) return null;
            return true;
        }

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

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

            string message = Msg(config.LockdownEnabled ? "Enabled" : "Disabled");
            if (player != null) player.ChatMessage(message);
            arg.ReplyWith(message);
        }
    }
}

The plugin adds an admin-only console command that toggles a server-wide lockdown flag, persisted in config. While the flag is on, OnInputUpdate is declared with a Door parameter, so Oxide only calls it for door-type IO entities and silently skips counters, timers and every other electrical device. When a signal reaches a door during lockdown, the hook returns a non-null object, which aborts UpdateFromInput so the door never receives power and cannot be opened remotely. Chat feedback and the console reply tell admins what state they switched to. Unload saves the config so the lockdown survives a restart unless it was cleared.

Common use cases

  • Event lockdown

    Freeze all doors or turrets wired to the grid while an event or raid protection window is active.

  • Signal auditing

    Cast the entity to a Counter and reject values above a threshold so players cannot push a counter past a limit you consider fair.

  • Per-port filtering

    Use inputSlot to ignore signals on one specific port of a multi-input device while leaving the others working normally.

Pitfalls

  • It fires very often

    Every input re-evaluation on every electrical entity can hit this hook. Always narrow the parameter type and avoid chat messages, Puts or heavy loops inside it.

  • Returning true blocks silently

    Any non-null return cancels the update with no feedback to the player. If a build stops working, check whether your plugin is swallowing the signal.

  • Not every device uses the same inputs

    Input slot indexes differ between entity types and some entities use industrial-style inputs carrying large values, so do not assume inputAmount is 0 or 1.

Build a plugin with OnInputUpdate

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

Prompt: Event lockdown using the OnInputUpdate 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 OnInputUpdate

Generate