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