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