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