1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/sourcemm/concommands.cpp Sat Apr 16 19:59:26 2005 +0000
1.3 @@ -0,0 +1,147 @@
1.4 +/* ======== SourceMM ========
1.5 +* Copyright (C) 2004-2005 SourceMM 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 +#include "concommands.h"
1.15 +#include "CPlugin.h"
1.16 +
1.17 +/**
1.18 + * @brief Console Command Implementations
1.19 + * @file concommands.cpp
1.20 + */
1.21 +
1.22 +SMConVarAccessor g_SMConVarAccessor;
1.23 +
1.24 +bool SMConVarAccessor::RegisterConCommandBase(ConCommandBase *pCommand)
1.25 +{
1.26 + pCommand->SetNext( NULL );
1.27 + g_Engine.icvar->RegisterConCommandBase(pCommand);
1.28 +
1.29 + return true;
1.30 +}
1.31 +
1.32 +ConVar metamod_version("metamod_version", SOURCEMM_VERSION, FCVAR_REPLICATED | FCVAR_SPONLY, "Metamod:Source Version");
1.33 +
1.34 +CON_COMMAND(meta, "Metamod:Source Menu")
1.35 +{
1.36 + IVEngineServer *e = g_Engine.engine;
1.37 +
1.38 + int args = e->Cmd_Argc();
1.39 +
1.40 + if (args >= 2)
1.41 + {
1.42 + const char *command = e->Cmd_Argv(1);
1.43 + if (strcmp(command, "credits") == 0)
1.44 + {
1.45 + Msg("Metamod:Source was developed by:\n");
1.46 + Msg(" SourceHook: Pavol \"PM OnoTo\" Marko\n");
1.47 + Msg(" GameDLL/Plugins: David \"BAILOPAN\" Anderson\n");
1.48 + Msg(" GameDLL: Scott \"Damaged Soul\" Ehlert\n");
1.49 + Msg("For more information, see the official website\n");
1.50 + Msg("http://www.sourcemm.net/\n");
1.51 +
1.52 + return;
1.53 + } else if (strcmp(command, "version") == 0) {
1.54 + Msg("Metamod:Source version %s\n", SOURCEMM_VERSION);
1.55 + Msg("Compiled on: %s\n", SOURCEMM_DATE);
1.56 + Msg("Plugin interface version: %d/%d\n", PLAPI_VERSION, PLAPI_MIN_VERSION);
1.57 + Msg("http://www.sourcemm.net/\n");
1.58 +
1.59 + return;
1.60 + } else if (strcmp(command, "game") == 0) {
1.61 + Msg("GameDLL Information\n");
1.62 + Msg(" Mod path: %s\n", g_ModPath.c_str());
1.63 + Msg(" Dll path: %s\n", g_BinPath.c_str());
1.64 +
1.65 + return;
1.66 + } else if (strcmp(command, "refresh") == 0) {
1.67 + char full_path[255];
1.68 +#if defined WIN32 || defined _WIN32
1.69 + snprintf(full_path, sizeof(full_path)-1, "%s\\%s", g_ModPath.c_str(), "metaplugins.ini");
1.70 +#else
1.71 + snprintf(full_path, sizeof(full_path)-1, "%s/%s", g_ModPath.c_str(), "metaplugins.ini");
1.72 +#endif
1.73 + LoadPluginsFromFile(full_path);
1.74 +
1.75 + return;
1.76 + } else if (strcmp(command, "list") == 0) {
1.77 + SourceMM::CPluginManager::CPlugin *pl;
1.78 + PluginIter i;
1.79 + const char *status="";
1.80 +
1.81 + Msg("[Id] %-16.15s %-8.7s %-12.11s %-8.7s\n", "Name", "Version", "Author", "Status");
1.82 + for (i=g_PluginMngr._begin(); i!=g_PluginMngr._end(); i++)
1.83 + {
1.84 + pl = (*i);
1.85 + if (!pl)
1.86 + break;
1.87 + if (pl->m_Status == Pl_Paused)
1.88 + {
1.89 + status = "PAUSE";
1.90 + } else if (pl->m_Status == Pl_Running) {
1.91 + status = "RUN";
1.92 + } else if (pl->m_Status == Pl_Refused) {
1.93 + status = "FAIL";
1.94 + } else if (pl->m_Status == Pl_Error) {
1.95 + status = "ERROR";
1.96 + } else if (pl->m_Status == Pl_NotFound) {
1.97 + status = "NOFILE";
1.98 + }
1.99 + Msg("[%02d] %-16.15s %-8.7s %-12.11s %-8.7s\n", pl->m_Id, pl->m_API->GetName(), pl->m_API->GetVersion(), pl->m_API->GetAuthor(), status);
1.100 + }
1.101 +
1.102 + return;
1.103 + } else if (strcmp(command, "info") == 0) {
1.104 + if (args >= 3)
1.105 + {
1.106 + int id = atoi(e->Cmd_Argv(2));
1.107 + SourceMM::CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
1.108 + if (!pl)
1.109 + {
1.110 + Msg("Plugin %d not found.\n", id);
1.111 + return;
1.112 + }
1.113 +
1.114 + if (!pl->m_API)
1.115 + {
1.116 + Msg("Plugin %d is not loaded.\n", id);
1.117 + } else {
1.118 + if (pl->m_Status == Pl_Paused)
1.119 + {
1.120 + Msg("Plugin %d is paused.\n", id);
1.121 + } else if (pl->m_Status == Pl_Running) {
1.122 + Msg("Plugin %d is running.\n", id);
1.123 + }
1.124 + Msg("Name: \"%s\" by %s\n", pl->m_API->GetName(), pl->m_API->GetAuthor());
1.125 + Msg("Version: %s\n", pl->m_API->GetVersion());
1.126 + Msg("Description: %s\n", pl->m_API->GetDescription());
1.127 + Msg("License: %s\n", pl->m_API->GetLicense());
1.128 + Msg("URL: %s\n", pl->m_API->GetURL());
1.129 + Msg("Details: API %03d, Date: %s\n", pl->m_API->GetApiVersion(), pl->m_API->GetDate());
1.130 + }
1.131 + Msg("File: %s\n", pl->m_File.c_str());
1.132 +
1.133 + return;
1.134 + } else {
1.135 + Msg("Usage: meta info <id>\n");
1.136 +
1.137 + return;
1.138 + }
1.139 + }
1.140 + }
1.141 +
1.142 + Msg("Metamod:Source Menu\n");
1.143 + Msg("usage: meta <command> [arguments]\n");
1.144 + Msg(" credits - About Metamod:Source\n");
1.145 + Msg(" game - Information about GameDLL\n");
1.146 + Msg(" info - Information about a plugin\n");
1.147 + Msg(" list - List plugins\n");
1.148 + Msg(" refresh - Reparse plugins file\n");
1.149 + Msg(" version - Version information\n");
1.150 +}