Skip to content
RustPluginGenerator

CanLowerSail

CanLowerSail is called when the game checks whether a sail on a player boat can be lowered, before the boat-ownership and child-entity authentication checks run.

Signature
object CanLowerSail(Sail sail, BasePlayer player)

Parameters

Hook parameters
ParameterTypeDescription
sailSailThe Sail entity (a child of a player boat) whose lowering is being checked. Use it to inspect position, parent boat, and status flags.
playerBasePlayerThe BasePlayer attempting to lower the sail. May be null in edge cases such as non-player driven lowering or teardown, so null-check it before using.

Return value

Return null (or nothing) to let the original CanBeLowered logic run, including the boat authentication check. Return a bool to override the result directly: true allows lowering, false denies it, and the vanilla auth check is skipped.

How it works

CanLowerSail fires from Sail.CanBeLowered(BasePlayer). The game calls that method when a player tries to lower a raised sail on a boat, so the hook runs once per attempt, before the built-in authorization logic that decides whether the player is allowed to operate child entities of the boat. Parameter sail is the Sail component itself; player is the player driving the action and can be null in non-player paths. Returning a non-null bool short-circuits the method: true lets the lowering succeed even if the normal auth check would deny it, and false blocks it. Returning null falls through to the vanilla check, which verifies the player is authed on the parent boat (authed if the boat has no lock or privilege). Because the hook fires on a player-triggered action rather than per tick, light logic here is fine, but keep it cheap and avoid chatty logging. Note the companion hook CanRaiseSail handles the opposite direction, and a permissive return here overrides all built-in boat-lock protection.

Example plugin: Restrict sail lowering to the boat owner

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

namespace Oxide.Plugins
{
    [Info("Owner Only Sail Lower", "RustPluginGenerator", "1.0.0")]
    [Description("Restricts lowering a boat sail to the boat owner or admins")]
    public class OwnerOnlySailLower : RustPlugin
    {
        private const string PermBypass = "owneronlysailLower.bypass";

        private PluginConfig config;

        private class PluginConfig
        {
            [JsonProperty("Enable ownership restriction")]
            public bool Enabled { get; set; } = true;

            [JsonProperty("Allow admins to bypass")]
            public bool AdminBypass { get; set; } = 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);

        protected override void LoadDefaultMessages()
        {
            lang.RegisterMessages(new System.Collections.Generic.Dictionary<string, string>
            {
                ["NotOwner"] = "Only the owner of this boat can lower its sails."
            }, this);
        }

        private string Msg(string key, string userId = null) => lang.GetMessage(key, this, userId);

        private void Init()
        {
            permission.RegisterPermission(PermBypass, this);
        }

        private object CanLowerSail(Sail sail, BasePlayer player)
        {
            if (!config.Enabled || sail == null || player == null)
                return null;

            if (player.IsAdmin || permission.UserHasPermission(player.UserIDString, PermBypass))
                return null;

            var boat = sail.GetParentEntity();
            if (boat == null)
                return null;

            if (boat.OwnerID != 0 && boat.OwnerID != player.userID.Get())
            {
                player.ChatMessage(Msg("NotOwner", player.UserIDString));
                return false;
            }

            return null;
        }
    }
}

The plugin denies lowering a sail unless the player is the boat's owner (or a server admin). In CanLowerSail it null-checks the sail and player, reads the parent boat's OwnerID, and compares it with the player's userID. Admins bypass the restriction. All player feedback goes through the language file: a denied player receives a chat message explaining only the owner can lower the sail. The config exposes a toggle and an admin-bypass flag so admins can turn the rule off or allow staff to test. Because the hook returns false, the vanilla child-entity auth path never runs, so the ownership rule is the sole gate.

Common use cases

  • Enforce strict boat ownership

    Deny sail lowering for anyone except the registered owner of the parent boat, even if the boat has no lock.

  • Lock sails during events

    Block all lowering while a custom event or combat timer is active, then allow it again once the timer expires.

  • Allow shared crew control

    Return true for members of the owner's team so a crew can manage sails without full lock access.

Pitfalls

  • Returning true bypasses boat locks

    A true return skips the built-in authentication check entirely, so a permissive hook can let unauthorized players operate locked boats.

  • player can be null

    Some non-player paths call the method with a null player. Guard against it before reading player.userID to avoid a NullReferenceException.

  • Only lowering is intercepted

    This hook does not affect raising sails; use CanRaiseSail for the opposite direction, or a permit here can be undone by another hook.

Build a plugin with CanLowerSail

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

Prompt: Enforce strict boat ownership using the CanLowerSail 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 CanLowerSail

Generate