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