Skip to content
RustPluginGenerator

CanEditPlayerBoat

CanEditPlayerBoat is called when a player tries to start editing a PlayerBoat, and returning a bool overrides the game's own permission check.

Signature
object CanEditPlayerBoat(PlayerBoat playerBoat, BasePlayer player)

Parameters

Hook parameters
ParameterTypeDescription
playerBoatPlayerBoatThe PlayerBoat (the small motorboat deployed by players) that is about to be edited. Compare its OwnerID, net.ID or position to decide who should be allowed.
playerBasePlayerThe BasePlayer attempting to start editing the boat. Check team, permissions or building privilege on this player to allow or deny.

Return value

Return null to let the game run its normal editing check. Return a bool (true to allow, false to deny) and the original PlayerBoat.CanStartEditing logic is skipped entirely; any non-bool return is ignored.

How it works

The hook fires inside PlayerBoat.CanStartEditing, which the boat runs before letting a player perform edit actions on it (such as picking the boat up and moving it around). The game calls the hook first with the boat instance and the player who triggered the edit. If any of your hook methods returns a bool, that value becomes the result of CanStartEditing directly and the vanilla ownership check is never evaluated. A constant true would let anyone edit anyone's boat, a constant false would lock editing off completely.

Declaring the first parameter as the concrete PlayerBoat type keeps the hook specific to this hull; other entity edits already run through other paths. Use playerBoat.OwnerID against player.userID for owner-only rules, or playerBoat.GetBuildingPrivilege() to allow neighbours with blocked building auth. Keep the method cheap and side-effect free, since it can run whenever a player interacts with a boat.

Example plugin: Owner and team only boat editing

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

namespace Oxide.Plugins
{
    [Info("BoatEditControl", "RustPluginGenerator", "1.0.0")]
    [Description("Restricts who can start editing a PlayerBoat to the owner, their team, or permission holders")]
    public class BoatEditControl : RustPlugin
    {
        private const string PermAllow = "boateditcontrol.allow";

        private PluginConfig config;

        private class PluginConfig
        {
            [JsonProperty("Allow teammates")]
            public bool AllowTeammates { get; set; } = true;

            [JsonProperty("Notify on denial")]
            public bool NotifyOnDenial { 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 Dictionary<string, string>
            {
                ["Denied"] = "You are not allowed to edit this boat."
            }, 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(PermAllow, this);
        }

        private object CanEditPlayerBoat(PlayerBoat playerBoat, BasePlayer player)
        {
            if (playerBoat == null || player == null) return null;
            if (player.IsAdmin || permission.UserHasPermission(player.UserIDString, PermAllow)) return null;

            ulong ownerId = playerBoat.OwnerID;
            if (ownerId == player.userID.Get()) return null;

            if (config.AllowTeammates && ownerId != 0)
            {
                ulong team = player.currentTeam;
                if (team != 0)
                {
                    var teamInfo = RelationshipManager.ServerInstance.FindTeam(team);
                    if (teamInfo != null && teamInfo.members.Contains(ownerId)) return null;
                }
            }

            if (config.NotifyOnDenial)
            {
                player.ChatMessage(Msg("Denied", player.UserIDString));
            }
            return false;
        }
    }
}

CanEditPlayerBoat rejects edits unless the player owns the boat, sits on the same team as the owner, or is an admin. It runs only on PlayerBoat.CanStartEditing, and each denial sends a short message through the language file. A registered permission boateditcontrol.allow grants a bypass for trusted builders. The decision is read from the config so server owners can toggle the team rule without recompiling, and the hook returns null when the player is allowed, letting the vanilla check run untouched.

Common use cases

  • Restrict editing to team members

    Block outsiders from moving or rearranging a boat that belongs to another group while letting the owner and their teammates continue.

  • Lock boats after a wipe

    During the first minutes of a wipe deny all edits so fresh boats are not dragged around, then stop denying once a timer or command flips the flag.

  • Grant edit rights by building auth

    Use playerBoat.GetBuildingPrivilege() to let players with cupboard auth allow edits in docks and marinas.

Pitfalls

  • Returning false everywhere locks the boat

    Once you return a bool, the game skips its own check. If you return false for every player, nobody can ever edit a boat until you unload the plugin or change the rule.

  • OwnerID is the placer, not always the team

    A boat crafted and deployed by a teammate belongs to that player's userID. Compare owners through the RelationshipManager team lookup, not by string matching player names.

  • Don't spam chat on every attempt

    The hook can fire repeatedly while a player mashes the interact key. Throttle or only reply when the attempt actually changes state, otherwise the chat log floods.

Build a plugin with CanEditPlayerBoat

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

Prompt: Restrict editing to team members using the CanEditPlayerBoat 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 CanEditPlayerBoat

Generate