Skip to content
RustPluginGenerator

OnWindmillUpdate

OnWindmillUpdate is called at the start of ElectricWindmill.WindUpdate, before the windmill recalculates its wind speed and stored energy. Returning a non-null value skips the vanilla recalculation for that entity.

Signature
object OnWindmillUpdate(ElectricWindmill electricWindmill)

Parameters

Hook parameters
ParameterTypeDescription
electricWindmillElectricWindmillThe ElectricWindmill entity whose wind update is being processed. Use it to read position, owner, health or the currently stored energy when deciding whether to alter the update.

Return value

Return null (or nothing) to let the vanilla wind speed and energy recalculation run. Return any non-null object, such as true, to skip the rest of ElectricWindmill.WindUpdate for that windmill, leaving its stored energy and wind speed unchanged for this cycle.

How it works

The hook fires every time an ElectricWindmill runs its wind update, which the game performs periodically to convert current wind conditions into stored energy. The single argument is the windmill instance being updated, so you can inspect its transform position, OwnerID or currentEnergy.

Because the return value is checked before the vanilla body runs, returning a non-null object from your hook (any object, typically true) tells Oxide to skip the rest of WindUpdate for that entity. The windmill then keeps whatever currentEnergy and serverWindSpeed values it already had, which is how you can freeze, boost or throttle output. Returning null lets the normal visibility and wind-scale calculation proceed.

This is a high-frequency hook: it runs on a timer for every placed windmill on the server, so keep the body cheap, avoid allocations where possible and never call Puts or PrintWarning from it. If you want a windmill to stop producing under some condition, return true and optionally set the energy yourself, but remember the game will re-run the hook on its next update cycle.

Example plugin: Throttle windmill output by permission and health

WindmillGovernor.cs
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;

namespace Oxide.Plugins
{
    [Info("Windmill Governor", "RustPluginGenerator", "1.0.0")]
    [Description("Blocks or throttles ElectricWindmill power generation based on permission and health.")]
    public class WindmillGovernor : RustPlugin
    {
        private const string PermUse = "windmillgovernor.vip";

        private PluginConfig config;

        public class PluginConfig
        {
            [JsonProperty("Require permission for full output")]
            public bool RequirePermission { get; set; } = true;

            [JsonProperty("Minimum health percent to generate")]
            public float MinHealthPercent { get; set; } = 25f;
        }

        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>
            {
                ["NoPermission"] = "You do not have permission to generate wind power here."
            }, 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);
        }

        private object OnWindmillUpdate(ElectricWindmill electricWindmill)
        {
            if (electricWindmill == null) return null;
            if (electricWindmill.IsDestroyed) return null;

            if (!IsBlocked(electricWindmill)) return null;

            // Freeze output for this cycle and bleed off stored charge.
            electricWindmill.currentEnergy = 0;
            return true;
        }

        private bool IsBlocked(ElectricWindmill windmill)
        {
            if (windmill.health < windmill.MaxHealth() * (config.MinHealthPercent / 100f))
                return true;

            if (!config.RequirePermission) return false;

            ulong ownerId = windmill.OwnerID;
            if (ownerId == 0) return false;

            string userId = ownerId.ToString();
            if (permission.UserHasPermission(userId, PermUse)) return false;

            BasePlayer owner = BasePlayer.FindByID(ownerId);
            if (owner != null && owner.IsConnected)
                owner.ChatMessage(Msg("NoPermission", userId));

            return true;
        }
    }
}

The plugin stops windmills from generating power when their owner lacks the configured permission, or when the windmill is damaged below a configurable health percentage. OnWindmillUpdate checks each condition and returns true to skip the vanilla recalculation, which leaves currentEnergy where it was. Because the windmill may already hold charge, the plugin also drains stored energy while it is blocked, by zeroing the field directly through the public member on the entity. A config file sets the required permission and damage threshold, messages are localized, and the helper methods stay trivial so the hot path does no logging.

Common use cases

  • Gate windmill power behind a permission

    Only players holding a VIP or paid permission get full output. Return true for windmills whose owner fails the check so their energy stays flat.

  • Disable windmills on damaged structures

    Stop a windmill from charging once its health drops below a threshold, forcing players to repair before regaining power.

  • Cap output in specific zones

    Compare the windmill position against configured zones and skip the update inside them, throttling power generation in protected or PvP areas.

Pitfalls

  • Blocking the hook leaves existing energy intact

    Returning true only skips recalculation; the windmill keeps whatever currentEnergy already holds. Set currentEnergy yourself if you need the output to actually drop.

  • Runs for every windmill on a timer

    The hook fires repeatedly for each placed ElectricWindmill. Keep it allocation-free and never log inside it or you will spam the server console.

  • Energy may still be consumed downstream

    Skipping WindUpdate only affects generation. Existing consumers pull from the stored energy, so pair the hook with your own drain or a consumer check if you need a full stop.

Build a plugin with OnWindmillUpdate

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

Prompt: Gate windmill power behind a permission using the OnWindmillUpdate 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 OnWindmillUpdate

Generate