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