From de5eb6924afa51a762b7e2ce451072710604d29d Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 8 Jul 2005 01:15:54 +0000 Subject: [PATCH] Added request at13457 from harbu. --- amxmodx/amxmodx.cpp | 27 +++++++++++++++++++++++++++ amxmodx/msvc/amxmodx_mm.vcproj | 3 --- plugins/include/amxconst.inc | 2 ++ plugins/include/amxmodx.inc | 5 ++++- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index fa47ac49..ac4cbeaa 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -2783,6 +2783,32 @@ static cell AMX_NATIVE_CALL amx_mkdir(AMX *amx, cell *params) #endif } +static cell AMX_NATIVE_CALL find_plugin_byfile(AMX *amx, cell *params) +{ + typedef int (*STRCOMPARE)(const char*, const char*); + + STRCOMPARE func; + + if (params[2]) + { + func = stricmp; + } else { + func = strcmp; + } + + int len, i=0; + char *file = get_amxstring(amx, params[1], 0, len); + + for (CPluginMngr::iterator iter = g_plugins.begin(); iter; ++iter) + { + if ( (func)((*iter).getName(), file) == 0 ) + return i; + i++; + } + + return -1; +} + AMX_NATIVE_INFO amxmod_Natives[] = { { "client_cmd", client_cmd }, { "client_print", client_print }, @@ -2793,6 +2819,7 @@ AMX_NATIVE_INFO amxmod_Natives[] = { { "engclient_cmd", engclient_cmd }, { "engclient_print", engclient_print }, { "find_player", find_player }, + { "find_plugin_byfile", find_plugin_byfile }, { "force_unmodified", force_unmodified }, { "format_time", format_time}, { "get_clcmd", get_clcmd}, diff --git a/amxmodx/msvc/amxmodx_mm.vcproj b/amxmodx/msvc/amxmodx_mm.vcproj index aa1d43bc..73eb6ab8 100755 --- a/amxmodx/msvc/amxmodx_mm.vcproj +++ b/amxmodx/msvc/amxmodx_mm.vcproj @@ -756,9 +756,6 @@ - - diff --git a/plugins/include/amxconst.inc b/plugins/include/amxconst.inc index 47ef57fe..10927494 100755 --- a/plugins/include/amxconst.inc +++ b/plugins/include/amxconst.inc @@ -260,3 +260,5 @@ enum { #define AMX_FLAG_LINEOPS (1<<5) /* line ops are parsed by the JIT [loadtime only flag] */ #define AMX_FLAG_BROWSE (1<<14) /* browsing/relocating or executing */ #define AMX_FLAG_RELOC (1<<15) /* jump/call addresses relocated */ + +#define INVALID_PLUGIN_ID -1 diff --git a/plugins/include/amxmodx.inc b/plugins/include/amxmodx.inc index 15c7a85e..bbafce17 100755 --- a/plugins/include/amxmodx.inc +++ b/plugins/include/amxmodx.inc @@ -677,4 +677,7 @@ native require_module(const module[]); native is_amd64_server(); /* Returns 0 on success, like the POSIX specification */ -native mkdir(const dirname[]); \ No newline at end of file +native mkdir(const dirname[]); + +/* Returns plugin id searched by file/name. Returns INVALID_PLUGIN_ID on failure. */ +native find_plugin_byfile(const filename[], ignoreCase=1); \ No newline at end of file