OnPlayerRespawned
OnPlayerRespawned is called after a player's respawn has been committed in BasePlayer.RespawnAt, right before the player enters the loading screen on the client.
void OnPlayerRespawned(BasePlayer player)Parameters
| Parameter | Type | Description |
|---|---|---|
player | BasePlayer | The BasePlayer that has just finished respawning. Already connected (or reconnected) at the load screen entry point, so you can chat, send commands and modify inventory immediately. |
Return value
The return value is ignored. The original RespawnAt method returns void and Oxide calls the hook without checking what you return, so returning null or any other value has no effect on respawn behavior.
How it works
The hook fires inside BasePlayer.RespawnAt, after the server has repositioned and reset the player and after EAC start-loading has been requested for connected clients, but before the mission event (RESPAWN) is processed and the injury state is recalculated. This is the point where the player exists as a valid entity with a spawn position and fresh health, so it is the right place to hand out gear, reset per-life state, or send a message.
Because the method runs for every respawn path (sleeping bag, bed, beach, and any call that ends up in RespawnAt), the hook covers both first spawns and re-spawns after death. The player argument is the already-valid BasePlayer; check IsNpc, IsConnected and team/membership data as needed since NPCs can also pass through respawn code.
Declaring the parameter as BasePlayer matches the game signature. Declaring BaseCombatEntity or BaseEntity would still receive the call, but you would lose the player-specific members. There is no narrower type that is useful here; keep BasePlayer.
Example plugin: Give a starter kit on each respawn
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("Respawn Kit", "RustPluginGenerator", "1.0.0")]
[Description("Gives a configurable kit to players when they respawn.")]
public class RespawnKit : RustPlugin
{
private const string PermBypass = "respawnkit.bypass";
private PluginConfig config;
private readonly Dictionary<ulong, float> lastGiven = new Dictionary<ulong, float>();
private class KitItem
{
[JsonProperty("Shortname")] public string Shortname { get; set; } = "rock";
[JsonProperty("Amount")] public int Amount { get; set; } = 1;
}
private class PluginConfig
{
[JsonProperty("Enable kit")] public bool Enabled { get; set; } = true;
[JsonProperty("Cooldown seconds")] public float Cooldown { get; set; } = 120f;
[JsonProperty("Give on first respawn only")] public bool FirstOnly { get; set; } = false;
[JsonProperty("Kit items")] public List<KitItem> Items { get; set; } = new List<KitItem>
{
new KitItem { Shortname = "bandage", Amount = 3 },
new KitItem { Shortname = "apple", Amount = 2 },
new KitItem { Shortname = "torch", Amount = 1 }
};
}
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>
{
["KitGiven"] = "You received a respawn kit.",
["KitReadyIn"] = "Your next respawn kit is ready in {0} seconds."
}, 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 void Unload()
{
lastGiven.Clear();
}
private void OnPlayerRespawned(BasePlayer player)
{
if (!config.Enabled || player == null || player.IsNpc || !player.IsConnected) return;
if (!player.IsAlive()) return;
string id = player.UserIDString;
float now = Time.realtimeSinceStartup;
float last;
if (lastGiven.TryGetValue(player.userID, out last) && !permission.UserHasPermission(id, PermBypass))
{
float remaining = config.Cooldown - (now - last);
if (remaining > 0f)
{
if (config.FirstOnly)
player.ChatMessage(Msg("KitReadyIn", id, Mathf.CeilToInt(remaining)));
return;
}
}
lastGiven[player.userID] = now;
foreach (KitItem entry in config.Items)
{
if (string.IsNullOrEmpty(entry.Shortname) || entry.Amount <= 0) continue;
Item item = ItemManager.CreateByName(entry.Shortname, entry.Amount);
if (item == null) continue;
if (item.info.category == ItemCategory.Weapon || item.info.category == ItemCategory.Tool)
player.GiveItem(item);
else if (!player.inventory.containerBelt.IsFull() || !player.inventory.containerMain.IsFull())
item.MoveToContainer(player.inventory.containerBelt.IsFull()
? player.inventory.containerMain
: player.inventory.containerBelt);
else
player.GiveItem(item);
}
player.ChatMessage(Msg("KitGiven", id));
}
}
}The plugin hands out a configurable set of items every time a player respawns, but only if the player is actually connected and human (not an NPC) and only if the previous respawn was more than a configured cooldown ago. A Dictionary<ulong, float> stores each player's last spawn time using Time.realtimeSinceStartup, which avoids pulling in DateTime. Items are created with ItemManager.CreateByName and moved into the belt or main container, and a chat line is sent once. Config lets admins toggle kits, set the cooldown, and define which shortnames and amounts to give, all read through the standard Oxide config lifecycle.
Common use cases
Starter kit delivery
Hand freshly spawned players a defined set of tools, food and clothes without writing a separate spawn hook. The player is guaranteed to exist with a valid inventory at this point.
Per-life state reset
Clear temporary buffs, UI overlays or bounty flags stored in memory so a new life starts clean. Combined with the respawn counter, admins can track deaths per session.
Spawn greeting and rules reminder
Send a ChatMessage with server rules, a command list, or a welcome line on respawn. Because the client is entering the loading screen, chat arrives once they are back in the world.
Pitfalls
Called for NPCs too
Scientist and animal respawn code can reach the same method. Always check
player.IsNpcbefore touching inventories or sending chat, otherwise you risk null reference or console spam.Fires on first spawn and every respawn
Use a stored timestamp or a flag book to avoid handing out kits on every beach wipe (which can be exploited to farm items). A cooldown keyed on
userIDis the simplest fix.Client not yet in world
The player is in the loading screen when this runs, so UI created here can be dropped. Send chat with
ChatMessageor schedule UI withtimer.Onceif you need a visible panel.
Plugin recipes that use OnPlayerRespawned
- How to make a Rust group respawn kit plugin (Oxide/Carbon)Gives each player a respawn loadout based on the highest-priority Oxide group they belong to. It uses OnPlayerRespawned and reads loadouts from the plugin config.
- How to make a Rust respawn loadout plugin (save belt and clothing, restore on respawn)Lets players save their belt and clothing items with /loadout save, then automatically hands that gear back when they respawn. Uses the OnPlayerRespawned hook plus a per-player permission and cooldown.
- 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.
- How to make a Rust server currency plugin (Oxide balances + /pay)A wallet plugin that stores per-player balances in a data file, exposes /balance, /pay and admin give/take console commands, saves on OnServerSave, and publishes GetBalance/Deposit/Withdraw for other plugins.
- How to make a Rust sleeping bag cooldown plugin (Oxide/Carbon)Overrides the respawn cooldown on sleeping bags and beds to a fixed number of seconds, with a separate shorter cooldown for a VIP permission. Uses OnEntitySpawned, OnPlayerRespawned and a startup sweep in OnServerInitialized.
- How to make a Rust starter kit plugin (on respawn)Gives every respawning player a configurable starter kit instead of the default rock and torch. Uses OnPlayerRespawned to strip the default inventory, place clothing in the wear container, tools in the belt, and items in the main inventory.
Build a plugin with OnPlayerRespawned
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 OnPlayerRespawned
Generate