Skip to content
RustPluginGenerator

How to make a Rust respawn vitals plugin (health, food, water)

Sets a player's health, calories and hydration to configured values right after respawn, with a separate VIP profile gated behind a permission. It uses the OnPlayerRespawned hook.

Freshly respawned players start with default vitals, which forces every server that wants a specific start-of-life loadout to explain it in rules or hand it out manually. This plugin hooks the moment a player is placed back into the world after death and overwrites health, calories and hydration from config, so every respawn is identical and predictable. A second set of values is applied to players holding a VIP permission, letting you sell or reward a sturdier respawn without touching the base experience. Values are clamped to the player's maximum health and to the vanilla calorie and hydration range, so a typo in config cannot create an immortal player. Two chat commands let admins preview the current values and reload the config without restarting the server.

The plugin code

RespawnVitals.cs
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("Respawn Vitals", "RustPluginGenerator", "1.0.0")]
    [Description("Sets health, calories and hydration to configured values when a player respawns.")]
    public class RespawnVitals : RustPlugin
    {
        private const string PermVip = "respawnvitals.vip";
        private const string PermAdmin = "respawnvitals.admin";

        private PluginConfig config;

        private class VitalsProfile
        {
            [JsonProperty("Health")]
            public float Health { get; set; }

            [JsonProperty("Calories")]
            public float Calories { get; set; }

            [JsonProperty("Hydration")]
            public float Hydration { get; set; }

            public VitalsProfile() { }

            public VitalsProfile(float health, float calories, float hydration)
            {
                Health = health;
                Calories = calories;
                Hydration = hydration;
            }
        }

        private class PluginConfig
        {
            [JsonProperty("Default respawn vitals")]
            public VitalsProfile Default { get; set; }

            [JsonProperty("VIP respawn vitals")]
            public VitalsProfile VIP { get; set; }

            public PluginConfig()
            {
                Default = new VitalsProfile(100f, 250f, 250f);
                VIP = new VitalsProfile(100f, 450f, 450f);
            }
        }

        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>
            {
                ["Vitals"] = "Respawn vitals - Default: {0} HP / {1} cal / {2} water. VIP: {3} HP / {4} cal / {5} water.",
                ["Reloaded"] = "Respawn vitals reloaded from oxide/config/RespawnVitals.json.",
                ["NoPermission"] = "You do not have permission to use this command."
            }, 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(PermVip, this);
            permission.RegisterPermission(PermAdmin, this);
        }

        private void OnPlayerRespawned(BasePlayer player)
        {
            if (player == null || player.IsNpc) return;

            VitalsProfile profile = permission.UserHasPermission(player.UserIDString, PermVip)
                ? config.VIP
                : config.Default;

            if (profile == null) return;

            float health = Mathf.Clamp(profile.Health, 1f, player.MaxHealth());
            float calories = Mathf.Clamp(profile.Calories, 0f, 500f);
            float hydration = Mathf.Clamp(profile.Hydration, 0f, 500f);

            if (player.health < health)
            {
                player.Heal(health - player.health);
            }
            else if (player.health > health)
            {
                player.Hurt(player.health - health);
            }

            player.metabolism.calories.value = calories;
            player.metabolism.hydration.value = hydration;
            player.SendNetworkUpdate();
        }

        [ChatCommand("vitals")]
        private void CmdVitals(BasePlayer player, string command, string[] args)
        {
            if (player == null) return;

            if (!permission.UserHasPermission(player.UserIDString, PermAdmin))
            {
                SendReply(player, Msg("NoPermission", player.UserIDString));
                return;
            }

            if (args != null && args.Length > 0 && args[0].ToLower() == "reload")
            {
                LoadConfig();
                SendReply(player, Msg("Reloaded", player.UserIDString));
                return;
            }

            SendReply(player, Msg("Vitals", player.UserIDString,
                config.Default.Health, config.Default.Calories, config.Default.Hydration,
                config.VIP.Health, config.VIP.Calories, config.VIP.Hydration));
        }
    }
}

Hooks used: OnPlayerRespawned

Config file

Created automatically on first load at oxide/config/RespawnVitals.json.

RespawnVitals.json
{
  "Default respawn vitals": {
    "Health": 100,
    "Calories": 250,
    "Hydration": 250
  },
  "VIP respawn vitals": {
    "Health": 100,
    "Calories": 450,
    "Hydration": 450
  }
}

Commands and permissions

Chat and console commands
CommandWhat it doesPermission
/vitalsShows the default and VIP respawn values currently loaded from config.respawnvitals.admin
/vitals reloadReloads oxide/config/RespawnVitals.json and confirms the new values.respawnvitals.admin
Permissions
PermissionGrants
respawnvitals.vipGives the player the VIP respawn health, calories and hydration instead of the defaults.
respawnvitals.adminAllows use of the /vitals chat commands.

