From 6c0300801f948146f3c1c2734672dcd8e38abe01 Mon Sep 17 00:00:00 2001 From: Steve Dudenhoeffer Date: Thu, 21 Jun 2007 15:26:02 +0000 Subject: [PATCH] Added amb32 - amxx {cvars,cmds} now takes an optional parameter to filter plugins by plugin filename --- amxmodx/srvcmd.cpp | 49 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/amxmodx/srvcmd.cpp b/amxmodx/srvcmd.cpp index 8ad64140..79f1f456 100755 --- a/amxmodx/srvcmd.cpp +++ b/amxmodx/srvcmd.cpp @@ -137,9 +137,24 @@ void amx_command() int ammount = 0; - for (CList::iterator a = g_cvars.begin(); a; ++a) + if (CMD_ARGC() > 2) // Searching for cvars registered to a plugin { - print_srvconsole(" [%3d] %-24.23s %-24.23s %-16.15s\n", ++ammount, (*a).getName(), CVAR_GET_STRING((*a).getName()), (*a).getPluginName()); + const char* targetname = CMD_ARGV(2); + size_t len = strlen(targetname); + for (CList::iterator a = g_cvars.begin(); a; ++a) + { + if (strncmp((*a).getPluginName(), targetname, len) == 0) + { + print_srvconsole(" [%3d] %-24.23s %-24.23s %-16.15s\n", ++ammount, (*a).getName(), CVAR_GET_STRING((*a).getName()), (*a).getPluginName()); + } + } + } + else // No search + { + for (CList::iterator a = g_cvars.begin(); a; ++a) + { + print_srvconsole(" [%3d] %-24.23s %-24.23s %-16.15s\n", ++ammount, (*a).getName(), CVAR_GET_STRING((*a).getName()), (*a).getPluginName()); + } } print_srvconsole("%d cvars\n", ammount); @@ -154,13 +169,29 @@ void amx_command() CmdMngr::iterator a = g_commands.begin(CMD_ConsoleCommand); - while (a) + if (CMD_ARGC() > 2) // Searching for commands registered to a plugin { - UTIL_GetFlags(access, (*a).getFlags()); - print_srvconsole(" [%3d] %-24.23s %-16.15s %-8.7s %-16.15s\n", ++ammount, (*a).getCmdLine(), access, (*a).getCmdType(), (*a).getPlugin()->getName()); - ++a; + const char* targetname = CMD_ARGV(2); + size_t len = strlen(targetname); + while (a) + { + if (strncmp((*a).getPlugin()->getName(), targetname, len) == 0) + { + UTIL_GetFlags(access, (*a).getFlags()); + print_srvconsole(" [%3d] %-24.23s %-16.15s %-8.7s %-16.15s\n", ++ammount, (*a).getCmdLine(), access, (*a).getCmdType(), (*a).getPlugin()->getName()); + } + ++a; + } + } + else // No search + { + while (a) + { + UTIL_GetFlags(access, (*a).getFlags()); + print_srvconsole(" [%3d] %-24.23s %-16.15s %-8.7s %-16.15s\n", ++ammount, (*a).getCmdLine(), access, (*a).getCmdType(), (*a).getPlugin()->getName()); + ++a; + } } - print_srvconsole("%d commands\n",ammount); } else if (!strcmp(cmd, "version")) @@ -267,8 +298,8 @@ void amx_command() print_srvconsole(" gpl - print the license\n"); print_srvconsole(" plugins - list plugins currently loaded\n"); print_srvconsole(" modules - list modules currently loaded\n"); - print_srvconsole(" cvars - list cvars registered by plugins\n"); - print_srvconsole(" cmds - list commands registered by plugins\n"); + print_srvconsole(" cvars [ plugin ] - list cvars registered by plugins\n"); + print_srvconsole(" cmds [ plugin ] - list commands registered by plugins\n"); print_srvconsole(" pause < plugin > - pause a running plugin\n"); print_srvconsole(" unpause < plugin > - unpause a previously paused plugin\n"); }