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