OnRentableShopOpen
OnRentableShopOpen is called when a player requests to open a RentableShop, after the game has already confirmed CanPlayerOpenShop and before the store UI is shown. Returning a non-null value cancels the open.
object OnRentableShopOpen(RentableShop rentableShop, BasePlayer player)Parameters
| Parameter | Type | Description |
|---|---|---|
rentableShop | RentableShop | The RentableShop entity the player is trying to open. Use it to read its position, net ID and current state, but null-check it before touching any member. |
player | BasePlayer | The BasePlayer sending the open request. This is the player who would start renting or reopen the vending UI, so it is the right place to check permissions or team membership. |
Return value
Return null (or let the method fall through without returning) to let the shop open normally. Return any non-null object to stop the original open sequence, so the UI is not shown and the internal state changes that follow the hook do not run.
How it works
This hook fires inside RentableShop.Server_OpenStore, the server method behind the RPC a player sends when interacting with a rentable shop. The game first runs its own CanPlayerOpenShop check on the requesting player; only if that passes does the hook run. At this point nothing has been changed yet: the store has not been opened, no rent multiplier has been touched, and no UI has been sent.
The two parameters are the shop entity and the requesting player. Because the shop is a RentableShop, you can read its position, ownership and state, and inside your hook method you can also declare the parameter as a more specific or broader type (for example BaseEntity) if that is all you need; Oxide only calls your method when the incoming object matches your declared type.
Use it for access control, logging, or announcing that a shop is about to open. Blocking here also blocks the internal CloseStore/rent-multiplier bookkeeping that follows, so only cancel when you truly want to keep the shop closed.
Example plugin: Restrict rentable shops to a permission
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("Rentable Shop Access", "RustPluginGenerator", "1.0.0")]
[Description("Restricts opening rentable shops to players holding a permission")]
public class RentableShopAccess : RustPlugin
{
private const string PermUse = "rentableshopaccess.use";
private PluginConfig config;
public class PluginConfig
{
[JsonProperty("Deny message shown to players without permission")]
public bool SendDenyMessage { 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 use rentable shops."
}, 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 OnRentableShopOpen(RentableShop rentableShop, BasePlayer player)
{
if (rentableShop == null || player == null || player.IsNpc)
return null;
if (permission.UserHasPermission(player.UserIDString, PermUse))
return null;
if (config.SendDenyMessage)
player.ChatMessage(Msg("NoPermission", player.UserIDString));
return true;
}
}
}The plugin registers a single permission that gates every rentable shop on the server. OnRentableShopOpen checks the incoming shop and player, then consults permission.UserHasPermission on the player's UserIDString. Players without the permission get a localized chat message and the hook returns true (any non-null value works) so Oxide stops the open sequence and the shop UI never appears. Admitted players fall through and see the normal interface. The permission name uses the lowercase plugin class name as its prefix, and the reply text lives in the language file so it can be translated.
Common use cases
Permission-gated shops
Require a permission or team membership before a player can open any rentable shop, useful on servers that reserve shops for a rank or donor group.
Area-based restrictions
Cancel the open if the shop sits inside a zone (spawn, event area) you want to keep clear by comparing
rentableShop.transform.positionagainst stored coordinates.Audit logging
Record who is opening which shop for anti-cheat or economy audits, writing to a data file instead of spamming the console.
Pitfalls
The game check already ran
CanPlayerOpenShopis evaluated before the hook, so a player who fails the vanilla check never reaches your code. Do not rely on this hook to replace the built-in rules.Cancelling skips internal follow-up
A non-null return stops the rest of
Server_OpenStore, including the rent multiplier increment andCloseStore. Only block when the player should not interact at all.Null shop or player
Guarding with
rentableShop == null || player == nullbefore reading position or permissions avoids exceptions if the entity was destroyed mid-request.
Build a plugin with OnRentableShopOpen
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 OnRentableShopOpen
Generate