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