sourcemm/metamod_console.cpp
author David Anderson <dvander@alliedmods.net>
Thu Sep 27 19:28:05 2007 +0000 (2007-09-27)
branchsourcemm-1.6.0
changeset 356 bbcf8dcb2aa7
parent 352 7d8c71df909f
child 359 9b3c625f3a83
permissions -rw-r--r--
removed unnecessary api call
     1 /* ======== SourceMM ========
     2  * Copyright (C) 2004-2007 Metamod:Source Development Team
     3  * No warranties of any kind
     4  *
     5  * License: zlib/libpng
     6  *
     7  * Author(s): David "BAILOPAN" Anderson
     8  * ============================
     9  */
    10 
    11 #if defined _DEBUG
    12 #define DEBUG2
    13 #undef _DEBUG
    14 #endif
    15 #include <ctype.h>
    16 #include "metamod.h"
    17 #include "metamod_util.h"
    18 #include "metamod_console.h"
    19 #include "metamod_plugins.h"
    20 #if defined DEBUG2
    21 #undef DEBUG2
    22 #define _DEBUG
    23 #endif
    24 
    25 using namespace SourceMM;
    26 using namespace SourceHook;
    27 
    28 /**
    29  * @brief Console Command Implementations
    30  * @file concommands.cpp
    31  */
    32 
    33 #define CONMSG			g_Metamod.ConPrintf
    34 #define CLIENT_CONMSG	g_Metamod.ClientConPrintf
    35 
    36 bool Command_Meta(edict_t *pEdict, IMetamodSourceCommandInfo *info)
    37 {
    38 	unsigned int args = info->GetArgCount();
    39 
    40 	if (args >= 1)
    41 	{
    42 		const char *command = info->GetArg(1);
    43 		if (strcmp(command, "credits") == 0)
    44 		{
    45 			CONMSG("Metamod:Source was developed by:\n");
    46 			CONMSG("  SourceHook: Pavol \"PM OnoTo\" Marko\n");
    47 			CONMSG("  GameDLL/Plugins: David \"BAILOPAN\" Anderson\n");
    48 			CONMSG("  GameDLL: Scott \"Damaged Soul\" Ehlert\n");
    49 			CONMSG("For more information, see the official website\n");
    50 			CONMSG("http://www.sourcemm.net/\n");
    51 			
    52 			return true;
    53 		}
    54 		else if (strcmp(command, "version") == 0)
    55 		{
    56 			CONMSG("Metamod:Source version %s\n", SOURCEMM_VERSION);
    57 			CONMSG("Compiled on: %s\n", SOURCEMM_DATE);
    58 			CONMSG("Plugin interface version: %d:%d\n", PLAPI_VERSION, PLAPI_MIN_VERSION);
    59 			CONMSG("SourceHook version: %d:%d\n", g_SourceHook.GetIfaceVersion(), g_SourceHook.GetImplVersion());
    60 			CONMSG("http://www.sourcemm.net/\n");
    61 
    62 			return true;
    63 		}
    64 		else if (strcmp(command, "game") == 0)
    65 		{
    66 			CONMSG("GameDLL Information\n");
    67 			CONMSG("  Description: %s\n", provider->GetGameDescription());
    68 			CONMSG("  Mod Path: %s\n", g_Metamod.GetBaseDir());
    69 			CONMSG("  DLL Path: %s\n", g_Metamod.GetGameBinaryPath());
    70 			CONMSG("  Interface: ServerGameDLL%03d\n", g_Metamod.GetGameDLLVersion());
    71 
    72 			// Display user messages
    73 			int messages = g_Metamod.GetUserMessageCount();
    74 			if (messages == -1)
    75 			{
    76 				const char *msgname;
    77 				int msgsize;
    78 
    79 				if (messages > 0)
    80 				{
    81 					CONMSG("  User Messages:  %-32.31s  %-5s  %-5s\n", "Name", "Index", "Size");
    82 
    83 					for (int i = 0; i < messages; i++)
    84 					{
    85 						msgname = g_Metamod.GetUserMessage(i, &msgsize);
    86 
    87 						CONMSG("                  %-32.31s  %-5d  %-5d\n", msgname, i, msgsize); 
    88 					}
    89 
    90 					CONMSG("  %d user message%s in total\n", messages, (messages > 1) ? "s" : "");
    91 				}
    92 				else
    93 				{
    94 					CONMSG("  User Messages: None\n");
    95 				}
    96 			}
    97 			else
    98 			{
    99 				CONMSG("  User Messages: Failed to get list of user messages\n");
   100 			}
   101 
   102 			return true;
   103 		}
   104 		else if (strcmp(command, "refresh") == 0)
   105 		{
   106 			char full_path[255];
   107 			g_Metamod.PathFormat(full_path,
   108 				sizeof(full_path),
   109 				"%s/%s",
   110 				g_Metamod.GetBaseDir(), 
   111 				g_Metamod.GetPluginsFile());
   112 
   113 			LoadPluginsFromFile(full_path);
   114 
   115 			return true;
   116 		}
   117 		else if (strcmp(command, "list") == 0)
   118 		{
   119 			CPluginManager::CPlugin *pl;
   120 			ISmmPlugin *plapi;
   121 			const char *plname;
   122 			PluginIter i;
   123 			char buffer[256];
   124 			int len;
   125 			int plnum = g_PluginMngr.GetPluginCount();
   126 
   127 			if (!plnum)
   128 			{
   129 				CONMSG("No plugins loaded.\n");
   130 				return true;
   131 			} else {
   132 				CONMSG("Listing %d plugin%s:\n", plnum, (plnum > 1) ? "s" : "");
   133 			}
   134 
   135 			for (i = g_PluginMngr._begin(); i != g_PluginMngr._end(); i++)
   136 			{
   137 				pl = (*i);
   138 				if (!pl)
   139 				{
   140 					break;
   141 				}
   142 
   143 				len = 0;
   144 
   145 				if (pl->m_Status != Pl_Running)
   146 				{
   147 					len += UTIL_Format(buffer, sizeof(buffer), "  [%02d] <%s>", pl->m_Id, g_PluginMngr.GetStatusText(pl));
   148 				} else {
   149 					len += UTIL_Format(buffer, sizeof(buffer), "  [%02d]", pl->m_Id);
   150 				}
   151 
   152 				if ((plapi = pl->m_API))
   153 				{
   154 					plname = IS_STR_FILLED(plapi->GetName()) ? plapi->GetName() : pl->m_File.c_str();
   155 					len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " %s", plname);
   156 
   157 					if (IS_STR_FILLED(plapi->GetVersion()))
   158 					{
   159 						len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " (%s)", plapi->GetVersion());
   160 					}
   161 					if (IS_STR_FILLED(plapi->GetAuthor()))
   162 					{
   163 						UTIL_Format(&buffer[len], sizeof(buffer)-len, " by %s", plapi->GetAuthor());
   164 					}
   165 				}
   166 
   167 				CONMSG("%s\n", buffer);
   168 			}
   169 
   170 			return true;
   171 		}
   172 		else if (strcmp(command, "cmds") == 0)
   173 		{
   174 			if (args >= 2)
   175 			{
   176 				int id = atoi(info->GetArg(2));
   177 				CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
   178 
   179 				if (!pl)
   180 				{
   181 					CONMSG("Plugin %d not found.\n", id);
   182 					return true;
   183 				}
   184 
   185 				if (!pl->m_API)
   186 				{
   187 					CONMSG("Plugin %d is not loaded.\n", id);
   188 				}
   189 				else
   190 				{
   191 					CONMSG("Console commands for %s:\n", pl->m_API->GetName());
   192 					List<ConCommandBase *>::iterator ci;
   193 					size_t count = 0;
   194 
   195 					for (ci=pl->m_Cmds.begin(); ci!=pl->m_Cmds.end(); ci++)
   196 					{
   197 						count++;
   198 						CONMSG(" [%5d] %-s\n", count, (*ci)->GetName());
   199 					}
   200 				}
   201 			}
   202 			else
   203 			{
   204 				CONMSG("Usage: meta cmds <id>\n");
   205 			}
   206 
   207 			return true;
   208 		}
   209 		else if (strcmp(command, "cvars") == 0)
   210 		{
   211 			if (args >= 2)
   212 			{
   213 				int id = atoi(info->GetArg(2));
   214 				CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
   215 
   216 				if (!pl)
   217 				{
   218 					CONMSG("Plugin %d not found.\n", id);
   219 					return true;
   220 				}
   221 
   222 				if (!pl->m_API)
   223 				{
   224 					CONMSG("Plugin %d is not loaded.\n", id);
   225 				}
   226 				else
   227 				{
   228 					CONMSG("Registered cvars for %s:\n", pl->m_API->GetName());
   229 					List<ConCommandBase *>::iterator ci;
   230 					size_t count = 0;
   231 
   232 					for (ci=pl->m_Cvars.begin(); ci!=pl->m_Cvars.end(); ci++)
   233 					{
   234 						count++;
   235 						CONMSG(" [%5d] %-s\n", count, (*ci)->GetName());
   236 					}
   237 				}
   238 			}
   239 			else
   240 			{
   241 				CONMSG("Usage: meta cvars <id>\n");
   242 			}
   243 
   244 			return true;
   245 		}
   246 		else if (strcmp(command, "info") == 0)
   247 		{
   248 			if (args >= 2)
   249 			{
   250 				int id = atoi(info->GetArg(2));
   251 				CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
   252 				if (!pl)
   253 				{
   254 					CONMSG("Plugin %d not found.\n", id);
   255 					return true;
   256 				}
   257 
   258 				if (!pl->m_API)
   259 				{
   260 					CONMSG("Plugin %d is not loaded.\n", id);
   261 				}
   262 				else
   263 				{
   264 					if (pl->m_Status == Pl_Paused)
   265 					{
   266 						CONMSG("Plugin %d is paused.\n", id);
   267 					}
   268 					else if (pl->m_Status == Pl_Running)
   269 					{
   270 						char run_msg[255];
   271 						bool run = false;
   272 						if (pl->m_API && pl->m_API->QueryRunning(run_msg, sizeof(run_msg)-1))
   273 						{
   274 							run = true;
   275 						}
   276 						if (run)
   277 						{
   278 							CONMSG("Plugin %d is running.\n", id);
   279 						}
   280 						else
   281 						{
   282 							CONMSG("Plugin %d is stopped: %s\n", id, run_msg);
   283 						}
   284 					}
   285 					CONMSG("  Name: \"%s\" by %s\n", pl->m_API->GetName(), pl->m_API->GetAuthor());
   286 					CONMSG("  Version: %s\n", pl->m_API->GetVersion());
   287 					CONMSG("  Description: %s\n", pl->m_API->GetDescription());
   288 					CONMSG("  License: %s\n", pl->m_API->GetLicense());
   289 					CONMSG("  URL: %s\n", pl->m_API->GetURL());
   290 					CONMSG("  Details: API %03d, Date: %s\n", pl->m_API->GetApiVersion(), pl->m_API->GetDate());
   291 				}
   292 				CONMSG("File: %s\n\n", pl->m_File.c_str());
   293 
   294 				return true;
   295 			}
   296 			else
   297 			{
   298 				CONMSG("Usage: meta info <id>\n");
   299 
   300 				return true;
   301 			}
   302 		}
   303 		else if (strcmp(command, "pause") == 0)
   304 		{
   305 			if (args >= 2)
   306 			{
   307 				int id = atoi(info->GetArg(2));
   308 
   309 				char error[255];
   310 
   311 				if (!g_PluginMngr.Pause(id, error, sizeof(error)))
   312 				{
   313 					CONMSG("Pause failed: %s\n", error);
   314 					return true;
   315 				}
   316 				
   317 				CONMSG("Plugin %d has been paused.\n", id);
   318 
   319 				return true;
   320 			}
   321 			else
   322 			{
   323 				CONMSG("Usage: meta pause <id>\n");
   324 
   325 				return true;
   326 			}
   327 		}
   328 		else if (strcmp(command, "unpause") == 0)
   329 		{
   330 			if (args >= 2)
   331 			{
   332 				int id = atoi(info->GetArg(2));
   333 				char error[255];
   334 
   335 				if (!g_PluginMngr.Unpause(id, error, sizeof(error)))
   336 				{
   337 					CONMSG("Unpause failed: %s\n", error);
   338 					return true;
   339 				}
   340 
   341 				CONMSG("Plugin %d has been unpaused.\n", id);
   342 
   343 				return true;
   344 			}
   345 			else
   346 			{
   347 				CONMSG("Usage: meta unpause <id>\n");
   348 
   349 				return true;
   350 			}
   351 		}
   352 		else if (strcmp(command, "load") == 0)
   353 		{
   354 			if (args >= 2)
   355 			{
   356 				const char *file = info->GetArg(2);
   357 				char full_path[255];
   358 
   359 				const char *alias = g_PluginMngr.LookupAlias(file);
   360 				if (alias)
   361 				{
   362 					file = alias;
   363 				}
   364 
   365 				if (file[0] == '/' || strcmp(&(file[1]), ":\\") == 0)
   366 				{
   367 					g_Metamod.PathFormat(full_path, sizeof(full_path), "%s", file);
   368 				}
   369 				else
   370 				{
   371 					const char *ext = UTIL_GetExtension(file);
   372 #if defined WIN32 || defined _WIN32
   373 					ext = ext ? "" : ".dll";
   374 #else
   375 					ext = ext ? "" : "_i486.so";
   376 #endif
   377 					g_Metamod.PathFormat(full_path,
   378 						sizeof(full_path),
   379 						"%s/%s%s",
   380 						g_Metamod.GetBaseDir(),
   381 						file,
   382 						ext);
   383 				}
   384 
   385 				char error[255]={0};
   386 				bool already;
   387 				CPluginManager::CPlugin *pl;
   388 
   389 				PluginId id = g_PluginMngr.Load(full_path, Pl_Console, already, error, sizeof(error));
   390 				pl = g_PluginMngr.FindById(id);
   391 				if (!pl || id < Pl_MinId || (pl->m_Status < Pl_Paused))
   392 				{
   393 					CONMSG("Failed to load plugin %s (%s).\n", file, error);
   394 					return true;
   395 				}
   396 
   397 				if (!already)
   398 				{
   399 					CONMSG("Plugin \"%s\" loaded with id %d.\n", pl->m_API->GetName(), pl->m_Id);
   400 				} else {
   401 					CONMSG("Plugin \"%s\" is already loaded as %d.\n", pl->m_API->GetName(), pl->m_Id);
   402 				}
   403 				
   404 				return true;
   405 			}
   406 			else
   407 			{
   408 				CONMSG("Usage: meta load <path>\n");
   409 
   410 				return true;
   411 			}
   412 		}
   413 		else if ( (strcmp(command, "alias") == 0) ||
   414 					(strcmp(command, "aliases") == 0) )
   415 		{
   416 			if (args >= 3)
   417 			{
   418 				const char *alias = info->GetArg(2);
   419 				const char *value = info->GetArg(3);
   420 
   421 				g_PluginMngr.SetAlias(alias, value);
   422 				if (value == NULL || value[0] == '\0')
   423 				{
   424 					CONMSG("Deleted alias: %s.\n", alias);
   425 				} else {
   426 					CONMSG("Set alias \"%s\" to: %s\n", alias, value);
   427 				}
   428 			}
   429 			else if (args >= 2)
   430 			{
   431 				const char *alias = info->GetArg(2);
   432 				const char *value = g_PluginMngr.LookupAlias(alias);
   433 				if (value)
   434 				{
   435 					CONMSG("Alias \"%s\" is set to: %s\n", alias, value);
   436 				} else {
   437 					CONMSG("Alias \"%s\" was not found.\n", alias);
   438 				}
   439 			}
   440 			else
   441 			{
   442 				List<CNameAlias *>::iterator iter, end;
   443 				CNameAlias *p;
   444 
   445 				iter = g_PluginMngr._alias_begin();
   446 				end = g_PluginMngr._alias_end();
   447 				size_t total = 0;
   448 				if (iter != end)
   449 				{
   450 					CONMSG("%-10.9s %s\n", "Alias", "File");
   451 					CONMSG(" --- \n");
   452 					for (; iter!=end; iter++)
   453 					{
   454 						p = (*iter);
   455 						CONMSG("%-10.9s %s\n", p->alias.c_str(), p->value.c_str());
   456 						total++;
   457 					}
   458 					CONMSG(" --- \n");
   459 					CONMSG("%d aliases total.\n", total);
   460 				}
   461 				else
   462 				{
   463 					CONMSG("No aliases found.\n");
   464 				}
   465 			}
   466 			return true;
   467 		}
   468 		else if (strcmp(command, "unload") == 0)
   469 		{
   470 			if (args >= 2)
   471 			{
   472 				const char *file = info->GetArg(2);
   473 				int id = atoi(file);
   474 				char error[255]={0};
   475 
   476 				if (id == 0 && isalpha(file[0]))
   477 				{
   478 					char full_path[255];
   479 					const char *alias = g_PluginMngr.LookupAlias(file);
   480 
   481 					if (alias)
   482 					{
   483 						file = alias;
   484 					}
   485 
   486 					/* first check if it's a known filename */
   487 					if (file[0] == '/' || strcmp(&(file[1]), ":\\") == 0)
   488 					{
   489 						g_Metamod.PathFormat(full_path, sizeof(full_path), "%s", file);
   490 					}
   491 					else
   492 					{
   493 						const char *ext = UTIL_GetExtension(file);
   494 #if defined WIN32 || defined _WIN32
   495 						ext = ext ? "" : ".dll";
   496 #else
   497 						ext = ext ? "" : "_i486.so";
   498 #endif
   499 						g_Metamod.PathFormat(full_path,
   500 							sizeof(full_path),
   501 							"%s/%s%s",
   502 							g_Metamod.GetBaseDir(),
   503 							file,
   504 							ext);
   505 					}
   506 
   507 					List<CPluginManager::CPlugin *>::iterator iter, end;
   508 					CPluginManager::CPlugin *pl;
   509 					iter = g_PluginMngr._begin();
   510 					end = g_PluginMngr._end();
   511 					for (; iter!=end; iter++)
   512 					{
   513 						pl = (*iter);
   514 						if (strcmp(pl->m_File.c_str(), full_path) == 0)
   515 						{
   516 							id = pl->m_Id;
   517 							break;
   518 						}
   519 					}
   520 					if (id == 0)
   521 					{
   522 						CONMSG("Plugin \"%s\" not found.\n", full_path);
   523 						return true;
   524 					}
   525 				}
   526 
   527 				if (!g_PluginMngr.Unload(id, false, error, sizeof(error)))
   528 				{
   529 					CONMSG("Unload failed: %s\n", error);
   530 					return true;
   531 				}
   532 
   533 				CONMSG("Plugin %d unloaded.\n", id);
   534 			}
   535 			else
   536 			{
   537 				CONMSG("Usage: meta unload <id>\n");
   538 			}
   539 			return true;
   540 		}
   541 		else if (strcmp(command, "force_unload") == 0)
   542 		{
   543 			if (args >= 2)
   544 			{
   545 				int id = atoi(info->GetArg(2));
   546 				char error[255]={0};
   547 
   548 				if (!g_PluginMngr.Unload(id, false, error, sizeof(error)))
   549 				{
   550 					CONMSG("Force unload failed: %s\n", error);
   551 					return true;
   552 				}
   553 
   554 				CONMSG("Plugin %d force unloaded.\n", id);
   555 
   556 				return true;
   557 			}
   558 			else
   559 			{
   560 				CONMSG("Usage: meta force_unload <id>\n");
   561 
   562 				return true;
   563 			}
   564 		}
   565 		else if (strcmp(command, "clear") == 0)
   566 		{
   567 			if (!g_PluginMngr.UnloadAll())
   568 			{
   569 				CONMSG("One or more plugins resisted removal (cleaned anyway).\n");
   570 				return true;
   571 			} 
   572 
   573 			CONMSG("All plugins unloaded.\n");
   574 
   575 			return true;
   576 		}
   577 		else if (strcmp(command, "retry") == 0)
   578 		{
   579 			if (args >= 2)
   580 			{
   581 				int id = atoi(info->GetArg(2));
   582 				char error[255];
   583 
   584 				if (!g_PluginMngr.Retry(id, error, sizeof(error)))
   585 				{
   586 					CONMSG("Error reloading plugin: %s\n", error);
   587 					return true;
   588 				}
   589 
   590 				CONMSG("Plugin %d successfully reloaded.\n", id);
   591 
   592 				return true;
   593 			}
   594 			else
   595 			{
   596 				CONMSG("Usage: meta retry <id>\n");
   597 
   598 				return true;
   599 			}
   600 		}
   601 	}
   602 
   603 	CONMSG("Metamod:Source Menu\n");
   604 	CONMSG("usage: meta <command> [arguments]\n");
   605 	CONMSG("  alias        - List or set an alias\n");
   606 	CONMSG("  clear        - Unload all plugins forcefully\n");
   607 	CONMSG("  cmds         - Show plugin commands\n");
   608 	CONMSG("  cvars        - Show plugin cvars\n");
   609 	CONMSG("  credits      - About Metamod:Source\n");
   610 	CONMSG("  force_unload - Forcefully unload a plugin\n");
   611 	CONMSG("  game         - Information about GameDLL\n");
   612 	CONMSG("  info         - Information about a plugin\n");
   613 	CONMSG("  list         - List plugins\n");
   614 	CONMSG("  load         - Load a plugin\n");
   615 	CONMSG("  pause        - Pause a running plugin\n");
   616 	CONMSG("  refresh      - Reparse plugins file\n");
   617 	CONMSG("  retry        - Attempt to reload a plugin\n");
   618 	CONMSG("  unload       - Unload a loaded plugin\n");
   619 	CONMSG("  unpause      - Unpause a paused plugin\n");
   620 	CONMSG("  version      - Version information\n");
   621 
   622 	return true;
   623 }
   624 
   625 bool Command_ClientMeta(edict_t *client, IMetamodSourceCommandInfo *info)
   626 {
   627 	const char *cmd = info->GetArg(0);
   628 
   629 	if (strcmp(cmd, "meta") == 0)
   630 	{
   631 		unsigned int args = info->GetArgCount();
   632 		if (args == 1)
   633 		{
   634 			const char *subcmd = info->GetArg(1);
   635 
   636 			if (strcmp(subcmd, "credits") == 0)
   637 			{
   638 				CLIENT_CONMSG(client, "Metamod:Source was developed by:\n");
   639 				CLIENT_CONMSG(client, "  SourceHook: Pavol \"PM OnoTo\" Marko\n");
   640 				CLIENT_CONMSG(client, "  GameDLL/Plugins: David \"BAILOPAN\" Anderson\n");
   641 				CLIENT_CONMSG(client, "  GameDLL: Scott \"Damaged Soul\" Ehlert\n");
   642 				CLIENT_CONMSG(client, "For more information, see the official website\n");
   643 				CLIENT_CONMSG(client, "http://www.sourcemm.net/\n");
   644 
   645 				return true;
   646 			}
   647 			else if(strcmp(subcmd, "version") == 0)
   648 			{
   649 				CLIENT_CONMSG(client, "Metamod:Source version %s\n", SOURCEMM_VERSION);
   650 				CLIENT_CONMSG(client, "Compiled on: %s\n", SOURCEMM_DATE);
   651 				CLIENT_CONMSG(client, "Plugin interface version: %d:%d\n", PLAPI_VERSION, PLAPI_MIN_VERSION);
   652 				CLIENT_CONMSG(client, "SourceHook version: %d:%d\n", g_SourceHook.GetIfaceVersion(), g_SourceHook.GetImplVersion());
   653 				CLIENT_CONMSG(client, "http://www.sourcemm.net/\n");
   654 
   655 				return true;
   656 			}
   657 			else if(strcmp(subcmd, "list") == 0)
   658 			{
   659 				CPluginManager::CPlugin *pl;
   660 				ISmmPlugin *plapi;
   661 				const char *plname;
   662 				PluginIter i;
   663 				char buffer[256];
   664 				int len = 0;
   665 				int plnum = 0;
   666 
   667 				for (i = g_PluginMngr._begin(); i != g_PluginMngr._end(); i++, len=0)
   668 				{
   669 					pl = (*i);
   670 					if (pl && pl->m_Status == Pl_Running)
   671 					{
   672 						plapi = pl->m_API;
   673 						if (!plapi || !plapi->QueryRunning(NULL, 0))
   674 						{
   675 							continue;
   676 						}
   677 						plnum++;
   678 
   679 						len += UTIL_Format(buffer, sizeof(buffer), "  [%02d]", plnum);
   680 
   681 						plname = IS_STR_FILLED(plapi->GetName()) ? plapi->GetName() : pl->m_File.c_str();
   682 						len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " %s", plname);
   683 
   684 						if (IS_STR_FILLED(plapi->GetVersion()))
   685 						{
   686 							len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " (%s)", plapi->GetVersion());
   687 						}
   688 						if (IS_STR_FILLED(plapi->GetAuthor()))
   689 						{
   690 							UTIL_Format(&buffer[len], sizeof(buffer)-len, " by %s", plapi->GetAuthor());
   691 						}
   692 
   693 						CLIENT_CONMSG(client, "%s\n", buffer);
   694 					}
   695 				}
   696 
   697 				if (!plnum)
   698 				{
   699 					CLIENT_CONMSG(client, "No active plugins loaded.\n");
   700 				}
   701 
   702 				return true;
   703 			}
   704 		}
   705 
   706 		CLIENT_CONMSG(client, "Metamod:Source Menu\n");
   707 		CLIENT_CONMSG(client, "usage: meta <command>\n");
   708 		CLIENT_CONMSG(client, "  credits - About Metamod:Source\n");
   709 		CLIENT_CONMSG(client, "  list    - List plugins\n");
   710 		CLIENT_CONMSG(client, "  version - Version information\n");
   711 
   712 		return true;
   713 	}
   714 
   715 	return false;
   716 }