CanLightCannonFuse
CanLightCannonFuse is called when a player attempts to light the fuse on a naval Cannon, before the game decides whether the fuse can be lit. Returning a boolean overrides that decision.
object CanLightCannonFuse(Cannon cannon)Parameters
| Parameter | Type | Description |
|---|---|---|
cannon | Cannon | The Cannon entity (the large naval cannon placed on boats) whose fuse lighting is being checked. It is a BaseEntity subclass, so it can be null-checked and queried for OwnerID, flags and position. |
Return value
Return a bool to directly control whether the fuse is lit: true allows it, false blocks it, and the game's own flag check is skipped. Return null (or anything that is not a bool) to fall back to the default !HasFlag(Flags.Reserved6) result.
How it works
The hook fires inside Cannon.CanLightFuse, which the game calls when a player interacts with a cannon to light its fuse. The default logic simply returns the opposite of the Flags.Reserved6 flag on the cannon, meaning the fuse is blocked while that flag is set. Declaring Cannon cannon matches the exact type; declaring a broader base type such as BaseEntity also works because the argument is a Cannon instance, but it gives you no cannon-specific members.
Use the parameter to inspect the cannon's owner (OwnerID), its position, its parent boat, or the surrounding environment. Because the hook can return a bool, it is the standard place to add server-specific rules about who may fire a cannon: block it for specific players, gate it behind a permission, prevent it in safe zones, or restrict it to the boat's owner team. Returning null keeps the vanilla behavior. The hook runs only when a player tries to light the fuse, so it is not a high-frequency hot path, but avoid heavy work or player-list scans inside it.
Example plugin: Restrict cannon fuses to a permission
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("Cannon Fuse Permission", "RustPluginGenerator", "1.0.0")]
[Description("Restricts lighting naval cannon fuses to players with a permission")]
public class CannonFusePermission : RustPlugin
{
private const string PermUse = "cannonfusepermission.use";
private PluginConfig config;
private class PluginConfig
{
[JsonProperty("Require permission to light cannon fuses")]
public bool RequirePermission { 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>
{
["NoPermission"] = "You do not have permission to light cannon fuses."
}, 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 CanLightCannonFuse(Cannon cannon)
{
if (cannon == null || !config.RequirePermission) return null;
BasePlayer player = BasePlayer.FindByID(cannon.OwnerID);
if (player == null || player.IsNpc) return null;
if (!permission.UserHasPermission(player.UserIDString, PermUse))
{
player.ChatMessage(Msg("NoPermission", player.UserIDString));
return false;
}
return true;
}
}
}The plugin registers a cannonfusepermission.use permission. When a player tries to light a cannon's fuse, CanLightCannonFuse looks up the player from the cannon's OwnerID and checks the permission. Players without it are blocked with a chat message and the hook returns false; everyone else is allowed through with true. The message text lives in the language file so it can be translated. Unload is left minimal because there is no saved state or UI.
Common use cases
Team or owner restriction
Allow only the boat owner or their teammates to fire a cannon by resolving the cannon's OwnerID to a BasePlayer and comparing teams with RelationshipManager.
Safe zone protection
Return false when the cannon sits inside a safe zone or near a building privilege you want protected, preventing griefing with naval cannons.
Admin-only test cannons
Gate fuse lighting behind a permission so only staff can operate pre-placed cannons during events or staging.
Pitfalls
OwnerID may not be a player
On cannons deployed by other entities or spawned by admins, OwnerID can be 0 or a non-player id. Use BasePlayer.FindByID and null-check before calling permission checks.
Do not return false unconditionally for everyone
Returning false for all calls disables the cannon entirely, including for admins. Always check your condition first and return null when you do not want to override the game.
Build a plugin with CanLightCannonFuse
Describe what should happen and get a compiled plugin that uses this hook.
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 CanLightCannonFuse
Generate