diff --git a/amxmodx/amxmodx.h b/amxmodx/amxmodx.h index d77c9131..dfeea693 100755 --- a/amxmodx/amxmodx.h +++ b/amxmodx/amxmodx.h @@ -103,6 +103,12 @@ void UTIL_ShowMenu( edict_t* pEntity, int slots, int time, char *menu, int mlen void UTIL_MakeNewLogFile(); void UTIL_Log(const char *fmt, ...); +#define UTIL_MODULES_RUNNING 0 +#define UTIL_MODULES_ALL 1 +#define UTIL_MODULES_STOPPED 2 + +int UTIL_GetModulesNum(int mode); + #define GET_PLAYER_POINTER(e) (&g_players[ENTINDEX(e)]) //#define GET_PLAYER_POINTER(e) (&g_players[(((int)e-g_edict_point)/sizeof(edict_t ))]) #define GET_PLAYER_POINTER_I(i) (&g_players[i]) diff --git a/amxmodx/util.cpp b/amxmodx/util.cpp index 4dc1701f..437e8d4c 100755 --- a/amxmodx/util.cpp +++ b/amxmodx/util.cpp @@ -330,3 +330,36 @@ void UTIL_Log(const char *fmt, ...) fclose(pF); print_srvconsole("L %s: %s\n", date, msg); } + +// Get the number of running modules +int UTIL_GetModulesNum(int mode) +{ + CList::iterator iter; + int num; + switch (mode) + { + case UTIL_MODULES_ALL: + return g_modules.size(); + case UTIL_MODULES_RUNNING: + iter = g_modules.begin(); + num = 0; + while (iter) + { + if ((*iter).getStatusValue() == MODULE_LOADED) + ++num; + ++iter; + } + return num; + case UTIL_MODULES_STOPPED: + iter = g_modules.begin(); + num = 0; + while (iter) + { + if ((*iter).getStatusValue() != MODULE_LOADED) + ++num; + ++iter; + } + return num; + } + return 0; +} \ No newline at end of file