sourcemm/metamod_console.cpp
branchsourcemm-1.6.0
changeset 352 7d8c71df909f
child 359 9b3c625f3a83
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/sourcemm/metamod_console.cpp	Sat Sep 22 18:08:30 2007 +0000
     1.3 @@ -0,0 +1,716 @@
     1.4 +/* ======== SourceMM ========
     1.5 + * Copyright (C) 2004-2007 Metamod:Source Development Team
     1.6 + * No warranties of any kind
     1.7 + *
     1.8 + * License: zlib/libpng
     1.9 + *
    1.10 + * Author(s): David "BAILOPAN" Anderson
    1.11 + * ============================
    1.12 + */
    1.13 +
    1.14 +#if defined _DEBUG
    1.15 +#define DEBUG2
    1.16 +#undef _DEBUG
    1.17 +#endif
    1.18 +#include <ctype.h>
    1.19 +#include "metamod.h"
    1.20 +#include "metamod_util.h"
    1.21 +#include "metamod_console.h"
    1.22 +#include "metamod_plugins.h"
    1.23 +#if defined DEBUG2
    1.24 +#undef DEBUG2
    1.25 +#define _DEBUG
    1.26 +#endif
    1.27 +
    1.28 +using namespace SourceMM;
    1.29 +using namespace SourceHook;
    1.30 +
    1.31 +/**
    1.32 + * @brief Console Command Implementations
    1.33 + * @file concommands.cpp
    1.34 + */
    1.35 +
    1.36 +#define CONMSG			g_Metamod.ConPrintf
    1.37 +#define CLIENT_CONMSG	g_Metamod.ClientConPrintf
    1.38 +
    1.39 +bool Command_Meta(edict_t *pEdict, IMetamodSourceCommandInfo *info)
    1.40 +{
    1.41 +	unsigned int args = info->GetArgCount();
    1.42 +
    1.43 +	if (args >= 1)
    1.44 +	{
    1.45 +		const char *command = info->GetArg(1);
    1.46 +		if (strcmp(command, "credits") == 0)
    1.47 +		{
    1.48 +			CONMSG("Metamod:Source was developed by:\n");
    1.49 +			CONMSG("  SourceHook: Pavol \"PM OnoTo\" Marko\n");
    1.50 +			CONMSG("  GameDLL/Plugins: David \"BAILOPAN\" Anderson\n");
    1.51 +			CONMSG("  GameDLL: Scott \"Damaged Soul\" Ehlert\n");
    1.52 +			CONMSG("For more information, see the official website\n");
    1.53 +			CONMSG("http://www.sourcemm.net/\n");
    1.54 +			
    1.55 +			return true;
    1.56 +		}
    1.57 +		else if (strcmp(command, "version") == 0)
    1.58 +		{
    1.59 +			CONMSG("Metamod:Source version %s\n", SOURCEMM_VERSION);
    1.60 +			CONMSG("Compiled on: %s\n", SOURCEMM_DATE);
    1.61 +			CONMSG("Plugin interface version: %d:%d\n", PLAPI_VERSION, PLAPI_MIN_VERSION);
    1.62 +			CONMSG("SourceHook version: %d:%d\n", g_SourceHook.GetIfaceVersion(), g_SourceHook.GetImplVersion());
    1.63 +			CONMSG("http://www.sourcemm.net/\n");
    1.64 +
    1.65 +			return true;
    1.66 +		}
    1.67 +		else if (strcmp(command, "game") == 0)
    1.68 +		{
    1.69 +			CONMSG("GameDLL Information\n");
    1.70 +			CONMSG("  Description: %s\n", provider->GetGameDescription());
    1.71 +			CONMSG("  Mod Path: %s\n", g_Metamod.GetBaseDir());
    1.72 +			CONMSG("  DLL Path: %s\n", g_Metamod.GetGameBinaryPath());
    1.73 +			CONMSG("  Interface: ServerGameDLL%03d\n", g_Metamod.GetGameDLLVersion());
    1.74 +
    1.75 +			// Display user messages
    1.76 +			int messages = g_Metamod.GetUserMessageCount();
    1.77 +			if (messages == -1)
    1.78 +			{
    1.79 +				const char *msgname;
    1.80 +				int msgsize;
    1.81 +
    1.82 +				if (messages > 0)
    1.83 +				{
    1.84 +					CONMSG("  User Messages:  %-32.31s  %-5s  %-5s\n", "Name", "Index", "Size");
    1.85 +
    1.86 +					for (int i = 0; i < messages; i++)
    1.87 +					{
    1.88 +						msgname = g_Metamod.GetUserMessage(i, &msgsize);
    1.89 +
    1.90 +						CONMSG("                  %-32.31s  %-5d  %-5d\n", msgname, i, msgsize); 
    1.91 +					}
    1.92 +
    1.93 +					CONMSG("  %d user message%s in total\n", messages, (messages > 1) ? "s" : "");
    1.94 +				}
    1.95 +				else
    1.96 +				{
    1.97 +					CONMSG("  User Messages: None\n");
    1.98 +				}
    1.99 +			}
   1.100 +			else
   1.101 +			{
   1.102 +				CONMSG("  User Messages: Failed to get list of user messages\n");
   1.103 +			}
   1.104 +
   1.105 +			return true;
   1.106 +		}
   1.107 +		else if (strcmp(command, "refresh") == 0)
   1.108 +		{
   1.109 +			char full_path[255];
   1.110 +			g_Metamod.PathFormat(full_path,
   1.111 +				sizeof(full_path),
   1.112 +				"%s/%s",
   1.113 +				g_Metamod.GetBaseDir(), 
   1.114 +				g_Metamod.GetPluginsFile());
   1.115 +
   1.116 +			LoadPluginsFromFile(full_path);
   1.117 +
   1.118 +			return true;
   1.119 +		}
   1.120 +		else if (strcmp(command, "list") == 0)
   1.121 +		{
   1.122 +			CPluginManager::CPlugin *pl;
   1.123 +			ISmmPlugin *plapi;
   1.124 +			const char *plname;
   1.125 +			PluginIter i;
   1.126 +			char buffer[256];
   1.127 +			int len;
   1.128 +			int plnum = g_PluginMngr.GetPluginCount();
   1.129 +
   1.130 +			if (!plnum)
   1.131 +			{
   1.132 +				CONMSG("No plugins loaded.\n");
   1.133 +				return true;
   1.134 +			} else {
   1.135 +				CONMSG("Listing %d plugin%s:\n", plnum, (plnum > 1) ? "s" : "");
   1.136 +			}
   1.137 +
   1.138 +			for (i = g_PluginMngr._begin(); i != g_PluginMngr._end(); i++)
   1.139 +			{
   1.140 +				pl = (*i);
   1.141 +				if (!pl)
   1.142 +				{
   1.143 +					break;
   1.144 +				}
   1.145 +
   1.146 +				len = 0;
   1.147 +
   1.148 +				if (pl->m_Status != Pl_Running)
   1.149 +				{
   1.150 +					len += UTIL_Format(buffer, sizeof(buffer), "  [%02d] <%s>", pl->m_Id, g_PluginMngr.GetStatusText(pl));
   1.151 +				} else {
   1.152 +					len += UTIL_Format(buffer, sizeof(buffer), "  [%02d]", pl->m_Id);
   1.153 +				}
   1.154 +
   1.155 +				if ((plapi = pl->m_API))
   1.156 +				{
   1.157 +					plname = IS_STR_FILLED(plapi->GetName()) ? plapi->GetName() : pl->m_File.c_str();
   1.158 +					len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " %s", plname);
   1.159 +
   1.160 +					if (IS_STR_FILLED(plapi->GetVersion()))
   1.161 +					{
   1.162 +						len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " (%s)", plapi->GetVersion());
   1.163 +					}
   1.164 +					if (IS_STR_FILLED(plapi->GetAuthor()))
   1.165 +					{
   1.166 +						UTIL_Format(&buffer[len], sizeof(buffer)-len, " by %s", plapi->GetAuthor());
   1.167 +					}
   1.168 +				}
   1.169 +
   1.170 +				CONMSG("%s\n", buffer);
   1.171 +			}
   1.172 +
   1.173 +			return true;
   1.174 +		}
   1.175 +		else if (strcmp(command, "cmds") == 0)
   1.176 +		{
   1.177 +			if (args >= 2)
   1.178 +			{
   1.179 +				int id = atoi(info->GetArg(2));
   1.180 +				CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
   1.181 +
   1.182 +				if (!pl)
   1.183 +				{
   1.184 +					CONMSG("Plugin %d not found.\n", id);
   1.185 +					return true;
   1.186 +				}
   1.187 +
   1.188 +				if (!pl->m_API)
   1.189 +				{
   1.190 +					CONMSG("Plugin %d is not loaded.\n", id);
   1.191 +				}
   1.192 +				else
   1.193 +				{
   1.194 +					CONMSG("Console commands for %s:\n", pl->m_API->GetName());
   1.195 +					List<ConCommandBase *>::iterator ci;
   1.196 +					size_t count = 0;
   1.197 +
   1.198 +					for (ci=pl->m_Cmds.begin(); ci!=pl->m_Cmds.end(); ci++)
   1.199 +					{
   1.200 +						count++;
   1.201 +						CONMSG(" [%5d] %-s\n", count, (*ci)->GetName());
   1.202 +					}
   1.203 +				}
   1.204 +			}
   1.205 +			else
   1.206 +			{
   1.207 +				CONMSG("Usage: meta cmds <id>\n");
   1.208 +			}
   1.209 +
   1.210 +			return true;
   1.211 +		}
   1.212 +		else if (strcmp(command, "cvars") == 0)
   1.213 +		{
   1.214 +			if (args >= 2)
   1.215 +			{
   1.216 +				int id = atoi(info->GetArg(2));
   1.217 +				CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
   1.218 +
   1.219 +				if (!pl)
   1.220 +				{
   1.221 +					CONMSG("Plugin %d not found.\n", id);
   1.222 +					return true;
   1.223 +				}
   1.224 +
   1.225 +				if (!pl->m_API)
   1.226 +				{
   1.227 +					CONMSG("Plugin %d is not loaded.\n", id);
   1.228 +				}
   1.229 +				else
   1.230 +				{
   1.231 +					CONMSG("Registered cvars for %s:\n", pl->m_API->GetName());
   1.232 +					List<ConCommandBase *>::iterator ci;
   1.233 +					size_t count = 0;
   1.234 +
   1.235 +					for (ci=pl->m_Cvars.begin(); ci!=pl->m_Cvars.end(); ci++)
   1.236 +					{
   1.237 +						count++;
   1.238 +						CONMSG(" [%5d] %-s\n", count, (*ci)->GetName());
   1.239 +					}
   1.240 +				}
   1.241 +			}
   1.242 +			else
   1.243 +			{
   1.244 +				CONMSG("Usage: meta cvars <id>\n");
   1.245 +			}
   1.246 +
   1.247 +			return true;
   1.248 +		}
   1.249 +		else if (strcmp(command, "info") == 0)
   1.250 +		{
   1.251 +			if (args >= 2)
   1.252 +			{
   1.253 +				int id = atoi(info->GetArg(2));
   1.254 +				CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
   1.255 +				if (!pl)
   1.256 +				{
   1.257 +					CONMSG("Plugin %d not found.\n", id);
   1.258 +					return true;
   1.259 +				}
   1.260 +
   1.261 +				if (!pl->m_API)
   1.262 +				{
   1.263 +					CONMSG("Plugin %d is not loaded.\n", id);
   1.264 +				}
   1.265 +				else
   1.266 +				{
   1.267 +					if (pl->m_Status == Pl_Paused)
   1.268 +					{
   1.269 +						CONMSG("Plugin %d is paused.\n", id);
   1.270 +					}
   1.271 +					else if (pl->m_Status == Pl_Running)
   1.272 +					{
   1.273 +						char run_msg[255];
   1.274 +						bool run = false;
   1.275 +						if (pl->m_API && pl->m_API->QueryRunning(run_msg, sizeof(run_msg)-1))
   1.276 +						{
   1.277 +							run = true;
   1.278 +						}
   1.279 +						if (run)
   1.280 +						{
   1.281 +							CONMSG("Plugin %d is running.\n", id);
   1.282 +						}
   1.283 +						else
   1.284 +						{
   1.285 +							CONMSG("Plugin %d is stopped: %s\n", id, run_msg);
   1.286 +						}
   1.287 +					}
   1.288 +					CONMSG("  Name: \"%s\" by %s\n", pl->m_API->GetName(), pl->m_API->GetAuthor());
   1.289 +					CONMSG("  Version: %s\n", pl->m_API->GetVersion());
   1.290 +					CONMSG("  Description: %s\n", pl->m_API->GetDescription());
   1.291 +					CONMSG("  License: %s\n", pl->m_API->GetLicense());
   1.292 +					CONMSG("  URL: %s\n", pl->m_API->GetURL());
   1.293 +					CONMSG("  Details: API %03d, Date: %s\n", pl->m_API->GetApiVersion(), pl->m_API->GetDate());
   1.294 +				}
   1.295 +				CONMSG("File: %s\n\n", pl->m_File.c_str());
   1.296 +
   1.297 +				return true;
   1.298 +			}
   1.299 +			else
   1.300 +			{
   1.301 +				CONMSG("Usage: meta info <id>\n");
   1.302 +
   1.303 +				return true;
   1.304 +			}
   1.305 +		}
   1.306 +		else if (strcmp(command, "pause") == 0)
   1.307 +		{
   1.308 +			if (args >= 2)
   1.309 +			{
   1.310 +				int id = atoi(info->GetArg(2));
   1.311 +
   1.312 +				char error[255];
   1.313 +
   1.314 +				if (!g_PluginMngr.Pause(id, error, sizeof(error)))
   1.315 +				{
   1.316 +					CONMSG("Pause failed: %s\n", error);
   1.317 +					return true;
   1.318 +				}
   1.319 +				
   1.320 +				CONMSG("Plugin %d has been paused.\n", id);
   1.321 +
   1.322 +				return true;
   1.323 +			}
   1.324 +			else
   1.325 +			{
   1.326 +				CONMSG("Usage: meta pause <id>\n");
   1.327 +
   1.328 +				return true;
   1.329 +			}
   1.330 +		}
   1.331 +		else if (strcmp(command, "unpause") == 0)
   1.332 +		{
   1.333 +			if (args >= 2)
   1.334 +			{
   1.335 +				int id = atoi(info->GetArg(2));
   1.336 +				char error[255];
   1.337 +
   1.338 +				if (!g_PluginMngr.Unpause(id, error, sizeof(error)))
   1.339 +				{
   1.340 +					CONMSG("Unpause failed: %s\n", error);
   1.341 +					return true;
   1.342 +				}
   1.343 +
   1.344 +				CONMSG("Plugin %d has been unpaused.\n", id);
   1.345 +
   1.346 +				return true;
   1.347 +			}
   1.348 +			else
   1.349 +			{
   1.350 +				CONMSG("Usage: meta unpause <id>\n");
   1.351 +
   1.352 +				return true;
   1.353 +			}
   1.354 +		}
   1.355 +		else if (strcmp(command, "load") == 0)
   1.356 +		{
   1.357 +			if (args >= 2)
   1.358 +			{
   1.359 +				const char *file = info->GetArg(2);
   1.360 +				char full_path[255];
   1.361 +
   1.362 +				const char *alias = g_PluginMngr.LookupAlias(file);
   1.363 +				if (alias)
   1.364 +				{
   1.365 +					file = alias;
   1.366 +				}
   1.367 +
   1.368 +				if (file[0] == '/' || strcmp(&(file[1]), ":\\") == 0)
   1.369 +				{
   1.370 +					g_Metamod.PathFormat(full_path, sizeof(full_path), "%s", file);
   1.371 +				}
   1.372 +				else
   1.373 +				{
   1.374 +					const char *ext = UTIL_GetExtension(file);
   1.375 +#if defined WIN32 || defined _WIN32
   1.376 +					ext = ext ? "" : ".dll";
   1.377 +#else
   1.378 +					ext = ext ? "" : "_i486.so";
   1.379 +#endif
   1.380 +					g_Metamod.PathFormat(full_path,
   1.381 +						sizeof(full_path),
   1.382 +						"%s/%s%s",
   1.383 +						g_Metamod.GetBaseDir(),
   1.384 +						file,
   1.385 +						ext);
   1.386 +				}
   1.387 +
   1.388 +				char error[255]={0};
   1.389 +				bool already;
   1.390 +				CPluginManager::CPlugin *pl;
   1.391 +
   1.392 +				PluginId id = g_PluginMngr.Load(full_path, Pl_Console, already, error, sizeof(error));
   1.393 +				pl = g_PluginMngr.FindById(id);
   1.394 +				if (!pl || id < Pl_MinId || (pl->m_Status < Pl_Paused))
   1.395 +				{
   1.396 +					CONMSG("Failed to load plugin %s (%s).\n", file, error);
   1.397 +					return true;
   1.398 +				}
   1.399 +
   1.400 +				if (!already)
   1.401 +				{
   1.402 +					CONMSG("Plugin \"%s\" loaded with id %d.\n", pl->m_API->GetName(), pl->m_Id);
   1.403 +				} else {
   1.404 +					CONMSG("Plugin \"%s\" is already loaded as %d.\n", pl->m_API->GetName(), pl->m_Id);
   1.405 +				}
   1.406 +				
   1.407 +				return true;
   1.408 +			}
   1.409 +			else
   1.410 +			{
   1.411 +				CONMSG("Usage: meta load <path>\n");
   1.412 +
   1.413 +				return true;
   1.414 +			}
   1.415 +		}
   1.416 +		else if ( (strcmp(command, "alias") == 0) ||
   1.417 +					(strcmp(command, "aliases") == 0) )
   1.418 +		{
   1.419 +			if (args >= 3)
   1.420 +			{
   1.421 +				const char *alias = info->GetArg(2);
   1.422 +				const char *value = info->GetArg(3);
   1.423 +
   1.424 +				g_PluginMngr.SetAlias(alias, value);
   1.425 +				if (value == NULL || value[0] == '\0')
   1.426 +				{
   1.427 +					CONMSG("Deleted alias: %s.\n", alias);
   1.428 +				} else {
   1.429 +					CONMSG("Set alias \"%s\" to: %s\n", alias, value);
   1.430 +				}
   1.431 +			}
   1.432 +			else if (args >= 2)
   1.433 +			{
   1.434 +				const char *alias = info->GetArg(2);
   1.435 +				const char *value = g_PluginMngr.LookupAlias(alias);
   1.436 +				if (value)
   1.437 +				{
   1.438 +					CONMSG("Alias \"%s\" is set to: %s\n", alias, value);
   1.439 +				} else {
   1.440 +					CONMSG("Alias \"%s\" was not found.\n", alias);
   1.441 +				}
   1.442 +			}
   1.443 +			else
   1.444 +			{
   1.445 +				List<CNameAlias *>::iterator iter, end;
   1.446 +				CNameAlias *p;
   1.447 +
   1.448 +				iter = g_PluginMngr._alias_begin();
   1.449 +				end = g_PluginMngr._alias_end();
   1.450 +				size_t total = 0;
   1.451 +				if (iter != end)
   1.452 +				{
   1.453 +					CONMSG("%-10.9s %s\n", "Alias", "File");
   1.454 +					CONMSG(" --- \n");
   1.455 +					for (; iter!=end; iter++)
   1.456 +					{
   1.457 +						p = (*iter);
   1.458 +						CONMSG("%-10.9s %s\n", p->alias.c_str(), p->value.c_str());
   1.459 +						total++;
   1.460 +					}
   1.461 +					CONMSG(" --- \n");
   1.462 +					CONMSG("%d aliases total.\n", total);
   1.463 +				}
   1.464 +				else
   1.465 +				{
   1.466 +					CONMSG("No aliases found.\n");
   1.467 +				}
   1.468 +			}
   1.469 +			return true;
   1.470 +		}
   1.471 +		else if (strcmp(command, "unload") == 0)
   1.472 +		{
   1.473 +			if (args >= 2)
   1.474 +			{
   1.475 +				const char *file = info->GetArg(2);
   1.476 +				int id = atoi(file);
   1.477 +				char error[255]={0};
   1.478 +
   1.479 +				if (id == 0 && isalpha(file[0]))
   1.480 +				{
   1.481 +					char full_path[255];
   1.482 +					const char *alias = g_PluginMngr.LookupAlias(file);
   1.483 +
   1.484 +					if (alias)
   1.485 +					{
   1.486 +						file = alias;
   1.487 +					}
   1.488 +
   1.489 +					/* first check if it's a known filename */
   1.490 +					if (file[0] == '/' || strcmp(&(file[1]), ":\\") == 0)
   1.491 +					{
   1.492 +						g_Metamod.PathFormat(full_path, sizeof(full_path), "%s", file);
   1.493 +					}
   1.494 +					else
   1.495 +					{
   1.496 +						const char *ext = UTIL_GetExtension(file);
   1.497 +#if defined WIN32 || defined _WIN32
   1.498 +						ext = ext ? "" : ".dll";
   1.499 +#else
   1.500 +						ext = ext ? "" : "_i486.so";
   1.501 +#endif
   1.502 +						g_Metamod.PathFormat(full_path,
   1.503 +							sizeof(full_path),
   1.504 +							"%s/%s%s",
   1.505 +							g_Metamod.GetBaseDir(),
   1.506 +							file,
   1.507 +							ext);
   1.508 +					}
   1.509 +
   1.510 +					List<CPluginManager::CPlugin *>::iterator iter, end;
   1.511 +					CPluginManager::CPlugin *pl;
   1.512 +					iter = g_PluginMngr._begin();
   1.513 +					end = g_PluginMngr._end();
   1.514 +					for (; iter!=end; iter++)
   1.515 +					{
   1.516 +						pl = (*iter);
   1.517 +						if (strcmp(pl->m_File.c_str(), full_path) == 0)
   1.518 +						{
   1.519 +							id = pl->m_Id;
   1.520 +							break;
   1.521 +						}
   1.522 +					}
   1.523 +					if (id == 0)
   1.524 +					{
   1.525 +						CONMSG("Plugin \"%s\" not found.\n", full_path);
   1.526 +						return true;
   1.527 +					}
   1.528 +				}
   1.529 +
   1.530 +				if (!g_PluginMngr.Unload(id, false, error, sizeof(error)))
   1.531 +				{
   1.532 +					CONMSG("Unload failed: %s\n", error);
   1.533 +					return true;
   1.534 +				}
   1.535 +
   1.536 +				CONMSG("Plugin %d unloaded.\n", id);
   1.537 +			}
   1.538 +			else
   1.539 +			{
   1.540 +				CONMSG("Usage: meta unload <id>\n");
   1.541 +			}
   1.542 +			return true;
   1.543 +		}
   1.544 +		else if (strcmp(command, "force_unload") == 0)
   1.545 +		{
   1.546 +			if (args >= 2)
   1.547 +			{
   1.548 +				int id = atoi(info->GetArg(2));
   1.549 +				char error[255]={0};
   1.550 +
   1.551 +				if (!g_PluginMngr.Unload(id, false, error, sizeof(error)))
   1.552 +				{
   1.553 +					CONMSG("Force unload failed: %s\n", error);
   1.554 +					return true;
   1.555 +				}
   1.556 +
   1.557 +				CONMSG("Plugin %d force unloaded.\n", id);
   1.558 +
   1.559 +				return true;
   1.560 +			}
   1.561 +			else
   1.562 +			{
   1.563 +				CONMSG("Usage: meta force_unload <id>\n");
   1.564 +
   1.565 +				return true;
   1.566 +			}
   1.567 +		}
   1.568 +		else if (strcmp(command, "clear") == 0)
   1.569 +		{
   1.570 +			if (!g_PluginMngr.UnloadAll())
   1.571 +			{
   1.572 +				CONMSG("One or more plugins resisted removal (cleaned anyway).\n");
   1.573 +				return true;
   1.574 +			} 
   1.575 +
   1.576 +			CONMSG("All plugins unloaded.\n");
   1.577 +
   1.578 +			return true;
   1.579 +		}
   1.580 +		else if (strcmp(command, "retry") == 0)
   1.581 +		{
   1.582 +			if (args >= 2)
   1.583 +			{
   1.584 +				int id = atoi(info->GetArg(2));
   1.585 +				char error[255];
   1.586 +
   1.587 +				if (!g_PluginMngr.Retry(id, error, sizeof(error)))
   1.588 +				{
   1.589 +					CONMSG("Error reloading plugin: %s\n", error);
   1.590 +					return true;
   1.591 +				}
   1.592 +
   1.593 +				CONMSG("Plugin %d successfully reloaded.\n", id);
   1.594 +
   1.595 +				return true;
   1.596 +			}
   1.597 +			else
   1.598 +			{
   1.599 +				CONMSG("Usage: meta retry <id>\n");
   1.600 +
   1.601 +				return true;
   1.602 +			}
   1.603 +		}
   1.604 +	}
   1.605 +
   1.606 +	CONMSG("Metamod:Source Menu\n");
   1.607 +	CONMSG("usage: meta <command> [arguments]\n");
   1.608 +	CONMSG("  alias        - List or set an alias\n");
   1.609 +	CONMSG("  clear        - Unload all plugins forcefully\n");
   1.610 +	CONMSG("  cmds         - Show plugin commands\n");
   1.611 +	CONMSG("  cvars        - Show plugin cvars\n");
   1.612 +	CONMSG("  credits      - About Metamod:Source\n");
   1.613 +	CONMSG("  force_unload - Forcefully unload a plugin\n");
   1.614 +	CONMSG("  game         - Information about GameDLL\n");
   1.615 +	CONMSG("  info         - Information about a plugin\n");
   1.616 +	CONMSG("  list         - List plugins\n");
   1.617 +	CONMSG("  load         - Load a plugin\n");
   1.618 +	CONMSG("  pause        - Pause a running plugin\n");
   1.619 +	CONMSG("  refresh      - Reparse plugins file\n");
   1.620 +	CONMSG("  retry        - Attempt to reload a plugin\n");
   1.621 +	CONMSG("  unload       - Unload a loaded plugin\n");
   1.622 +	CONMSG("  unpause      - Unpause a paused plugin\n");
   1.623 +	CONMSG("  version      - Version information\n");
   1.624 +
   1.625 +	return true;
   1.626 +}
   1.627 +
   1.628 +bool Command_ClientMeta(edict_t *client, IMetamodSourceCommandInfo *info)
   1.629 +{
   1.630 +	const char *cmd = info->GetArg(0);
   1.631 +
   1.632 +	if (strcmp(cmd, "meta") == 0)
   1.633 +	{
   1.634 +		unsigned int args = info->GetArgCount();
   1.635 +		if (args == 1)
   1.636 +		{
   1.637 +			const char *subcmd = info->GetArg(1);
   1.638 +
   1.639 +			if (strcmp(subcmd, "credits") == 0)
   1.640 +			{
   1.641 +				CLIENT_CONMSG(client, "Metamod:Source was developed by:\n");
   1.642 +				CLIENT_CONMSG(client, "  SourceHook: Pavol \"PM OnoTo\" Marko\n");
   1.643 +				CLIENT_CONMSG(client, "  GameDLL/Plugins: David \"BAILOPAN\" Anderson\n");
   1.644 +				CLIENT_CONMSG(client, "  GameDLL: Scott \"Damaged Soul\" Ehlert\n");
   1.645 +				CLIENT_CONMSG(client, "For more information, see the official website\n");
   1.646 +				CLIENT_CONMSG(client, "http://www.sourcemm.net/\n");
   1.647 +
   1.648 +				return true;
   1.649 +			}
   1.650 +			else if(strcmp(subcmd, "version") == 0)
   1.651 +			{
   1.652 +				CLIENT_CONMSG(client, "Metamod:Source version %s\n", SOURCEMM_VERSION);
   1.653 +				CLIENT_CONMSG(client, "Compiled on: %s\n", SOURCEMM_DATE);
   1.654 +				CLIENT_CONMSG(client, "Plugin interface version: %d:%d\n", PLAPI_VERSION, PLAPI_MIN_VERSION);
   1.655 +				CLIENT_CONMSG(client, "SourceHook version: %d:%d\n", g_SourceHook.GetIfaceVersion(), g_SourceHook.GetImplVersion());
   1.656 +				CLIENT_CONMSG(client, "http://www.sourcemm.net/\n");
   1.657 +
   1.658 +				return true;
   1.659 +			}
   1.660 +			else if(strcmp(subcmd, "list") == 0)
   1.661 +			{
   1.662 +				CPluginManager::CPlugin *pl;
   1.663 +				ISmmPlugin *plapi;
   1.664 +				const char *plname;
   1.665 +				PluginIter i;
   1.666 +				char buffer[256];
   1.667 +				int len = 0;
   1.668 +				int plnum = 0;
   1.669 +
   1.670 +				for (i = g_PluginMngr._begin(); i != g_PluginMngr._end(); i++, len=0)
   1.671 +				{
   1.672 +					pl = (*i);
   1.673 +					if (pl && pl->m_Status == Pl_Running)
   1.674 +					{
   1.675 +						plapi = pl->m_API;
   1.676 +						if (!plapi || !plapi->QueryRunning(NULL, 0))
   1.677 +						{
   1.678 +							continue;
   1.679 +						}
   1.680 +						plnum++;
   1.681 +
   1.682 +						len += UTIL_Format(buffer, sizeof(buffer), "  [%02d]", plnum);
   1.683 +
   1.684 +						plname = IS_STR_FILLED(plapi->GetName()) ? plapi->GetName() : pl->m_File.c_str();
   1.685 +						len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " %s", plname);
   1.686 +
   1.687 +						if (IS_STR_FILLED(plapi->GetVersion()))
   1.688 +						{
   1.689 +							len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " (%s)", plapi->GetVersion());
   1.690 +						}
   1.691 +						if (IS_STR_FILLED(plapi->GetAuthor()))
   1.692 +						{
   1.693 +							UTIL_Format(&buffer[len], sizeof(buffer)-len, " by %s", plapi->GetAuthor());
   1.694 +						}
   1.695 +
   1.696 +						CLIENT_CONMSG(client, "%s\n", buffer);
   1.697 +					}
   1.698 +				}
   1.699 +
   1.700 +				if (!plnum)
   1.701 +				{
   1.702 +					CLIENT_CONMSG(client, "No active plugins loaded.\n");
   1.703 +				}
   1.704 +
   1.705 +				return true;
   1.706 +			}
   1.707 +		}
   1.708 +
   1.709 +		CLIENT_CONMSG(client, "Metamod:Source Menu\n");
   1.710 +		CLIENT_CONMSG(client, "usage: meta <command>\n");
   1.711 +		CLIENT_CONMSG(client, "  credits - About Metamod:Source\n");
   1.712 +		CLIENT_CONMSG(client, "  list    - List plugins\n");
   1.713 +		CLIENT_CONMSG(client, "  version - Version information\n");
   1.714 +
   1.715 +		return true;
   1.716 +	}
   1.717 +
   1.718 +	return false;
   1.719 +}