OnWallpaperRemove
OnWallpaperRemove is called when wallpaper is being taken off a BuildingBlock, before the game clears that side's wallpaper. Returning a non-null value cancels the removal.
object OnWallpaperRemove(BuildingBlock buildingBlock, int side)Parameters
| Parameter | Type | Description |
|---|---|---|
buildingBlock | BuildingBlock | The BuildingBlock whose wallpaper is being removed. Null-check it and use it to identify the wall, its grade, owner and position. |
side | int | Which face of the block the wallpaper sits on: 0 for one side and 1 for the other, matching the side value BuildingBlock.RemoveWallpaper receives. |
Return value
Returning null lets the game continue and remove the wallpaper on that side. Returning any non-null value stops the original method, so the wallpaper health and state for that side are left unchanged.
How it works
This hook runs inside BuildingBlock.RemoveWallpaper, the method the game calls when a player removes wallpaper from a wall (for example by using the building menu action that strips the soft side decoration). It fires once per call, with the block and the affected side. The original method then resets the wallpaper health for that side and clears the stored wallpaper state; if your hook returns non-null, none of that runs and the wallpaper stays put.
Use the hook to protect decorated walls, to log or audit who strips wallpaper, or to require cupboard access. buildingBlock.OwnerID gives the placing player, buildingBlock.buildingID groups the structure, and buildingBlock.GetBuildingPrivilege() returns the nearby cupboard for authorization checks, though the acting player is not passed directly to the hook. There is no narrower useful type for the block parameter, so declare it as BuildingBlock. This is a void method in the game, so any non-null return simply blocks the removal.
Example plugin: Keep wallpaper on walls that have no cupboard
using System;
using Newtonsoft.Json;
using Oxide.Core;
namespace Oxide.Plugins
{
[Info("Wallpaper Removal Guard", "RustPluginGenerator", "1.0.0")]
[Description("Blocks wallpaper removal on building blocks that have no nearby tool cupboard")]
public class WallpaperRemovalGuard : RustPlugin
{
private PluginConfig config;
private class PluginConfig
{
[JsonProperty("Enable protection")]
public bool EnableProtection = 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);
private object OnWallpaperRemove(BuildingBlock buildingBlock, int side)
{
if (!config.EnableProtection)
return null;
if (buildingBlock == null || buildingBlock.IsDestroyed)
return null;
// No cupboard covers this wall: keep the wallpaper and cancel removal.
if (buildingBlock.GetBuildingPrivilege() == null)
return false;
return null;
}
[ChatCommand("wallpaper.toggle")]
private void CmdToggleWallpaper(BasePlayer player, string command, string[] args)
{
if (player == null) return;
if (!player.IsAdmin)
{
player.ChatMessage("Only admins can toggle wallpaper protection.");
return;
}
config.EnableProtection = !config.EnableProtection;
SaveConfig();
player.ChatMessage(config.EnableProtection
? "Wallpaper protection enabled."
: "Wallpaper protection disabled.");
}
}
}The plugin lets you protect wallpaper on walls that have no building privilege nearby, so decoration cannot be stripped from undefended structures. In OnWallpaperRemove it checks the toggle in config, null-checks the block, then calls GetBuildingPrivilege(). If there is no cupboard around the wall and protection is enabled, it returns a non-null value to cancel the removal; otherwise it returns null and vanilla behavior runs. An admin chat command toggles the guard on and off and saves the config so the choice persists across restarts. The hook does no logging, timers or data file work, keeping it cheap since it can fire often on busy servers.
Common use cases
Protect decorated bases
Prevent raiders or teammates from stripping wallpaper on walls that are not covered by a tool cupboard, keeping the decoration as a visual layer of defence.
Log wallpaper stripping
Record which block and side lost wallpaper, plus the owner id, so admins can audit griefing or roll back cosmetic losses.
Permission-gated decoration
Allow only players with a specific permission to remove wallpaper, leaving it untouched for everyone else by returning non-null from the hook.
Pitfalls
The acting player is not passed
The hook only receives the block and side. Infer the actor from
buildingBlock.OwnerIDor cupboard authorization, not from a player argument.Side values matter
sideselects which face is affected. Blocking unconditionally stops both sides, so check the value if you only want to protect one face.
Build a plugin with OnWallpaperRemove
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 OnWallpaperRemove
Generate