CanDesignFirework
CanDesignFirework is called when a player tries to open the design interface of a PatternFirework, before the game checks building privilege. Return false to deny the interaction.
object CanDesignFirework(BasePlayer player, PatternFirework patternFirework)Parameters
| Parameter | Type | Description |
|---|---|---|
player | BasePlayer | The BasePlayer who is trying to open the firework design UI. Already checked for null and CanInteract() before the hook fires, but re-check it in your code. |
patternFirework | PatternFirework | The PatternFirework entity the player is trying to edit. Use it to read its position, owner and building privilege via GetBuildingPrivilege(). |
Return value
Returning a bool replaces the method result: false denies the player the design UI, true grants it even without building privilege. Returning null (or anything that is not a bool) lets the original privilege check run unchanged.
How it works
The hook fires inside PatternFirework.PlayerCanModify, the method the game calls when a player attempts to open the design editor of a firework. The original code first rejects the request if player is null or fails CanInteract(), then calls the hook, and only afterwards checks building privilege with GetBuildingPrivilege(). Both arguments are the player performing the action and the firework entity being edited.
Because the injection uses the player and the firework directly, you can narrow the player parameter if you want the hook to fire only for a specific subtype, though the game only ever passes a real BasePlayer here. Returning a bool short-circuits the entire privilege check: return false to block the UI, return true to allow it even when the player is not authorized on the cupboard. Return null to fall through to the normal privilege logic.
Practical uses: allow editing only for the firework's owner or team, restrict design changes to authorized players in a certain zone, or block editing during events. Keep the hook fast because it runs on each interaction attempt.
Example plugin: Restrict firework design to owner and team
using System.Collections.Generic;
using System;
using Newtonsoft.Json;
using Oxide.Core;
namespace Oxide.Plugins
{
[Info("Firework Design Guard", "RustPluginGenerator", "1.0.0")]
[Description("Restricts editing of PatternFirework designs to the owner and optionally their team.")]
public class FireworkDesignGuard : RustPlugin
{
private const string PermBypass = "fireworkdesignguard.bypass";
private PluginConfig config;
private class PluginConfig
{
[JsonProperty("Enabled")]
public bool Enabled = true;
[JsonProperty("Allow team members")]
public bool AllowTeamMembers = 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>
{
["NotAllowed"] = "You are not allowed to edit this firework."
}, 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(PermBypass, this);
}
private object CanDesignFirework(BasePlayer player, PatternFirework patternFirework)
{
if (!config.Enabled || player == null || patternFirework == null)
return null;
if (permission.UserHasPermission(player.UserIDString, PermBypass))
return null;
if (patternFirework.OwnerID == 0 || patternFirework.OwnerID == player.userID.Get())
return null;
if (config.AllowTeamMembers && player.currentTeam != 0)
{
var owner = BasePlayer.FindByID(patternFirework.OwnerID);
if (owner != null && owner.currentTeam == player.currentTeam)
return null;
}
player.ChatMessage(Msg("NotAllowed", player.UserIDString));
return false;
}
}
}The plugin intercepts every attempt to open a PatternFirework design editor. It reads the configurable switch and the allowed team-member setting from oxide/config. If the feature is enabled, it compares the requesting player's userID with the firework's OwnerID, and when team sharing is on, checks that both players share a non-zero currentTeam. Otherwise the request is allowed. A lang key sends nothing to the player here because the game simply refuses the interaction, but the messages are set up so a future patch could extend it. Return null in the owner/team case so the standard building privilege check still applies for everyone else.
Common use cases
Owner-only firework editing
Return false for players who are not the deployed firework's owner, preventing strangers from changing a design placed inside a base.
Team sharing
Allow teammates to edit the design by comparing currentTeam values, while still blocking unrelated players.
Event lockdown
Block all firework design changes during a server event or wipe period by toggling a config flag that forces the hook to return false.
Pitfalls
Returning true bypasses privilege
A non-null bool result replaces the whole method, so returning true lets the player edit even without cupboard authorization. Only do this deliberately.
OwnerID can be zero
Fireworks spawned by the server or given via admin commands may have no owner. Compare against zero before trusting the owner check, or nobody will be able to edit them.
Hook runs before privilege lookup
The building privilege check happens after the hook, so you cannot read its result here. Call GetBuildingPrivilege() yourself if you need that information.
Build a plugin with CanDesignFirework
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 CanDesignFirework
Generate