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