Skip to content
RustPluginGenerator

OnUserRespawned

OnUserRespawned is called after a player has respawned and their player entity exists again, fired by Oxide's Rust core wrapper once the respawn completes. It gives plugins a single place to react to a fresh life without patching the game.

Signature
void OnUserRespawned(IPlayer iplayer)

Parameters

Hook parameters
ParameterTypeDescription
iplayerIPlayerThe Oxide IPlayer wrapper of the player who just respawned. Use iplayer.Object to get the BasePlayer and iplayer.Id / iplayer.Name for identity; null-check it and its Object before touching the entity.

Return value

The return value is ignored. Oxide only calls the hook when the IPlayer wrapper exists; returning anything has no effect on the respawn flow.

How it works

Oxide fires this hook from RustCore.OnPlayerRespawned, which runs after the game has processed a player's respawn. The injection looks up basePlayer.IPlayer and calls the hook only when that wrapper exists, so it fires once per completed respawn, not while the player is a corpse or sleeping. It is a core hook rather than a patch on a specific game method, so it triggers for any respawn path that ends in OnPlayerRespawned, including waking from a bed or bag and a normal death respawn.

The single parameter is the IPlayer object. To touch the world, read iplayer.Object as BasePlayer; the player may be null if they disconnected in the same frame, so guard it. Because the player entity is live again you can safely teleport, give items, send chat, or push CUI from here.

OnUserRespawned is the post-respawn companion to OnPlayerRespawn, which runs slightly earlier in the respawn flow. Use this one when you want to act on the finished result. Keep the handler cheap: it fires per respawn, and the plugin API (Puts, PrintWarning) should stay out of the hot path if many players respawn at once, such as after a wipe.

Example plugin: Give respawning players configured starter items

RespawnStarterKit.cs
using System.Linq;
using Oxide.Core.Libraries.Covalence;
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;

namespace Oxide.Plugins
{
    [Info("Respawn Starter Kit", "RustPluginGenerator", "1.0.0")]
    [Description("Gives configured starter items to a player when they respawn.")]
    public class RespawnStarterKit : RustPlugin
    {
        private const string PermGrant = "respawnstarterkit.grant";

        private PluginConfig config;

        private class PluginConfig
        {
            [JsonProperty("Items granted on respawn")]
            public List<KitItem> Items = new List<KitItem>
            {
                new KitItem { Shortname = "bandage", Amount = 3, Permission = "" },
                new KitItem { Shortname = "torch", Amount = 1, Permission = "" }
            };
        }

        private class KitItem
        {
            [JsonProperty("Shortname")]
            public string Shortname = "bandage";

            [JsonProperty("Amount")]
            public int Amount = 1;

            [JsonProperty("Permission (blank = everyone)")]
            public string Permission = "";
        }

        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 void Init()
        {
            permission.RegisterPermission(PermGrant, this);
            foreach (KitItem item in config.Items)
            {
                if (!string.IsNullOrEmpty(item.Permission))
                {
                    permission.RegisterPermission(item.Permission, this);
                }
            }
        }

        private void OnUserRespawned(IPlayer iplayer)
        {
            if (iplayer == null) return;
            BasePlayer player = iplayer.Object as BasePlayer;
            if (player == null || !player.IsConnected) return;

            foreach (KitItem entry in config.Items)
            {
                if (entry == null || string.IsNullOrEmpty(entry.Shortname)) continue;
                if (!string.IsNullOrEmpty(entry.Permission) && !permission.UserHasPermission(player.UserIDString, entry.Permission))
                {
                    continue;
                }

                Item item = ItemManager.CreateByName(entry.Shortname, Math.Max(1, entry.Amount));
                if (item == null)
                {
                    PrintWarning($"Starter kit shortname '{entry.Shortname}' is invalid and was skipped");
                    continue;
                }
                player.GiveItem(item);
            }
        }
    }
}

The plugin reads a config list of shortnames and amounts, each with a permission that unlocks it. When a player respawns, OnUserRespawned pulls the BasePlayer out of the IPlayer, then loops the kit entries and grants only those the player is permitted for (entries with an empty permission are open to everyone). Each granted shortname is validated with ItemManager.CreateByName, and the item is given via player.GiveItem; anything that cannot be created is reported once with PrintWarning instead of spamming. LoadDefaultConfig seeds a sensible default kit so the plugin works out of the box after install.

Common use cases

  • Starter kit at respawn

    Hand a fresh life a small kit, gated per permission, without touching death or bag hooks.

  • Spawn protection toggle

    Flip a short-lived invulnerability flag or notify the player that protection is active the moment they respawn.

  • Respawn announcement

    Send a chat or console message confirming a respawn, or push a small CUI notice that clears after a few seconds.

Pitfalls

  • iplayer.Object can be null

    The IPlayer wrapper can exist while the entity is gone if the player disconnects at the wrong moment; always null-check iplayer and iplayer.Object before acting.

  • Runs alongside OnPlayerRespawn

    Do not duplicate logic in both hooks, or players may receive items twice; pick one for the finished respawn.

  • Not every spawn is a respawn

    First join, team bag and bed use all route through respawn, so gate anything join-only with a separate flag.

Build a plugin with OnUserRespawned

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

Prompt: Starter kit at respawn using the OnUserRespawned 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 OnUserRespawned

Generate