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