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