Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be >= in player count comparison ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

totally missed that lol

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should NPC's be included in this check btw? Server.PlayerCount includes dummies, but Server.ConnectedPlayerCount will ignore them

{
eligibleRoles.Add(role);
totalChance += role.SpawnChance;
Expand Down Expand Up @@ -123,4 +123,4 @@ internal void OnSpawned(SpawnedEventArgs ev)
}
}
}
}
}
Loading