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