OnOvenStart
OnOvenStart is called when a BaseOven (furnace, campfire, BBQ and other cookers) tries to begin a cooking session via BaseOven.StartCooking. Returning a non-null value stops the oven from starting.
object OnOvenStart(BaseOven oven)Parameters
| Parameter | Type | Description |
|---|---|---|
oven | BaseOven | The BaseOven entity that is about to start cooking. Check its type (BaseOven covers furnaces, campfires and similar cookers), OwnerID, position or inventory contents to decide whether to allow the start. |
Return value
Return null to let the oven start cooking normally. Return any non-null value to skip the rest of StartCooking, so the oven is not added to the cook queue and no temperature is applied; for this void method the returned value itself is discarded.
How it works
The hook fires inside BaseOven.StartCooking, before the oven sets its inventory temperature, adds itself to the cook queue and resets lastCookUpdate. StartCooking is the internal method the game runs when an oven is switched on or when it tries to resume cooking, so the hook covers both player toggles and automatic restarts. At the moment of the call the oven has not yet been queued for cooking, so blocking the hook leaves it in its previous state. The single parameter is the oven entity itself: use oven.OwnerID, oven.transform.position, oven.inventory.itemList or a as cast to a more specific cooker type to make a decision. Because the only parameter is already typed BaseOven, narrowing with a subclass (for example BaseOven is not subclassed here) is not needed; the useful narrowing is your own type checks on the instance. Do not run long loops here; ovens start frequently on busy servers and the method runs on the main thread.
Example plugin: Block cooking on ovens inside blocked zones
using System.Linq;
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("Oven Zone Guard", "RustPluginGenerator", "1.0.0")]
[Description("Blocks ovens from starting when they stand inside configured zones")]
public class OvenZoneGuard : RustPlugin
{
private const string PermBypass = "ovenzoneguard.bypass";
private PluginConfig config;
private readonly Dictionary<ulong, float> lastNotice = new Dictionary<ulong, float>();
private class PluginConfig
{
[JsonProperty("Blocked zones")]
public List<Zone> Zones = new List<Zone>
{
new Zone { MinX = 0f, MinZ = 0f, MaxX = 10f, MaxZ = 10f }
};
}
private class Zone
{
[JsonProperty("Minimum X")]
public float MinX;
[JsonProperty("Minimum Z")]
public float MinZ;
[JsonProperty("Maximum X")]
public float MaxX;
[JsonProperty("Maximum Z")]
public float MaxZ;
public bool Contains(Vector3 position)
{
return position.x >= MinX && position.x <= MaxX && position.z >= MinZ && position.z <= MaxZ;
}
}
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>
{
["Blocked"] = "This area does not allow cooking."
}, 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(PermBypass, this);
}
private object OnOvenStart(BaseOven oven)
{
if (oven == null || oven.IsDestroyed || config?.Zones == null) return null;
Vector3 position = oven.transform.position;
bool blocked = false;
for (int i = 0; i < config.Zones.Count; i++)
{
Zone zone = config.Zones[i];
if (zone != null && zone.Contains(position))
{
blocked = true;
break;
}
}
if (!blocked) return null;
foreach (BasePlayer player in BasePlayer.activePlayerList)
{
if (player == null || !player.IsConnected) continue;
if (Vector3.Distance(player.transform.position, position) > 6f) continue;
if (permission.UserHasPermission(player.UserIDString, PermBypass)) return null;
Notify(player);
}
return true;
}
private void Notify(BasePlayer player)
{
float now = UnityEngine.Time.realtimeSinceStartup;
float last;
if (lastNotice.TryGetValue(player.userID, out last) && now - last < 5f) return;
lastNotice[player.userID] = now;
player.ChatMessage(Msg("Blocked", player.UserIDString));
}
private void Unload()
{
lastNotice.Clear();
}
}
}The plugin stores a list of blocked rectangular areas in its config and refuses cooking for any oven whose position falls inside one of them. OnOvenStart checks oven.IsDestroyed and oven.OwnerID, then tests the oven position against every configured zone. When a zone matches, the hook returns a non-null value, which prevents BaseOven.StartCooking from running. Players are told through chat via a localized message, throttled so a player spamming the use button does not flood their console. Config validation in LoadConfig falls back to defaults on bad JSON, and the zone coordinates are edited in oxide/config/OvenZoneGuard.json.
Common use cases
Restrict furnaces in PvP zones
Prevent ovens inside a raid or event area from starting so raiders cannot smelt ore mid-fight. Return a non-null value when the oven position is inside a configured zone.
Whitelist cookers by owner permission
Allow only players with a permission to start campfires or furnaces, for example on a roleplay or event server. Check
oven.OwnerIDagainstpermission.UserHasPermissionand block everyone else.Freeze cooking during server events
Toggle a flag while a custom event runs and return a non-null value from the hook so all ovens pause. Flip the flag off when the event ends and check it before deciding.
Pitfalls
The hook fires before fuel checks
StartCooking is called even when the oven has no burnable item; the game checks
FindBurnable()after the hook. Blocking based on fuel state will also block ovens that would have failed to start anyway.OwnerID is not always a player
For ovens spawned by the map or by plugins
OwnerIDis 0 or a non-player id. If you key behaviour off the owner, handle the zero case instead of assuming a connected player.Returning false does not allow cooking
The return value is checked against null. Returning
falseis a non-null value and therefore blocks the start just like returningtrue. Always returnnullto permit cooking.
Build a plugin with OnOvenStart
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 OnOvenStart
Generate