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