diff --git a/amxmodx/CPlugin.cpp b/amxmodx/CPlugin.cpp index c9ecfa66..6c804322 100755 --- a/amxmodx/CPlugin.cpp +++ b/amxmodx/CPlugin.cpp @@ -167,6 +167,14 @@ int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn) plugin->setError(errorMsg); AMXXLOG_Error("[AMXX] %s", plugin->getError()); } + else + { + cell addr; + if (amx_FindPubVar(plugin->getAMX(), "MaxClients", &addr) != AMX_ERR_NOTFOUND) + { + *get_amxaddr(plugin->getAMX(), addr) = gpGlobals->maxClients; + } + } } fclose(fp); diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index d491be17..b7614b28 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -70,9 +70,14 @@ static cell AMX_NATIVE_CALL get_xvar_id(AMX *amx, cell *params) char* sName = get_amxstring(amx, params[1], 0, len); cell ptr; + if (!strcmp(sName, "MaxClients")) + { + return -1; + } + for (CPluginMngr::iterator a = g_plugins.begin(); a ; ++a) { - if ((*a).isValid() && amx_FindPubVar((*a).getAMX(), sName, &ptr) == AMX_ERR_NONE) + if ((*a).isValid() && amx_FindPubVar((*a).getAMX(), sName, &ptr) == AMX_ERR_NONE) return g_xvars.put((*a).getAMX(), get_amxaddr((*a).getAMX(), ptr)); } diff --git a/plugins/include/amxconst.inc b/plugins/include/amxconst.inc index 8e7ce17c..9911f084 100755 --- a/plugins/include/amxconst.inc +++ b/plugins/include/amxconst.inc @@ -25,6 +25,16 @@ */ #define MAX_STRING_LENGTH 16384 +/** + * MAX_PLAYERS is not the same as MaxClients. + * MAX_PLAYERS is a hardcoded value as an upper limit. MaxClients changes based on the server. + */ +#define MAX_PLAYERS 33 /* Maximum number of players AMX Mod X supports */ +#define MAX_NAME_LENGTH 32 /* Maximum buffer required to store a client name */ + +public const MaxClients; /* Maximum number of players the server supports (dynamic) */ + + #define M_PI 3.1415926535 #define ADMIN_ALL 0 /* everyone */