Skip to content
RustPluginGenerator

OnFlameExplosion

OnFlameExplosion is called when a flamethrower projectile (FlameExplosive) detonates and the game spawns its fireball. It fires after the flame entity has spawned but before the fireball velocity is applied.

Signature
void OnFlameExplosion(FlameExplosive flameExplosive, UnityEngine.Collider component)

Parameters

Hook parameters
ParameterTypeDescription
flameExplosiveFlameExplosiveThe FlameExplosive component that is detonating. Use it to read the projectile's creator, position and transform, and to identify who fired the flamethrower round.
componentUnityEngine.ColliderThe Collider the flame projectile hit or is resolving against. Can be null when the explosion does not resolve to a collider, so null-check before reading its transform or attached entity.

Return value

The return value is ignored. The game continues to spawn the fireball and apply its velocity regardless of what the hook returns, so returning null or any value has no effect on the projectile.

How it works

This hook runs inside FlameExplosive.FlameExplode, right after the game spawns the fire entity and assigns its creator, and just before it computes the fireball's velocity. Every flamethrower round that resolves into a flame burst triggers it, so it fires frequently during sustained flamethrower combat and in flame-trap scenarios, not just player-shot flames.

The flameExplosive parameter is the projectile component itself: its creatorEntity, transform.position and owner ID tell you who produced the flame and where it landed. The component parameter is the collider the round resolved against; it may be null, so treat it as optional context rather than a guaranteed target.

You cannot cancel the explosion by declaring parameter types differently, and you cannot narrow the call by type because both arguments are typed directly. Use the hook for observation and side effects: tracking flame usage, applying effects near the impact point, or enforcing rules on who may spread fire in an area. Do not throw exceptions or run heavy work here; the hook can fire many times per second in a flamethrower fight.

Example plugin: Log and count flamethrower detonations per player

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

namespace Oxide.Plugins
{
    [Info("Flame Explosion Tracker", "RustPluginGenerator", "1.0.0")]
    [Description("Counts flamethrower detonations per player and reports them to admins.")]
    public class FlameExplosionTracker : RustPlugin
    {
        private const string PermAdmin = "flameexplosiontracker.admin";

        private PluginConfig config;
        private readonly Dictionary<string, int> counts = new Dictionary<string, int>();

        private class PluginConfig
        {
            [JsonProperty("Minimum detonations to report")]
            public int MinimumToReport { get; set; } = 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>
            {
                ["NoPermission"] = "You do not have permission to use this command.",
                ["NoData"] = "No flame detonations have been recorded this session.",
                ["Reset"] = "Flame detonation statistics cleared.",
                ["Header"] = "Flame detonation counts ({0} players):",
                ["Entry"] = "{0}: {1}"
            }, 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(PermAdmin, this);
        }

        private void OnFlameExplosion(FlameExplosive flameExplosive, Collider component)
        {
            if (flameExplosive == null) return;

            var creator = flameExplosive.creatorEntity as BasePlayer;
            if (creator == null || creator.IsNpc || creator.IsDead()) return;

            string id = creator.UserIDString;
            int current;
            counts.TryGetValue(id, out current);
            counts[id] = current + 1;
        }

        [ChatCommand("flamestats")]
        private void CmdFlameStats(BasePlayer player, string command, string[] args)
        {
            if (player == null) return;
            if (!permission.UserHasPermission(player.UserIDString, PermAdmin))
            {
                SendReply(player, Msg("NoPermission", player.UserIDString));
                return;
            }

            if (counts.Count == 0)
            {
                SendReply(player, Msg("NoData", player.UserIDString));
                return;
            }

            SendReply(player, Msg("Header", player.UserIDString, counts.Count));
            foreach (var pair in counts)
            {
                if (pair.Value < config.MinimumToReport) continue;
                var owner = BasePlayer.FindByID(ulong.Parse(pair.Key));
                string name = owner != null ? owner.displayName : pair.Key;
                SendReply(player, Msg("Entry", player.UserIDString, name, pair.Value));
            }
        }

        [ConsoleCommand("flame.reset")]
        private void CcmdFlameReset(ConsoleSystem.Arg arg)
        {
            var player = arg.Player();
            if (player != null && !permission.UserHasPermission(player.UserIDString, PermAdmin))
            {
                arg.ReplyWith(Msg("NoPermission", player.UserIDString));
                return;
            }

            counts.Clear();
            arg.ReplyWith(Msg("Reset", player?.UserIDString));
        }

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

The plugin records every flamethrower detonation against the player who created the flame, so admins can see who is spreading the most fire and when. Inside OnFlameExplosion it reads the creator from flameExplosive.creatorEntity, resolves the owning BasePlayer, and increments a per-player counter keyed by UserIDString. The counter is throttled so chat output cannot be spammed. An admin chat command flamestats prints the current session counts, and a console command flame.reset clears them. Data is not persisted to disk; this is a live diagnostic tool, and the counters are dropped on unload. Colliders and fireball entities are never modified.

Common use cases

  • Identify repeat flame offenders

    Track who detonates the most flamethrower rounds in a session and surface the top users to admins via a chat command.

  • Trigger local effects at impact

    Play a custom effect or sound at flameExplosive.transform.position to give flamethrower fire a distinct feel without touching the fireball logic.

  • Enforce area restrictions

    Detect flames detonating inside a protected zone by checking the projectile position against stored regions and alerting staff or applying a separate penalty.

Pitfalls

  • component can be null

    The collider argument is not always present. Null-check it before reading its transform or the entity it belongs to; reading component.transform directly will throw.

  • Runs many times per second

    Flamethrowers detonate rapidly, so avoid Puts, PrintWarning, database writes or anything expensive inside this hook. Use throttled chat or in-memory counters instead.

  • Cannot cancel the flame

    The hook return value is ignored and the fireball still spawns with its velocity. If you need to stop flame damage, use damage-related hooks instead.

Build a plugin with OnFlameExplosion

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

Prompt: Identify repeat flame offenders using the OnFlameExplosion 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 OnFlameExplosion

Generate