CanHideStash
CanHideStash is called when a player attempts to bury a small stash, right before the game marks the container hidden. Returning a non-null value blocks the hide.
object CanHideStash(BasePlayer player, StashContainer stashContainer)Parameters
| Parameter | Type | Description |
|---|---|---|
player | BasePlayer | The BasePlayer who triggered the hide action through the stash RPC. This is the player whose client sent the request, so it is the one you should check permissions or position against. |
stashContainer | StashContainer | The StashContainer being hidden. Use its position, OwnerID, or HasFlag(BaseEntity.Flags.Open) to decide whether to allow the transition to the hidden state. |
Return value
The original RPC_HideStash only proceeds when Interface.CallHook("CanHideStash", ...) returns null. Return any non-null value to prevent the stash from being hidden and skip the analytics event and OnStashHidden call. Returning null lets the vanilla hide proceed.
How it works
The hook fires inside StashContainer.RPC_HideStash, the RPC the client sends when a player finishes the bury action on a small stash. At the call site the stash is still visible and the game has not yet set its hidden flag, so the parameters describe the pre-state: player is the connecting player who sent the RPC and stashContainer is the stash entity itself. Because the hook runs before SetHidden(true), this is the right place to veto a bury based on ownership, location, wipe rules, or cooldowns. The game follows the hide with an analytics event and then OnStashHidden. There is only one injection site and no overloads, so declaring BasePlayer and StashContainer exactly is correct. Do not try to declare BaseEntity as the first parameter; the first argument is always a player. The call fires once per hide request, so it is not hot enough to guard with caches, but you still should not print warnings here — send feedback through SendReply instead.
Example plugin: Prevent hiding stashes that are not yours
using System.Collections.Generic;
using System;
using Newtonsoft.Json;
using Oxide.Core;
namespace Oxide.Plugins
{
[Info("Stash Owner Only", "RustPluginGenerator", "1.0.0")]
[Description("Only allow players to hide stashes they placed themselves.")]
public class StashOwnerOnly : RustPlugin
{
private const string PermAdmin = "stashowneronly.admin";
private PluginConfig config;
private class PluginConfig
{
[JsonProperty("Only owner may hide stash")]
public bool OwnerOnly { 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 System.Collections.Generic.Dictionary<string, string>
{
["NotOwner"] = "You can only hide a stash that you placed.",
["AdminDenied"] = "Only the owner can hide this stash."
}, this);
}
private string Msg(string key, string userId = null) => lang.GetMessage(key, this, userId);
private void Init()
{
permission.RegisterPermission(PermAdmin, this);
}
private object CanHideStash(BasePlayer player, StashContainer stashContainer)
{
if (!config.OwnerOnly || player == null || stashContainer == null) return null;
ulong ownerId = stashContainer.OwnerID;
if (ownerId == 0) return null;
if (stashContainer is BaseEntity entity && entity.OwnerID == player.userID.Get()) return null;
if (permission.UserHasPermission(player.UserIDString, PermAdmin)) return null;
player.ChatMessage(Msg("NotOwner", player.UserIDString));
return true;
}
}
}The plugin blocks players from burying a stash they did not place. On every CanHideStash request it reads stashContainer.OwnerID and compares it with the requesting player's steam id. If they differ, and the player is not an admin, the hook returns a non-null value so the game never flips the hidden flag. The player gets a localized chat message explaining why. A config toggle lets admins disable the rule entirely. Ownership for stashes is set when the item is deployed, so players can still hide their own stash after placing it. The plugin does not touch loot permissions or open states; it only gates the hide transition.
Common use cases
Restrict hiding to the stash owner
Block teammates or looters from burying someone else's stash, forcing the owner to hide it themselves.
Block hides inside a raid window
Deny the hide request while a raid flag is active on the stash's building privilege so raiders cannot quickly conceal a stash mid-fight.
Log hide events for moderation
Record which player hid which stash and where, so admins can trace suspicious stashes after a report without blocking the action.
Pitfalls
Returning false does not block
The dispatch only checks for a non-null value. Returning
falsestill prevents the hide only because it is non-null; returningnullis what lets the action through. Usetrueor a string for clarity.OwnerID can be 0 for spawned stashes
Stashes created by maps or admin commands may have OwnerID 0. Treat that case as unrestricted or your rule will lock out everyone on those stashes.
Do not expect OnStashHidden after a block
When you return a non-null value,
OnStashHiddenis not called. Any plugin logic relying on that hook will not run, so keep hide bookkeeping inside this hook if you also block.
Build a plugin with CanHideStash
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 CanHideStash
Generate