diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index a3c87228..30778c1a 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -3124,6 +3124,7 @@ static cell AMX_NATIVE_CALL is_module_loaded(AMX *amx, cell *params) } // native is_plugin_loaded(const name[]); +// 1.8 changed to: is_plugin_loaded(const name[], bool:usefilename=false); static cell AMX_NATIVE_CALL is_plugin_loaded(AMX *amx, cell *params) { // param1: name @@ -3131,12 +3132,29 @@ static cell AMX_NATIVE_CALL is_plugin_loaded(AMX *amx, cell *params) char *name = get_amxstring(amx, params[1], 0, len); int id = 0; - for (CPluginMngr::iterator iter = g_plugins.begin(); iter; ++iter) + if (params[0] / sizeof(cell) == 1 || // compiled pre-1.8 - assume plugin's registered name + params[2] == 0) // compiled post 1.8 - wants plugin's registered name { - if (stricmp((*iter).getTitle(), name) == 0) - return id; - - ++id; + // searching for registered plugin name + for (CPluginMngr::iterator iter = g_plugins.begin(); iter; ++iter) + { + if (stricmp((*iter).getTitle(), name) == 0) + return id; + + ++id; + } + } + else + { + // searching for filename + // filename search is case sensitive + for (CPluginMngr::iterator iter = g_plugins.begin(); iter; ++iter) + { + if (strcmp((*iter).getName(), name) == 0) + return id; + + ++id; + } } return -1; diff --git a/plugins/include/amxmodx.inc b/plugins/include/amxmodx.inc index 72b032e1..fb9d8e08 100755 --- a/plugins/include/amxmodx.inc +++ b/plugins/include/amxmodx.inc @@ -604,9 +604,23 @@ native get_module(id, name[], nameLen, author[], authorLen, version[], versionLe /* Returns number of currently registered modules */ native get_modulesnum(); -/* Checks whether a plugin is loaded. If it is not, the return value is -1, otherwise -* the return value is the plugin id. The function is case insensitive. */ -native is_plugin_loaded(const name[]); +/** + * Checks whether a plugin is loaded by the given registered name (such as "Admin Base"), or, optionally + * the given filename ("admin.amxx"). + * + * @param name Either the plugin name to lookup, or the plugin filename to lookup. + * @param usefilename Set to true if you want to search for the plugin by the filename, false to search + * by the plugin's registered name. + * + * @return Plugin ID of the matching plugin on a successful search, -1 on a failed search. + * + * @note Prior to 1.8, this function would only search for plugins registered names, not + * the filename. + * + * @note The plugin registered name search is a case insensitive search, however, the plugin + * filename search is case sensitive. + */ +native is_plugin_loaded(const name[], bool:usefilename=false); /* Gets info about plugin by given index. * Function returns -1 if plugin doesn't exist with given index. diff --git a/plugins/menufront.sma b/plugins/menufront.sma index cbe24164..d6869ab8 100755 --- a/plugins/menufront.sma +++ b/plugins/menufront.sma @@ -191,7 +191,9 @@ displayMenu(id, pos) for (new a = start; a < end; ++a) { - if (access(id, g_menuAccess[a]) && (is_plugin_loaded(g_menuPlugin[a]) != -1)) + if ( access(id, g_menuAccess[a]) && + ((is_plugin_loaded(g_menuPlugin[a]) != -1) || // search plugins for registered name + (is_plugin_loaded(g_menuPlugin[a], true) != -1))) // search plugins for filename { keys |= (1< - Add a menu item to Menus Front-End") - register_srvcmd("amx_addclientmenuitem", "addclientmenuitem_cmd", 0, " - Add a menu item to Client Menus Front-End") + register_srvcmd("amx_addmenuitem", "addmenuitem_cmd", 0, " - Add a menu item to Menus Front-End") + register_srvcmd("amx_addclientmenuitem", "addclientmenuitem_cmd", 0, " - Add a menu item to Client Menus Front-End") g_coloredMenus = colored_menus() diff --git a/plugins/pluginmenu.sma b/plugins/pluginmenu.sma index 4a56acd4..fc48f363 100644 --- a/plugins/pluginmenu.sma +++ b/plugins/pluginmenu.sma @@ -80,11 +80,11 @@ public plugin_init() // Add these menus to the amxmodmenu public plugin_cfg() { - new PluginName[64]; + new PluginFileName[64]; - get_plugin(-1,"",0,PluginName,sizeof(PluginName)-1); - AddMenuItem("Plugin Cvars", "amx_plugincvarmenu", ADMIN_CVAR, PluginName); - AddMenuItem("Plugin Commands", "amx_plugincmdmenu", ADMIN_MENU, PluginName); + get_plugin(-1, PluginFileName, charsmax(PluginFileName)); + AddMenuItem("Plugin Cvars", "amx_plugincvarmenu", ADMIN_CVAR, PluginFileName); + AddMenuItem("Plugin Commands", "amx_plugincmdmenu", ADMIN_MENU, PluginFileName); } // Reset all fields for each client as they connect.