diff --git a/core/smn_player.cpp b/core/smn_player.cpp index 5d7e328f..dc304011 100644 --- a/core/smn_player.cpp +++ b/core/smn_player.cpp @@ -66,6 +66,22 @@ static cell_t sm_GetMaxClients(IPluginContext *pCtx, const cell_t *params) return g_Players.MaxClients(); } +static cell_t sm_GetMaxHumanPlayers(IPluginContext *pCtx, const cell_t *params) +{ + int maxHumans = -1; + +#if SOURCE_ENGINE >= SE_LEFT4DEAD + maxHumans = serverClients->GetMaxHumanPlayers(); +#endif + + if( maxHumans == -1 ) + { + return g_Players.MaxClients(); + } + + return maxHumans; +} + static cell_t sm_GetClientName(IPluginContext *pCtx, const cell_t *params) { int index = params[1]; @@ -1634,6 +1650,7 @@ REGISTER_NATIVES(playernatives) {"GetClientTeam", GetClientTeam}, {"GetClientUserId", GetClientUserId}, {"GetMaxClients", sm_GetMaxClients}, + {"GetMaxHumanPlayers", sm_GetMaxHumanPlayers}, {"GetUserAdmin", GetUserAdmin}, {"GetUserFlagBits", GetUserFlagBits}, {"IsClientAuthorized", sm_IsClientAuthorized}, diff --git a/plugins/include/clients.inc b/plugins/include/clients.inc index 2a28f894..d4e34eb4 100644 --- a/plugins/include/clients.inc +++ b/plugins/include/clients.inc @@ -209,6 +209,21 @@ forward OnClientPostAdminCheck(client); */ native GetMaxClients(); +/** + * Returns the maximum number of human players allowed on the server. This is + * a game-specific function used on newer games to limit the number of humans + * that can join a game and can be lower than MaxClients. It is the number often + * reflected in the server browser or when viewing the output of the status command. + * On unsupported games or modes without overrides, it will return the same value + * as MaxClients. + * + * You should not globally cache the value to GetMaxHumanPlayers() because it can change across + * game modes. You may still cache it locally. + * + * @return Maximum number of humans allowed. + */ +native GetMaxHumanPlayers(); + /** * Returns the client count put in the server. *