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