Skip to content
RustPluginGenerator

OnTeamDisbanded

OnTeamDisbanded is called after a team has been removed from the server's team list, from RelationshipManager.DisbandTeam. It fires on every disband path, including a team that empties after its last member leaves.

Signature
void OnTeamDisbanded(RelationshipManager.PlayerTeam teamToDisband)

Parameters

Hook parameters
ParameterTypeDescription
teamToDisbandRelationshipManager.PlayerTeamThe RelationshipManager.PlayerTeam instance that has just been removed from the server's team list. Read teamID, members and teamLeader from it, but treat it as transient because the object is pooled right after the hook returns.

Return value

The return value is ignored. DisbandTeam collects the result of the OnTeamDisbanded call and discards it, then frees the PlayerTeam back to the pool, so returning a value changes nothing.

How it works

The hook fires at the end of RelationshipManager.DisbandTeam, after the team has been removed from the internal teams dictionary and before the PlayerTeam object is returned to the pool. Rust routes every disband through this method: an explicit /team disband by the leader, the automatic disband when the last member leaves, and any plugin call to DisbandTeam.

The teamToDisband parameter still carries the full team state at this point: teamID, teamLeader and the members list of Steam IDs. That makes it the last reliable moment to read the roster before the object is recycled, so any cleanup or notification work should copy the data it needs rather than store the reference.

This hook cannot be narrowed to a more specific type; PlayerTeam is the only game type the argument can be. Do not try to cancel the disband here, because the team is already gone from the server when the hook runs. Use OnTeamDisband if you need a chance to block the disband.

Because disbands are player-driven, the hook fires rarely. It is safe to write data, send messages or run timers from it.

Example plugin: Announce team disband and log the former roster

TeamDisbandNotifier.cs
using System.Linq;
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;

namespace Oxide.Plugins
{
    [Info("Team Disband Notifier", "RustPluginGenerator", "1.0.0")]
    [Description("Logs every team disband and optionally broadcasts it to the server")]
    public class TeamDisbandNotifier : RustPlugin
    {
        private const string PermAdmin = "teamdisbandnotifier.admin";

        private PluginConfig config;

        private class PluginConfig
        {
            [JsonProperty("Broadcast Disband")]
            public bool BroadcastDisband { get; set; } = true;

            [JsonProperty("Log To Console")]
            public bool LogToConsole { 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>
            {
                ["Broadcast"] = "Team {0} has been disbanded by its leader.",
                ["LogLine"] = "Team {0} disbanded. Leader {1}, members: {2}",
            }, 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 OnTeamDisbanded(RelationshipManager.PlayerTeam teamToDisband)
        {
            if (teamToDisband == null) return;

            ulong teamId = teamToDisband.teamID;
            ulong leaderId = teamToDisband.teamLeader;
            List<ulong> memberIds = teamToDisband.members != null
                ? new List<ulong>(teamToDisband.members)
                : new List<ulong>();

            if (config.LogToConsole)
            {
                string roster = string.Join(", ", memberIds.ConvertAll(id => id.ToString()).ToArray());
                Puts(Msg("LogLine", null, teamId, leaderId, roster));
            }

            if (config.BroadcastDisband)
            {
                Server.Broadcast(Msg("Broadcast", null, teamId));
            }
        }
    }
}

The plugin listens in OnTeamDisbanded and, before the PlayerTeam object is recycled, copies the team ID, leader and member list into local variables. It logs a one-line summary of the disband so admins can audit team churn, then broadcasts a message that names the former leader. All player-facing text goes through the language file, and the broadcast can be turned off with Broadcast Disband in the config. Because the team is already removed from the server, the plugin never tries to cancel or modify the disband; it only reports it. The guild name lookup is skipped on purpose since the team object no longer needs any live references after the hook returns.

Common use cases

  • Audit team churn for admins

    Write the former team ID, leader and member count to a data file so you can review how often teams form and break up during a wipe.

  • Notify members of a disband

    Broadcast or message online members that their team was disbanded, which helps players who missed the chat line from the leader.

  • Clean up team-scoped plugin data

    Remove any custom data keyed by team ID (shared storage, territory, scoreboards) so a new team that reuses the ID does not inherit stale entries.

Pitfalls

  • The object is pooled right after the hook

    DisbandTeam calls Pool.Free on the PlayerTeam once the hook returns. Copy teamID, teamLeader and a new List<ulong> of members inside the hook instead of storing the team reference.

  • Too late to block the disband

    The team is already removed from the server's team dictionary when this hook runs. Use OnTeamDisband (which wraps the actual removal) if you need a veto.

  • Last member leaving also triggers it

    A team with one member disbands automatically when they leave, quit or are kicked, so you will see this hook without an explicit /team disband command. Do not assume there was user intent.

Plugin recipes that use OnTeamDisbanded

Build a plugin with OnTeamDisbanded

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

Prompt: Audit team churn for admins using the OnTeamDisbanded 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 OnTeamDisbanded

Generate