OnMixingTableToggle
OnMixingTableToggle is called when a player switches a mixing table on or off, before the game applies the new state. Returning a non-null value blocks the switch.
object OnMixingTableToggle(MixingTable mixingTable, BasePlayer player)Parameters
| Parameter | Type | Description |
|---|---|---|
mixingTable | MixingTable | The MixingTable entity the player is trying to start or stop. Use it to check the table's position, owner, or its current contents before allowing the toggle. |
player | BasePlayer | The BasePlayer sending the switch RPC. Can be null in edge cases, so null-check it before reading permissions, team, or identity. |
Return value
Returning any non-null value stops SVSwitch immediately, so the game never reads the requested on/off bit and the table state stays as it was. Returning null lets the original method continue and apply the switch normally.
How it works
The hook fires inside MixingTable.SVSwitch, the server-side method that handles the switch RPC sent when a player presses the table's on/off control in the UI. It runs before the game reads the requested on/off bit, so the table's state has not changed yet when your code is called. mixingTable is the entity being toggled and player is the sender of the RPC.
Because this is an entity hook, you can declare mixingTable as MixingTable (as given) and it will only be called for mixing tables. If you narrow player to another type the call is skipped whenever the sender does not match, but in practice the sender is a BasePlayer.
This is the place to gate table usage: block non-authed players, restrict to a building privilege area, deny tables owned by other players, or log who starts a mix. It fires only on an actual state change attempt, not on every frame. MixingTable derives from an entity type, so member access like OwnerID and transform.position is available.
Example plugin: Restrict mixing tables to owners and teammates
using System.Linq;
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("MixingTableGuard", "RustPluginGenerator", "1.0.0")]
[Description("Restricts mixing table switches to the owner, their team, and permitted players.")]
public class MixingTableGuard : RustPlugin
{
private const string PermAdmin = "mixingtableguard.admin";
private const string PermBypass = "mixingtableguard.bypass";
private PluginConfig config;
private class PluginConfig
{
[JsonProperty("Allow teammates to use the table")]
public bool AllowTeammates = true;
[JsonProperty("Require building privilege")]
public bool RequireBuildingPrivilege = false;
}
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>
{
["NotOwner"] = "You do not have permission to use this mixing table.",
["NoPrivilege"] = "You must be authorized on the building privilege to use this table."
}, this);
}
private string Msg(string key, string userId = null) => lang.GetMessage(key, this, userId);
private void Init()
{
permission.RegisterPermission(PermAdmin, this);
permission.RegisterPermission(PermBypass, this);
}
private object OnMixingTableToggle(MixingTable mixingTable, BasePlayer player)
{
if (mixingTable == null || player == null) return null;
string userId = player.UserIDString;
if (player.IsAdmin || permission.UserHasPermission(userId, PermAdmin) || permission.UserHasPermission(userId, PermBypass))
return null;
if (config.RequireBuildingPrivilege)
{
var privilege = mixingTable.GetBuildingPrivilege();
if (privilege != null && !privilege.IsAuthed(player))
{
player.ChatMessage(Msg("NoPrivilege", userId));
return true;
}
return null;
}
if (mixingTable.OwnerID == 0 || mixingTable.OwnerID == player.userID.Get())
return null;
if (config.AllowTeammates && player.currentTeam != 0)
{
var team = RelationshipManager.ServerInstance.FindTeam(player.currentTeam);
if (team != null && team.members.Contains(mixingTable.OwnerID))
return null;
}
player.ChatMessage(Msg("NotOwner", userId));
return true;
}
}
}The plugin checks the sender of the switch RPC against the table's OwnerID. Admins with the mixingtableguard.admin permission and players holding the mixingtableguard.bypass permission are allowed. Otherwise the player must match the owner or share a team with the owner, using RelationshipManager.ServerInstance.FindTeam and comparing currentTeam. A denied switch returns a non-null value to stop the state change and sends a localized chat message. Teams are resolved once at startup and never cached, so the check stays correct as teams change.
Common use cases
Owner and teammate locking
Deny switches on mix tables owned by another player unless the sender is on the owner's team. Returning a value blocks the state change without touching the entity.
Building privilege requirement
Check
mixingTable.GetBuildingPrivilege()andIsAuthed(player)so raiders cannot start or stop tables inside a protected base they do not own.Usage logging and stats
Record who toggled the table, where it is, and whether it was switched on, then report totals to admins. Return null so the switch proceeds normally.
Pitfalls
State is not changed yet
The game reads the requested on/off bit after the hook, so
mixingTable.IsOn()still reflects the old state inside your hook. Do not use it to tell whether the player is starting or stopping a mix.Returning false still blocks
This site checks only for a non-null return. Returning
falseis treated as blocking, so always returnnullwhen you want to allow the switch.player can be null
The decompiled call passes
msg.playerstraight through. Null-check it before reading permissions or team data to avoid a NullReferenceException.
Build a plugin with OnMixingTableToggle
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 OnMixingTableToggle
Generate