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