OnClanMemberAdded
OnClanMemberAdded is called after a player successfully accepts a clan invite and the server has already written the new member into the clan database.
void OnClanMemberAdded(long clanId, ulong steamId)Parameters
| Parameter | Type | Description |
|---|---|---|
clanId | long | Numeric identifier of the clan the member was added to. Use it to look up the clan in your own records or to key per-clan settings. |
steamId | ulong | Steam ID of the player who accepted the invite and became a clan member. Use it with BasePlayer.FindByID or your stored data to reach the player. |
Return value
The hook is called for notification only. The server ignores whatever your method returns, so the invite-acceptance routine still returns true after the hook runs. Return nothing to keep behavior unchanged.
How it works
This hook fires inside the clan system's invite-acceptance routine, after the pending invite is removed, the member record is created and the change is committed to disk. It only runs on the success path: if the invite cannot be deleted or the member cannot be created, the database is rolled back and no hook call happens. It is not triggered when a clan is created, when the leader kicks someone, or when a player leaves on their own.
Both arguments are plain values, so there is no object to null-check. clanId identifies the clan and steamId identifies the new member; there is no BasePlayer argument, so resolve the player yourself with BasePlayer.FindByID (the client may already be connected, but do not assume it). Because the arguments are simple primitives, you cannot narrow the hook to a subset of calls by declaring a different parameter type. Use it for welcome messages, syncing clan membership into your own data files, granting permission groups, or running first-join rewards.
Example plugin: Announce and reward new clan members
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("Clan Member Announcer", "RustPluginGenerator", "1.0.0")]
[Description("Welcomes and rewards players who accept a clan invite")]
public class ClanMemberAnnouncer : RustPlugin
{
private const string PermWelcome = "clanmemberannouncer.welcome";
private PluginConfig config;
private readonly Dictionary<ulong, float> lastWelcome = new Dictionary<ulong, float>();
private class PluginConfig
{
[JsonProperty("Broadcast welcome to all players")]
public bool Broadcast { get; set; } = false;
[JsonProperty("Welcome cooldown in seconds")]
public float CooldownSeconds { get; set; } = 30f;
[JsonProperty("Grant welcome permission")]
public bool GrantPermission { 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>
{
["Welcome"] = "You joined a clan. Welcome, {0}!",
["ClanWelcome"] = "{0} has joined a clan!"
}, this);
}
private string Msg(string key, string userId = null, params object[] args)
{
return string.Format(lang.GetMessage(key, this, userId), args);
}
private void Init()
{
permission.RegisterPermission(PermWelcome, this);
}
private void OnClanMemberAdded(long clanId, ulong steamId)
{
float now = Time.realtimeSinceStartup;
float last;
if (lastWelcome.TryGetValue(steamId, out last) && now - last < config.CooldownSeconds)
return;
lastWelcome[steamId] = now;
if (config.GrantPermission)
permission.GrantUserPermission(steamId.ToString(), PermWelcome, this);
string name = steamId.ToString();
var player = BasePlayer.FindByID(steamId);
if (player != null && player.IsConnected)
name = player.displayName;
if (config.Broadcast)
Server.Broadcast(Msg("ClanWelcome", null, name));
if (player == null || !player.IsConnected)
return;
player.ChatMessage(Msg("Welcome", player.UserIDString, player.displayName));
}
}
}The plugin listens for OnClanMemberAdded and resolves the player with BasePlayer.FindByID. If the player is still connected, it sends a chat message and registers the clanmemberannouncer.welcome permission so admins can attach a welcome kit or chat tag group. A short cooldown stored in a dictionary prevents double messages if the same player is re-added to the same clan within a few seconds. Player-facing text goes through the language file, and server broadcasts are only sent when the config option is enabled.
Common use cases
Welcome message and clan tag
Send the new member a chat message explaining clan rules and grant a permission group that shows a clan tag in chat.
Sync membership to external data
Record clanId and steamId in a data file so a stats or economy plugin can award points to the whole clan later.
First-join reward
Track the player's first-ever accepted clan invite and give a one-time item or currency via an optional Economy reference.
Pitfalls
Player may be offline
The acceptance can complete while the player is disconnecting, so
BasePlayer.FindByIDmay return null. Guard before sending chat or granting permissions.Not fired for kicks or leaves
This hook only covers accepted invites. Use
OnClanMemberKickedandOnClanMemberLeftto keep your own membership records in sync for the other transitions.Race with clan deletion
A clan can be disbanded shortly after, so avoid caching a clan as permanently valid. Re-read state when you act on it later.
Build a plugin with OnClanMemberAdded
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 OnClanMemberAdded
Generate