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