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