OnClanCreated
OnClanCreated is called after the server has finished creating a new clan in LocalClanBackend.Create, once the creator has been added as a member and the result has been prepared. It fires at most once per successful clan creation.
void OnClanCreated(LocalClan clan, ulong leaderSteamId)Parameters
| Parameter | Type | Description |
|---|---|---|
clan | LocalClan | The LocalClan instance that was just created. Use it to read the clan ID, name, tag, leader and member list; it is the same object stored in the clan backend. |
leaderSteamId | ulong | Steam ID (ulong) of the player who created the clan and is set as its leader. Use it to look up the player, send them a confirmation message or grant permissions. |
Return value
The return value is ignored. The hook is injected as a plain Interface.CallHook call with no conditional branch, so returning null or any value has no effect on the created clan or the game's result.
How it works
The hook runs inside the clan creation coroutine, after the new clan has been committed to the backend and the leader has been registered as a member with MembershipChanged. Because the call sits just before the method returns its result, it only fires on a successful creation: a failed lookup of the freshly created clan throws before reaching this point, so a rejected or aborted creation never triggers it.
clan is the live LocalClan object. Read clan.ClanId, clan.Name, clan.Tag and its member/leader data from it rather than re-querying the backend, which may not be fully indexed yet at this exact instant. leaderSteamId is the creator's Steam ID independent of whether they are still connected; combine it with BasePlayer.FindByID only if you need to message them immediately.
This is a notification hook: the clan already exists when it fires, so you cannot cancel it. There is no meaningful narrowing of clan by parameter type; it is always LocalClan. Keep the body fast, since it runs inside the server's clan backend coroutine, and avoid prints on this path.
Example plugin: Give clan leaders a starter kit and welcome message
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
using Oxide.Core.Plugins;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("Clan Creation Kit", "RustPluginGenerator", "1.0.0")]
[Description("Gives new clan leaders a starter kit and a welcome message when a clan is created")]
public class ClanCreationKit : RustPlugin
{
private const string PermLeader = "clancreationkit.leader";
[PluginReference] private Plugin Economics;
private PluginConfig config;
private readonly HashSet<ulong> rewardedLeaders = new HashSet<ulong>();
private readonly Dictionary<long, ulong> clanLeaders = new Dictionary<long, ulong>();
private class PluginConfig
{
[JsonProperty("Enable starter kit")]
public bool EnableKit = true;
[JsonProperty("Starter items (shortname:amount)")]
public Dictionary<string, int> StarterItems = new Dictionary<string, int>
{
["wood"] = 1000,
["stone"] = 1000,
["metal.fragments"] = 250
};
[JsonProperty("Grant leader permission")]
public bool GrantPermission = true;
[JsonProperty("Economy reward (0 disables)")]
public double EconomyReward = 0.0;
}
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"] = "Your clan is registered. Welcome aboard, leader!",
["KitGiven"] = "A starter kit was delivered to your inventory.",
["InventoryFull"] = "Your inventory was full, some items were dropped nearby."
}, 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(PermLeader, this);
}
private void OnClanCreated(LocalClan clan, ulong leaderSteamId)
{
if (clan == null || leaderSteamId == 0) return;
if (clan.ClanId != 0)
clanLeaders[clan.ClanId] = leaderSteamId;
if (!rewardedLeaders.Add(leaderSteamId)) return;
var player = BasePlayer.FindByID(leaderSteamId);
if (player == null || !player.IsConnected) return;
if (config.GrantPermission && !permission.UserHasPermission(player.UserIDString, PermLeader))
permission.GrantUserPermission(player.UserIDString, PermLeader, this);
if (config.EnableKit && config.StarterItems != null)
{
bool dropped = false;
foreach (var entry in config.StarterItems)
{
if (entry.Value <= 0) continue;
var item = ItemManager.CreateByName(entry.Key, entry.Value);
if (item == null) continue;
if (!player.inventory.GiveItem(item))
{
item.Drop(player.transform.position, Vector3.zero);
dropped = true;
}
}
if (dropped) player.ChatMessage(Msg("InventoryFull", player.UserIDString));
}
if (config.EconomyReward > 0.0 && Economics != null)
Economics.Call("Deposit", player.UserIDString, config.EconomyReward);
player.ChatMessage(Msg("Welcome", player.UserIDString));
}
private void OnClanDisbanded(LocalClan clan)
{
if (clan == null) return;
ulong leader;
if (clan.ClanId != 0 && clanLeaders.TryGetValue(clan.ClanId, out leader))
{
if (leader != 0) rewardedLeaders.Remove(leader);
clanLeaders.Remove(clan.ClanId);
}
}
private void Unload()
{
rewardedLeaders.Clear();
clanLeaders.Clear();
}
}
}The plugin listens for OnClanCreated, records the clan's leader, and only rewards each leader once per session. It looks up the leader by Steam ID with BasePlayer.FindByID and returns if the player is missing or disconnected. If GrantPermission is enabled, it grants the clancreationkit.leader permission to the leader when they don't already have it. If EnableKit is enabled, it gives each configured item with ItemManager.CreateByName and player.inventory.GiveItem, dropping items at the player's position when the inventory is full and messaging them about it. If EconomyReward is greater than zero and the Economics plugin is loaded, it deposits that amount before sending a localised welcome message through the language file. OnClanDisbanded removes the leader from the tracking so a future clan creation can reward them again.
Common use cases
Reward new clan leaders
Grant a starter kit, resources or a currency via an Economy plugin reference when a player founds their first clan, keeping clan creation attractive without affecting normal gameplay.
Auto-tag clan roles
Give the leader a permission such as 'clancreationkit.leader' so chat titles or other plugins can highlight clan founders, and remove it when the clan is disbanded.
Audit clan creation
Append the clan ID, name and leader Steam ID to a data file for admin review, useful on large servers tracking clan churn or investigating abuse.
Pitfalls
The clan already exists
Returning a value or throwing does not undo creation. To block clan creation at all you need a hook that fires earlier, such as a permission check performed in your own command layer or a different clan hook.
Backend state may still be settling
The hook runs inside the creation coroutine right before the result is returned, so avoid immediately calling clan backend queries that assume the new clan is indexed everywhere; read from the provided LocalClan instead.
Leader may be disconnected
leaderSteamIdis always valid butBasePlayer.FindByIDcan return null. Guard the player before sending chat messages or giving items, and queue the reward for reconnect if needed.
Build a plugin with OnClanCreated
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 OnClanCreated
Generate