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