Skip to content
RustPluginGenerator

OnRunPlayerMetabolism

OnRunPlayerMetabolism is called right before the game runs its own metabolism update for a player. Returning a non-null value skips the vanilla metabolism pass for that tick.

Signature
object OnRunPlayerMetabolism(PlayerMetabolism playerMetabolism, BaseCombatEntity ownerEntity, float delta)

Parameters

Hook parameters
ParameterTypeDescription
playerMetabolismPlayerMetabolismThe PlayerMetabolism instance of the player being processed. Holds calories, hydration, temperature, bleeding, radiation and similar stat values you can read or write.
ownerEntityBaseCombatEntityThe BaseCombatEntity that owns this metabolism, normally the BasePlayer. Can be null or another combat entity in edge cases, so null-check before use.
deltafloatSeconds elapsed since the last metabolism tick (a small float). Useful for scaling any custom per-second stat changes you apply.

Return value

Returning null lets the vanilla metabolism update run normally. Returning any non-null value makes RunMetabolism return immediately, so the game's own stat simulation is skipped for that tick and you are responsible for applying the changes yourself.

How it works

The hook fires inside PlayerMetabolism.RunMetabolism, which the game calls repeatedly to advance calorie, hydration, temperature, bleeding and related stat simulation for a combat entity. It runs per owner entity on a recurring tick, so with many players it is a high-frequency hook — keep the body cheap and avoid logging.

playerMetabolism gives you the live stat object: you can read or adjust calories, hydration, temperature, radiation_level, bleeding and similar fields before the vanilla pass runs. ownerEntity is the owning combat entity, usually the BasePlayer; declaring it as BasePlayer narrows dispatch so the hook is skipped for non-player owners. delta is the elapsed time for this step.

Returning any non-null value makes RunMetabolism return immediately, skipping the vanilla update for that tick. This suits custom survival or hunger systems that fully replace metabolism, but it also means you must handle bleeding, temperature and stat clamping yourself when you suppress vanilla. Returning null lets the normal update proceed.

Example plugin: Replace bleeding with a custom damage-over-time

RunPlayerMetabolismBleed.cs
using System;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("RunPlayerMetabolismBleed", "RustPluginGenerator", "1.0.0")]
    [Description("Converts player bleeding into a configurable damage-over-time effect each metabolism tick.")]
    public class RunPlayerMetabolismBleed : RustPlugin
    {
        private const float MinDamage = 0.01f;

        private PluginConfig config;

        private class PluginConfig
        {
            [JsonProperty("Damage per second while bleeding")]
            public float DamagePerSecond = 2.5f;
        }

        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);

        private object OnRunPlayerMetabolism(PlayerMetabolism playerMetabolism, BaseCombatEntity ownerEntity, float delta)
        {
            if (playerMetabolism == null || ownerEntity == null || delta <= 0f) return null;

            var player = ownerEntity as BasePlayer;
            if (player == null || player.IsDead() || player.IsNpc) return null;
            if (playerMetabolism.bleeding == null || playerMetabolism.bleeding.value <= 0f) return null;

            float damage = config.DamagePerSecond * delta;
            if (damage < MinDamage) return null;

            player.Hurt(damage);
            return null;
        }
    }
}

The plugin keeps vanilla metabolism running (returns null) so hunger, hydration and temperature still work, but independently turns bleeding into a scaled damage-over-time. Each metabolism tick it reads playerMetabolism.bleeding, and while it is above zero it applies delta * DamagePerSecond damage to the owning player via player.Hurt. If the owner is not a live, non-NPC BasePlayer, or the computed damage is below 0.01, nothing is applied. A config field (DamagePerSecond) controls the damage rate so admins can tune severity without recompiling.

Common use cases

  • Custom hunger and thirst systems

    Return non-null to suppress vanilla calorie and hydration drain, then apply your own stat changes scaled by delta for a custom survival ruleset.

  • Bleeding rebalance

    Read playerMetabolism.bleeding and convert it into your own health drain or status effect while leaving other stats to vanilla.

  • Radiation or temperature overrides

    Adjust radiation_level or temperature before the vanilla pass to implement zones the base game does not support.

Pitfalls

  • Returning non-null skips all vanilla metabolism

    A non-null return stops the entire update for that tick, including bleeding, temperature and stat clamping. If you only want to tweak one stat, return null after editing the metabolism object instead of suppressing the pass.

  • High frequency hook

    This runs on every metabolism tick for every combat entity. Avoid Puts, PrintWarning, allocations and expensive lookups inside the body.

  • ownerEntity may not be a player

    Declare the parameter as BasePlayer to narrow dispatch, or null-check ownerEntity and cast carefully before calling player-only methods.

Build a plugin with OnRunPlayerMetabolism

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

Prompt: Custom hunger and thirst systems using the OnRunPlayerMetabolism 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 OnRunPlayerMetabolism

Generate