How the code works

  1. Apply values when the player is back in the world

    The plugin implements void OnPlayerRespawned(BasePlayer player), which Oxide calls after a player has been respawned. The hook null-checks the player and ignores NPCs. It then picks the VIP or default profile, clamps health to player.MaxHealth() and calories/hydration to 0-500 (the vanilla range), and writes player.metabolism.calories.value and player.metabolism.hydration.value. Health is adjusted with Heal or Hurt so the game's own clamping applies, then SendNetworkUpdate pushes the new vitals to the client.

  2. Why Heal and Hurt instead of setting health directly

    Heal(float) and Hurt(float) are the public API for moving health and apply the game's own clamping and effects. Assigning player.health directly bypasses that and can leave a player above their maximum if their max health changes later (food buffs, gear). The plugin reads MaxHealth() first so the configured value cannot exceed what the player can actually hold.

  3. VIP profile by permission

    At respawn the hook calls permission.UserHasPermission(player.UserIDString, PermVip). If it returns true the VIP block from config is used, otherwise the default block. Both blocks are plain nested classes with [JsonProperty] names, so oxide/config/RespawnVitals.json stays readable. Nothing is cached between respawns, so granting or revoking the permission takes effect on the next death without a reload.

  4. Config with safe defaults

    LoadDefaultConfig builds a PluginConfig with Default and VIP sub-objects. LoadConfig reads the file, and on any parse error it warns and falls back to defaults instead of leaving config null. The defaults use 100 health, 250 calories and 250 hydration, which matches a standard spawn, so installing the plugin changes nothing until you edit the file.

  5. Clamping protects the server

    A config mistake like "Health": 5000 would otherwise want to set a player far past their maximum. Mathf.Clamp is applied to the configured values before use: health against MaxHealth(), calories and hydration against 0 and 500. The clamp runs on every respawn so it also covers players whose max health differs from the default 100.

  6. Admin preview and reload commands

    [ChatCommand("vitals")] handles both /vitals and /vitals reload, and both paths check respawnvitals.admin before doing anything. The plain command prints the six configured numbers through lang, and reload calls the plugin's config loader and saves the file so future edits start from the current values. All player-facing text goes through the language file so you can translate it.

Install it on your server

  1. Save RespawnVitals.cs

    Keep the file name exactly as the class name. Oxide matches them.
  2. Upload it to the plugins folder

    Oxide: oxide/plugins/. Carbon: carbon/plugins/. The server compiles and loads it within a few seconds, no restart needed.
  3. Edit the config if you want

    On first load the default config is written to oxide/config/RespawnVitals.json (Carbon: carbon/configs/RespawnVitals.json). After editing, reload it:oxide.reload RespawnVitals c.reload RespawnVitals # Carbon
  4. Grant the permission

    Give it to every player, or swap default for a group such as vip:oxide.grant group default respawnvitals.vip c.grant group default respawnvitals.vip # Carbon

Variations

Each one opens the generator with a ready prompt you can tweak.

  • Randomised respawn vitals

    Give each respawn a random value inside a configured min/max range instead of a fixed number.

    Generate this version
  • First-respawn bonus only

    Apply the boosted values only the first time a player ever respawns on the server.

    Generate this version
  • Wipe-day boost window

    Use generous VIP values for a configurable number of hours after a wipe.

    Generate this version

FAQ

Will this plugin overwrite a player's health if they respawn with food already in their inventory?

Yes. The values are written after the respawn completes, so anything in the player's metabolism is replaced at that moment. If you want vanilla behaviour to continue, raise the calories and hydration in config or set them to 500 so the player spawns full and normal hunger handling takes over from there.

Does it work on Carbon?

Yes. Carbon loads the same Oxide plugin file and dispatches OnPlayerRespawned the same way. Drop RespawnVitals.cs into carbon/plugins and the config file appears under carbon/config after the first load.

How do I install it?

Place the .cs file in oxide/plugins (or carbon/plugins) and let the server compile it. Grant respawnvitals.vip to a group with oxide.grant group vip respawnvitals.vip, then edit oxide/config/RespawnVitals.json. Use /vitals reload after edits.

Why does my player still die right after respawn?

If health is set to a low value and the player respawns in a hostile area, they can die before they move. Keep default health at 100 and rely on calories/hydration for the survival feel. Also make sure no other plugin sets health afterwards; later respawn hooks run after this one.

Can I give VIP players more than 100 health?

Not by default, because health is capped by MaxHealth(), which is 100 unless gear or other plugins change it. The plugin will still try, and will fill the player to their current maximum. To go above 100 you would need a separate max-health mechanic.

Customize it for your server

Change the reward, add a cooldown, restrict it to VIPs. Start from this prompt and edit anything.

Prompt: Write a Rust Oxide plugin called RespawnVitals that sets respawn health to 100, calories to 250 and hydration to 250, with VIP values of 100/450/450 behind the respawnvitals.vip permission and an admin /vitals command.
Customize for my server

Edit the prompt on the next screen. 2 free plugins a month, no card.

Last updated Oct 26, 2026.

Customize respawn health and food

Customize