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