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