Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions EXILED/Exiled.CustomRoles/API/Features/CustomRole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ public abstract class CustomRole
/// </summary>
public virtual SpawnProperties SpawnProperties { get; set; } = new();

/// <summary>
/// Gets or sets the minimum number of players connected needed in order to add the role.
/// </summary>
public virtual int MinPlayers { get; set; }

/// <summary>
/// Gets or sets a value indicating whether players keep their current position when gaining this role.
/// </summary>
Expand Down Expand Up @@ -548,7 +553,7 @@ public virtual void AddRole(Player player)
Log.Debug($"{Name}: Adding role to {player.Nickname}.");
player.UniqueRole = Name;

if (Role != RoleTypeId.None)
if (Role != RoleTypeId.None && (MinPlayers is 0 || Server.PlayerCount == MinPlayers))
{
try
{
Expand Down Expand Up @@ -1020,4 +1025,4 @@ private void OnSpawningRagdoll(SpawningRagdollEventArgs ev)

private void OnDestroying(DestroyingEventArgs ev) => RemoveRole(ev.Player);
}
}
}
Loading