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