Skip to content
RustPluginGenerator

OnPlayerAssist

OnPlayerAssist is called when one player revives another wounded player, before the wounded player is stood back up and the assist/revive stats are recorded.

Signature
object OnPlayerAssist(BasePlayer player, BasePlayer player2)

Parameters

Hook parameters
ParameterTypeDescription
playerBasePlayerThe wounded player being helped. This is the entity that invoked the assist RPC on themselves (the 'this' in BasePlayer.RPC_Assist), so it is always wounded when the hook runs.
player2BasePlayerThe player performing the assist, taken from the incoming RPC message. This is the player who pressed the assist key and who would normally revive the wounded player.

Return value

Return null (or nothing) to let the revive proceed normally. Return any non-null value to stop the original code path, which means the wounded player is not revived and the assist/revive stats are not recorded.

How it works

This hook fires from BasePlayer.RPC_Assist, the RPC a player sends to help a nearby wounded player. The game first checks that the assisting player can interact, that the two players are not the same, and that the target is wounded. Only then is OnPlayerAssist called, with the wounded player and the assisting player2. If nothing blocks it, the game calls StopWounded on the wounded player, increments the assister's wounded_assisted stat and the target's wounded_healed stat. Because the hook runs before those stats are written, blocking it also prevents the stat counters from updating. Declaring player as a more specific type has no practical effect here since both parameters are always BasePlayer. Use it to gate revives with cooldowns, permissions, team rules, or to reward medics. Return a non-null value to cancel the revive completely.

Example plugin: Restrict revives to teammates or allies

TeamReviveOnly.cs
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;

namespace Oxide.Plugins
{
    [Info("Team Revive Only", "RustPluginGenerator", "1.0.0")]
    [Description("Restricts reviving wounded players to their own teammates.")]
    public class TeamReviveOnly : RustPlugin
    {
        private const string PermAdmin = "teamreviveonly.admin";

        private PluginConfig config;

        private class PluginConfig
        {
            [JsonProperty("Only teammates can revive")]
            public bool TeamOnly { get; set; } = true;
        }

        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>
            {
                ["NotTeammate"] = "Only members of your team can revive you.",
                ["ToggleOn"] = "Team-only revives are enabled.",
                ["ToggleOff"] = "Team-only revives are disabled."
            }, this);
        }

        private string Msg(string key, string userId = null) => lang.GetMessage(key, this, userId);

        private void Init()
        {
            permission.RegisterPermission(PermAdmin, this);
        }

        private object OnPlayerAssist(BasePlayer player, BasePlayer player2)
        {
            if (player == null || player2 == null) return null;
            if (!config.TeamOnly) return null;
            if (player2.IsAdmin) return null;

            ulong teamA = player.currentTeam;
            ulong teamB = player2.currentTeam;

            if (teamA == 0 || teamB == 0 || teamA != teamB)
            {
                player2.ChatMessage(Msg("NotTeammate", player2.UserIDString));
                return true;
            }

            return null;
        }

        [ChatCommand("teamrevive")]
        private void CmdTeamRevive(BasePlayer player, string command, string[] args)
        {
            if (player == null) return;
            if (!permission.UserHasPermission(player.UserIDString, PermAdmin))
            {
                return;
            }

            config.TeamOnly = !config.TeamOnly;
            SaveConfig();
            player.ChatMessage(Msg(config.TeamOnly ? "ToggleOn" : "ToggleOff", player.UserIDString));
        }
    }
}

The plugin lets admins toggle a mode where a wounded player can only be revived by someone on the same team. In the hook it reads the config flag, checks that both players have a team and that the teams match, and if the assister is not a teammate it returns a non-null object to block the revive, then sends that player a localised message. Admins are still allowed through. The toggle is exposed as a chat command guarded by a permission and persists the setting to the config file so it survives restarts.

Common use cases

  • Block enemy revives in team modes

    Return a non-null value when the assisting player is not the wounded player's teammate, forcing coordinated revives and preventing enemies from finishing the wound.

  • Reward medics

    On a successful assist, grant the assisting player a small reward such as an item or currency, while still returning null to let the revive complete.

  • Add a revive cooldown

    Track the last assist time per player and block revives that come too quickly, returning a value to cancel and messaging the player.

Pitfalls

  • Both arguments are players

    player is the wounded one and player2 is the helper. Mixing them up will grant rewards or send messages to the wrong person.

  • Returning true is a veto

    This hook is not a permission check that returns true to allow; any non-null return cancels the revive. Return null to allow it.

  • Wounded state is not guaranteed later

    The wounded player may stop being wounded through other means (bleeding out, being finished). Don't cache state across ticks expecting the wound to persist.

Build a plugin with OnPlayerAssist

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

Prompt: Block enemy revives in team modes using the OnPlayerAssist 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 OnPlayerAssist

Generate