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