added module_exists

This commit is contained in:
David Anderson 2005-09-11 04:43:40 +00:00
parent 120c849e4b
commit 73d70aff29
2 changed files with 49 additions and 0 deletions

View File

@ -31,6 +31,7 @@
#include <time.h> #include <time.h>
#include "amxmodx.h" #include "amxmodx.h"
#include "natives.h"
static cell AMX_NATIVE_CALL get_xvar_id(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_xvar_id(AMX *amx, cell *params)
{ {
@ -3035,6 +3036,52 @@ static cell AMX_NATIVE_CALL amx_abort(AMX *amx, cell *params)
return 1; return 1;
} }
static cell AMX_NATIVE_CALL module_exists(AMX *amx, cell *params)
{
int len;
char *module = get_amxstring(amx, params[1], 0, len);
CList<CModule,const char *>::iterator a;
bool isdbi = false, found = false;
const amxx_module_info_s *info;
if (stricmp(module, "dbi")==0)
isdbi = true;
for (a=g_modules.begin(); a; ++a)
{
if ( (*a).getStatusValue() == MODULE_LOADED )
{
info = (*a).getInfoNew();
if (info)
{
if (isdbi)
{
if (info->logtag
&& (StrCaseStr(info->logtag, "sql")
||
StrCaseStr(info->logtag, "dbi"))
)
{
found = true;
break;
}
} else {
if (info->logtag && (stricmp(info->logtag, module) == 0))
{
found = true;
break;
}
}
}
}
}
if (!found)
found = LibraryExists(module);
return (found ? 1 : 0);
}
AMX_NATIVE_INFO amxmodx_Natives[] = { AMX_NATIVE_INFO amxmodx_Natives[] = {
{"abort", amx_abort}, {"abort", amx_abort},
{"callfunc_begin", callfunc_begin}, {"callfunc_begin", callfunc_begin},
@ -3139,6 +3186,7 @@ AMX_NATIVE_INFO amxmodx_Natives[] = {
{"md5_file", amx_md5_file}, {"md5_file", amx_md5_file},
{"message_begin", message_begin}, {"message_begin", message_begin},
{"message_end", message_end}, {"message_end", message_end},
{"module_exists", module_exists},
{"mkdir", amx_mkdir}, {"mkdir", amx_mkdir},
{"num_to_word", num_to_word}, {"num_to_word", num_to_word},
{"parse_loguser", parse_loguser}, {"parse_loguser", parse_loguser},

View File

@ -49,5 +49,6 @@
#define STATIC_MODULE 1 #define STATIC_MODULE 1
int CheckModules(AMX *amx, char error[128]); int CheckModules(AMX *amx, char error[128]);
const char *StrCaseStr(const char *as, const char *bs);
#endif // __MODULES_H__ #endif // __MODULES_H__