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