core/metamod_console.cpp
author Scott Ehlert <ds@alliedmods.net>
Thu Dec 10 00:59:50 2009 -0600 (2009-12-10)
changeset 689 4065ba5e9155
parent 674 c4ed595f6248
child 705 a1001281dcb1
permissions -rw-r--r--
Rewrote user message caching code to always use IServerGameDLL::GetUserMessageInfo (bug 4117, r=dvander).

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