diff --git a/Content.Server/Connection/ConnectionManager.cs b/Content.Server/Connection/ConnectionManager.cs
index 5e2552a552..afc4b43b85 100644
--- a/Content.Server/Connection/ConnectionManager.cs
+++ b/Content.Server/Connection/ConnectionManager.cs
@@ -1,10 +1,12 @@
using System;
using System.Collections.Immutable;
using System.Threading.Tasks;
+using Content.Server.Administration.Managers;
using Content.Server.Database;
using Content.Server.Preferences.Managers;
using Content.Shared;
using Content.Shared.CCVar;
+using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.IoC;
using Robust.Shared.Network;
@@ -22,6 +24,8 @@ namespace Content.Server.Connection
///
public sealed class ConnectionManager : IConnectionManager
{
+ [Dependency] private readonly IServerDbManager _dbManager = default!;
+ [Dependency] private readonly IPlayerManager _plyMgr = default!;
[Dependency] private readonly IServerNetManager _netMgr = default!;
[Dependency] private readonly IServerDbManager _db = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
@@ -70,6 +74,12 @@ The ban reason is: ""{ban.Reason}""
hwId = null;
}
+ if (_plyMgr.PlayerCount >= _cfg.GetCVar(CCVars.SoftMaxPlayers) && await _dbManager.GetAdminDataForAsync(e.UserId) is null)
+ {
+ e.Deny("The server is full!");
+ return;
+ }
+
var ban = await _db.GetServerBanAsync(addr, userId, hwId);
if (ban != null)
{
diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs
index e4785ac74a..843ff1c2e3 100644
--- a/Content.Shared/CCVar/CCVars.cs
+++ b/Content.Shared/CCVar/CCVars.cs
@@ -99,12 +99,15 @@ namespace Content.Shared.CCVar
///
/// When enabled, guests will be assigned permanent UIDs and will have their preferences stored.
///
- public static readonly CVarDef
- GamePersistGuests = CVarDef.Create("game.persistguests", true, CVar.ARCHIVE | CVar.SERVERONLY);
+ public static readonly CVarDef GamePersistGuests =
+ CVarDef.Create("game.persistguests", true, CVar.ARCHIVE | CVar.SERVERONLY);
public static readonly CVarDef GameDiagonalMovement =
CVarDef.Create("game.diagonalmovement", true, CVar.ARCHIVE);
+ public static readonly CVarDef SoftMaxPlayers =
+ CVarDef.Create("game.soft_max_players", 30, CVar.SERVERONLY | CVar.ARCHIVE);
+
/*
* Suspicion
*/