Skip to content
RustPluginGenerator

OnPlayerRevive

OnPlayerRevive is called when a medical tool (or defibrillator) with revive ability is applied to a wounded player, before the game actually stops their wounded state.

Signature
object OnPlayerRevive(BasePlayer fromPlayer, BasePlayer player)

Parameters

Hook parameters
ParameterTypeDescription
fromPlayerBasePlayerThe BasePlayer who applied the medical tool (reviver). It can be the server-spawned or another player, but is never the downed player himself.
playerBasePlayerThe BasePlayer who is wounded and would be brought back up by this medical action.

Return value

Returning a non-null value stops the original code path, so StopWounded is never called and the target stays wounded. Returning null lets the game proceed and revive the player normally. Because the check tests only != null, even false blocks the revive.

How it works

The hook fires inside BasePlayer.OnMedicalToolApplied after the game has confirmed three conditions: the reviver is not the target, the target IsWounded(), and the applied item reports canRevive. That covers a defibrillator or any other medical tool configured to revive, when another player uses it on a downed body. The call happens before StopWounded(fromPlayer), so at this point the target is still wounded and can be cancelled.

fromPlayer is the player performing the revive; player is the wounded player being revived. Both are always present, but either can be null if the surrounding game state is unusual, so guard them. There is no narrower overload available: declaring more specific types here does not help because the game already passes BasePlayer instances.

This is the right place to implement rules about who may revive, revive cooldowns, penalties, or logging. Because the return check uses only a non-null value, returning any object (for example true or a string) suppresses the revive entirely; returning null lets the normal StopWounded run.

Example plugin: Team-only revive for defibrillator

TeamOnlyRevive.cs
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("Team Only Revive", "RustPluginGenerator", "1.0.0")]
    [Description("Restricts reviving to teammates and applies a per-player revive cooldown.")]
    public class TeamOnlyRevive : RustPlugin
    {
        private const float CooldownSeconds = 15f;
        private readonly Dictionary<ulong, float> lastRevive = new Dictionary<ulong, float>();

        private class PluginConfig
        {
            [JsonProperty("Require same team")] public bool RequireSameTeam = true;
            [JsonProperty("Enable cooldown")] public bool EnableCooldown = true;
        }

        private PluginConfig config;

        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"] = "You cannot revive this player.",
                ["Cooldown"] = "You must wait {0:0}s before reviving again."
            }, this);
        }

        private string Msg(string key, string userId = null, params object[] args) => string.Format(lang.GetMessage(key, this, userId), args);

        private object OnPlayerRevive(BasePlayer fromPlayer, BasePlayer player)
        {
            if (fromPlayer == null || player == null) return null;

            if (config.RequireSameTeam)
            {
                bool sameTeam = fromPlayer.currentTeam != 0 && fromPlayer.currentTeam == player.currentTeam;
                if (!sameTeam)
                {
                    SendReply(fromPlayer, Msg("Blocked", fromPlayer.UserIDString));
                    return true;
                }
            }

            if (config.EnableCooldown)
            {
                float now = Time.realtimeSinceStartup;
                if (lastRevive.TryGetValue(fromPlayer.userID, out float last) && now - last < CooldownSeconds)
                {
                    SendReply(fromPlayer, Msg("Cooldown", fromPlayer.UserIDString, CooldownSeconds - (now - last)));
                    return true;
                }
                lastRevive[fromPlayer.userID] = now;
            }

            return null;
        }

        private void Unload()
        {
            lastRevive.Clear();
        }
    }
}

This plugin blocks a revive when the reviver and the downed player are not on the same team, and replies to the reviver with a short message. Config allows toggling the team check and an optional cooldown per reviver. OnPlayerRevive first null-checks both players, then verifies teams via currentTeam; if teams differ (or either has no team), it sends the configured Blocked message and returns true to cancel the revive. A per-user cooldown tracked with UnityEngine.Time.realtimeSinceStartup limits rapid revives with a defibrillator. Messages live in lang so admins can translate them, and cooldown state is cleared in Unload.

Common use cases

  • Team-only revive rules

    Only allow a defibrillator to bring back teammates, blocking random revives in PvP zones or on event servers.

  • Revive cooldown or cost

    Enforce a cooldown between revives, or hook an Economy plugin's Call to charge a fee and return non-null to cancel when the player cannot pay.

  • Admin/whitelist restriction

    Allow only players with a specific permission to revive others, useful for event or roleplay servers with designated medics.

Pitfalls

  • Any non-null blocks the revive

    Because the game checks != null only, returning false also blocks the revive. Return null when you want the revive to proceed.

  • Not called for self-healing

    The game already skips the revive call when fromPlayer == this, so a downed player cannot revive themselves through this hook.

  • Runs only when canRevive is true

    Items that heal but do not have revive capability never reach this hook, so do not assume every medical item triggers it.

Build a plugin with OnPlayerRevive

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

Prompt: Team-only revive rules using the OnPlayerRevive 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 OnPlayerRevive

Generate