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