Skip to content
RustPluginGenerator

OnWallpaperSet

OnWallpaperSet is called when a player tries to apply wallpaper to a building block, before the game commits the change.

Signature
object OnWallpaperSet(BuildingBlock buildingBlock, ulong id, int side, float rotation)

Parameters

Hook parameters
ParameterTypeDescription
buildingBlockBuildingBlockThe BuildingBlock entity the wallpaper is being applied to. Use it to read the owner (OwnerID), location and building privilege.
idulongThe item ID of the wallpaper item that would be applied. Compare with ItemManager.FindItemDefinition(...).itemid to identify the specific skin or wallpaper type.
sideintWhich face of the block the wallpaper targets: 0 selects the primary wall face and 1 the opposite side.
rotationfloatRotation value passed through from the client request, used to orient the wallpaper on the face.

Return value

Returning null lets the game proceed and apply the wallpaper. Returning any non-null value stops SetWallpaper immediately, so the wallpaper is never applied for that request.

How it works

The hook fires inside BuildingBlock.SetWallpaper, which is invoked when a player uses wallpaper (and related wall skin items) on a wall face. It runs before the server applies the side, rotation and item ID, so every attempt passes through it, including attempts that the game would later reject.

Use buildingBlock to inspect the target: its OwnerID for who placed it, GetBuildingPrivilege() for authorization checks, and transform.position for proximity rules. id is the wallpaper item ID, so you can resolve the matching ItemDefinition to read its shortname or display name. side tells you which face is being covered, which matters when you want to limit wallpaper to one side of a wall or block it on exposed facades. rotation is the client-supplied orientation.

You do not need to narrow by parameter type here: the block is always a BuildingBlock, so declaring a different type would prevent the hook from being invoked at all. Return a non-null value to cancel the operation for that call; return null to let the game continue its normal logic. The hook also fires for admin and other non-player code paths that call SetWallpaper directly, so check OwnerID rather than assuming a player context.

Example plugin: Restrict wallpaper to authorized builders

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

namespace Oxide.Plugins
{
    [Info("Wallpaper Guard", "RustPluginGenerator", "1.0.0")]
    [Description("Restricts wallpaper application to players authorized on the building's cupboard.")]
    public class WallpaperGuard : RustPlugin
    {
        private const string PermAnywhere = "wallpaperguard.anywhere";

        private PluginConfig config;

        private class PluginConfig
        {
            [JsonProperty("Allow any player within radius without cupboard auth")]
            public bool AllowNearby { get; set; } = false;

            [JsonProperty("Radius for nearby allowance")]
            public float Radius { get; set; } = 5f;

            [JsonProperty("Send denial messages")]
            public bool Notify { 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 authorized to wallpaper this structure.",
                ["DeniedSide"] = "Wallpaper cannot be placed on this side of the block."
            }, this);
        }

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

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

        private object OnWallpaperSet(BuildingBlock buildingBlock, ulong id, int side, float rotation)
        {
            if (buildingBlock == null || buildingBlock.IsDestroyed) return null;
            if (config == null) return null;

            BasePlayer player = BasePlayer.FindByID(buildingBlock.OwnerID);
            if (player == null || player.IsNpc) return null;

            if (permission.UserHasPermission(player.UserIDString, PermAnywhere)) return null;

            if (IsAllowed(buildingBlock, player)) return null;

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

        private bool IsAllowed(BuildingBlock block, BasePlayer player)
        {
            var privilege = block.GetBuildingPrivilege();
            if (privilege != null && privilege.IsAuthed(player)) return true;

            if (config.AllowNearby)
            {
                float distance = Vector3.Distance(block.transform.position, player.transform.position);
                if (distance <= config.Radius) return true;
            }

            return false;
        }
    }
}

The plugin checks GetBuildingPrivilege() on the target block and compares the caller to the cupboard's authorized list through the block's owner. Access is decided by a permission: holders with wallpaperguard.anywhere can wallpaper any structure, everyone else must be authorized on the building's tool cupboard and inside a configurable radius of the block. Configuration exposes the permission-free radius and a message toggle. Failures are surfaced with localized chat messages, keyed in LoadDefaultMessages, so admins can translate them. The hook is read-only apart from the chat feedback: it never edits the block, and returns null to allow or a non-null value to cancel, matching the game's guard check.

Common use cases

  • Only allow wallpaper on your own base

    Block wallpaper requests where the requesting player is not authorized on the building's cupboard or does not own the block, preventing strangers from decorating or obscuring raided structures.

  • Limit wallpaper to one side

    Inspect side and cancel requests for the outer face so players must cover the interior only, keeping exteriors paintable or visible for other plugins.

  • Whitelist specific wallpaper skins

    Resolve id to an ItemDefinition and reject wallpaper items outside an allowed shortname list, useful on servers that sell premium wallpaper skins.

Pitfalls

  • The caller is not a parameter

    SetWallpaper only receives the block and item data. Derive the player from the block's owner or other server state; do not assume InitiatorPlayer style data exists, and guard against blocks placed by bots or admins.

  • Blocks without a privilege

    GetBuildingPrivilege() returns null when no cupboard covers the block. Treat that as unauthorized unless your policy allows open building, otherwise the guard will throw or block everything.

  • Cancelling silently confuses players

    Returning non-null gives no game feedback. Send a chat message through the language system so the player knows why the wallpaper did not apply.

Build a plugin with OnWallpaperSet

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

Prompt: Only allow wallpaper on your own base using the OnWallpaperSet 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 OnWallpaperSet

Generate