Skip to content
RustPluginGenerator

OnPatrolHelicopterKill

OnPatrolHelicopterKill is called from PatrolHelicopter.Hurt when incoming damage is about to reduce the helicopter's health to zero, before the game resets its health and runs the crash sequence.

Signature
object OnPatrolHelicopterKill(PatrolHelicopter patrolHelicopter, HitInfo info)

Parameters

Hook parameters
ParameterTypeDescription
patrolHelicopterPatrolHelicopterThe PatrolHelicopter entity whose health just dropped to or below zero. Check IsDestroyed and myAI before touching it, since the kill sequence has not run yet.
infoHitInfoThe HitInfo describing the lethal hit: InitiatorPlayer, Weapon, damageTypes, HitPositionWorld and isHeadshot. Can be null, so always null-check it before reading damage data.

Return value

Returning a non-null value stops PatrolHelicopter.Hurt before it resets health and triggers CriticalDamage(), so the helicopter survives that lethal hit (which usually means the caller or next hit will try again). Returning null lets the normal crash sequence proceed.

How it works

The hook fires inside PatrolHelicopter.Hurt at the moment info.damageTypes.Total() is greater than or equal to the helicopter's current health. That check covers every lethal blow regardless of source: bullets, rockets, C4, turrets or environmental damage. Because the call happens before base.health = 10000f and myAI.CriticalDamage(), the helicopter has not yet entered its crash state when your code runs.

Use patrolHelicopter to read position, owner, myAI state or net.ID.Value. Use info to find out who landed the hit via InitiatorPlayer and with what Weapon, or to read damageTypes.GetMajorityDamageType() and isHeadshot for a custom notification. Both the entity and info can be null on unusual damage paths, so guard them.

You can narrow the dispatch by declaring patrolHelicopter as a more specific type only if a subclass exists (there is not a common one here), so keep PatrolHelicopter. Declaring InitiatorPlayer as BasePlayer directly is not possible because it lives inside HitInfo. The hook fires once per lethal damage event; if you block it the same hit may be retried, so do not spam player-facing output from this hook.

Example plugin: Broadcast helicopter kills and reward the killer

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

namespace Oxide.Plugins
{
    [Info("HelicopterKillFeed", "RustPluginGenerator", "1.0.0")]
    [Description("Broadcasts Patrol Helicopter kills and rewards the killer")]
    public class HelicopterKillFeed : RustPlugin
    {
        private const string PermBroadcast = "helicopterkillfeed.broadcast";

        private PluginConfig config;
        private readonly Dictionary<ulong, Timer> handled = new Dictionary<ulong, Timer>();

        private class PluginConfig
        {
            [JsonProperty("Reward item shortname")]
            public string RewardShortname = "scrap";

            [JsonProperty("Reward amount")]
            public int RewardAmount = 100;

            [JsonProperty("Broadcast to all players")]
            public bool Broadcast = 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>
            {
                ["Kill"] = "{0} destroyed the Patrol Helicopter!",
                ["KillAnonymous"] = "The Patrol Helicopter was destroyed.",
                ["Reward"] = "You received {0} x {1} for the kill.",
                ["NoPerm"] = "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(PermBroadcast, this);
        }

        private object OnPatrolHelicopterKill(PatrolHelicopter patrolHelicopter, HitInfo info)
        {
            if (patrolHelicopter == null || patrolHelicopter.IsDestroyed) return null;

            ulong heliId = patrolHelicopter.net.ID.Value;
            if (handled.ContainsKey(heliId)) return null;

            Timer cleanup = timer.Once(60f, () => handled.Remove(heliId));
            handled[heliId] = cleanup;

            BasePlayer killer = info?.InitiatorPlayer;
            string killerName = killer != null && !killer.IsNpc ? killer.displayName : null;

            if (config.Broadcast)
            {
                string text = killerName != null
                    ? Msg("Kill", null, killerName)
                    : Msg("KillAnonymous");
                Server.Broadcast(text);
            }

            if (killer == null || killer.IsNpc || killer.IsDead()) return null;

            var reward = ItemManager.CreateByName(config.RewardShortname, config.RewardAmount);
            if (reward != null && killer.inventory.GiveItem(reward))
            {
                killer.ChatMessage(Msg("Reward", killer.UserIDString, config.RewardAmount, reward.info.displayName.english));
            }

            return null;
        }

        [ChatCommand("helikill")]
        private void CmdHeliKill(BasePlayer player, string command, string[] args)
        {
            if (player == null || !permission.UserHasPermission(player.UserIDString, PermBroadcast))
            {
                if (player != null) player.ChatMessage(Msg("NoPerm", player.UserIDString));
                return;
            }
            player.ChatMessage("Helicopter kill feed is active.");
        }

        private void Unload()
        {
            foreach (var entry in handled)
            {
                entry.Value?.Destroy();
            }
            handled.Clear();
        }
    }
}

The plugin listens to OnPatrolHelicopterKill and pulls the killer out of HitInfo.InitiatorPlayer. If the player is valid it broadcasts a server-wide message and gives a reward item from config to the killer's inventory. Kills by turrets or NPCs still get a generic broadcast without a reward. A short cooldown timer guards against the same helicopter finalizing twice in a burst of damage, and all text goes through the language file so admins can translate it.

Common use cases

  • Reward the pilot's killer

    Give the player in info.InitiatorPlayer a configured item or currency when they land the killing blow, skipping turret or NPC kill credit.

  • Discord-style kill feed

    Broadcast a chat line with the killer's display name and the helicopter's death position so the whole server knows an event just ended.

  • Track event results

    Store a timestamp, killer ID and damage type in a data file so admins can review who farms helicopters and how often.

Pitfalls

  • Returning a value keeps the helicopter alive

    Any non-null return from this hook skips the crash sequence in Hurt, so the helicopter will not die from that hit. Return null unless you intentionally want to cancel the kill.

  • info may be null

    Hurt can be called with a null HitInfo in some damage paths. Null-check info and info.InitiatorPlayer before reading Weapon or damage types, or your hook throws and the kill is aborted.

  • Fires per lethal hit, not once per entity

    Multiple damage instances can each satisfy the health threshold in the same tick. Guard against duplicate announcements with a short timer or a HashSet of helicopter net IDs you have already handled.

Build a plugin with OnPatrolHelicopterKill

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

Prompt: Reward the pilot's killer using the OnPatrolHelicopterKill 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 OnPatrolHelicopterKill

Generate