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