OnClanMemberLeft
OnClanMemberLeft is called after a player successfully leaves a clan through the clan's own leave action, once the backend has deleted the membership record.
void OnClanMemberLeft(LocalClan localClan, ulong steamId)Parameters
| Parameter | Type | Description |
|---|---|---|
localClan | LocalClan | The LocalClan instance the player is leaving. Use its ClanId, Name and member list to identify the clan; check it for null before reading fields. |
steamId | ulong | The 64-bit Steam ID of the member who left, as a ulong. Convert it with ToString() when you need a string for permission checks, data keys or player lookup. |
Return value
The return value has no effect. The original code continues to append the "leave" log entry regardless of what your hook method returns.
How it works
This hook fires inside LocalClan.Kick, but only on the branch of the code that handles a voluntary departure rather than an eviction. The call is placed after DeleteMember returns true, so the membership is already gone from the database when your plugin runs. A kick by a leader goes to OnClanMemberKicked instead and never reaches this hook, and a failed database delete means neither hook fires.
localClan gives you the clan's identifier, name and remaining members, which is what you need for notifications and records. steamId is the departing player's ID; the player may already be offline, leaving, or disconnected, so treat a lookup with BasePlayer.FindByID as possibly returning null.
The hook return value is ignored here, so you cannot cancel or delay the departure. The only injection site is this one place in clan kick handling, so nothing else in the game triggers it.
Declaring a more specific parameter type gains nothing: the first argument is always the LocalClan being modified. Keep the class, clan and Steam ID consistent with the existing types.
Example plugin: Announce clan departures to online clan members
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
namespace Oxide.Plugins
{
[Info("Clan Leave Notifier", "RustPluginGenerator", "1.0.0")]
[Description("Announces to online clan members when someone leaves their clan.")]
public class ClanLeaveNotifier : RustPlugin
{
private class PluginConfig
{
[JsonProperty("Announce departures in chat")]
public bool Announce { get; set; } = 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>
{
["Left"] = "{0} has left the clan.",
["Unknown"] = "A clan member has left the clan."
}, this);
}
private string Msg(string key, string userId = null, params object[] args)
=> string.Format(lang.GetMessage(key, this, userId), args);
private void OnClanMemberLeft(ulong clanId, ulong steamId)
{
if (!config.Announce) return;
string leaverId = steamId.ToString();
BasePlayer leaver = BasePlayer.FindByID(steamId);
string text = leaver != null && !string.IsNullOrEmpty(leaver.displayName)
? Msg("Left", leaverId, leaver.displayName)
: Msg("Unknown", leaverId);
object clan = Interface.CallHook("GetClan", clanId);
if (clan == null) return;
var membersObj = clan.GetType().GetProperty("Members")?.GetValue(clan, null) as System.Collections.IEnumerable;
if (membersObj == null) return;
foreach (var member in membersObj)
{
if (member == null) continue;
var steamIdProp = member.GetType().GetProperty("SteamId");
if (steamIdProp == null) continue;
if (!(steamIdProp.GetValue(member, null) is ulong memberId)) continue;
if (memberId == steamId) continue;
BasePlayer player = BasePlayer.FindByID(memberId);
if (player == null || !player.IsConnected || player.IsSleeping()) continue;
player.ChatMessage(text);
}
}
}
}The plugin sends a togglable chat announcement to online clan members when someone leaves the clan. OnClanMemberLeft receives the clan ID and the Steam ID of the leaver. It looks up the leaver with BasePlayer.FindByID; if a display name is available it uses the Left message, otherwise the Unknown message. The clan object is fetched through the GetClan hook, and the plugin reads its Members collection and each member's SteamId. It skips the leaver and any member without a resolvable, connected, non-sleeping BasePlayer, then sends the chat line to the rest. If GetClan returns null or the expected members data is missing, nothing is announced. The config key Announce (default true) controls whether announcements are sent, and the messages are registered through the language file so servers can translate them.
Common use cases
Notify the clan
Send a chat message to remaining online clan members so they know someone left, including the leaver's display name when it can be resolved.
Audit clan activity
Append a line to a JSON file in oxide/data with the clan ID, member Steam ID and a Unix timestamp so admins can review departures later.
Clean up per-member state
Remove the player from custom clan-based systems such as shared waypoints or clan-only shop permissions stored in your own data files.
Pitfalls
Kicks do not fire this hook
A leader removing a member goes through
OnClanMemberKickedinstead. Register both hooks if you need a complete record of membership changes.The player may not be loaded
The departure can complete while the player is disconnecting. Use
BasePlayer.FindByIDand handle a null result rather than assuming a live BasePlayer exists.Cannot be cancelled
The return value is ignored and the database row is already deleted, so do not build features that rely on blocking a departure here.
Build a plugin with OnClanMemberLeft
Describe what should happen and get a compiled plugin that uses this hook.
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 OnClanMemberLeft
Generate