Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 6 additions & 1 deletion 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 @@ -1020,4 +1025,4 @@ private void OnSpawningRagdoll(SpawningRagdollEventArgs ev)

private void OnDestroying(DestroyingEventArgs ev) => RemoveRole(ev.Player);
}
}
}
4 changes: 2 additions & 2 deletions EXILED/Exiled.CustomRoles/Events/PlayerHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ internal void OnSpawned(SpawnedEventArgs ev)

foreach (CustomRole role in CustomRole.Registered)
{
if (role.Role == ev.Player.Role.Type && !role.IgnoreSpawnSystem && role.SpawnChance > 0 && !role.Check(ev.Player) && (role.SpawnProperties is null || role.SpawnedPlayers < role.SpawnProperties.Limit))
if (role.Role == ev.Player.Role.Type && !role.IgnoreSpawnSystem && role.SpawnChance > 0 && !role.Check(ev.Player) && (role.SpawnProperties is null || role.SpawnedPlayers < role.SpawnProperties.Limit) && (role.MinPlayers is 0 || Server.PlayerCount >= role.MinPlayers))
{
eligibleRoles.Add(role);
totalChance += role.SpawnChance;
Expand Down Expand Up @@ -123,4 +123,4 @@ internal void OnSpawned(SpawnedEventArgs ev)
}
}
}
}
}
Loading