Added MaxClients public var to replace GetMaxClients (
bug 3283, r=pred).
This is a hard bump of the plugin version number. 1.1 plugins compiled against this include set
will not run against earlier versions of SourceMod.
3 * =============================================================================
4 * SourceMod Admin Help Plugin
5 * Displays and searches SourceMod commands and descriptions.
7 * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
8 * =============================================================================
10 * This program is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License, version 3.0, as published by the
12 * Free Software Foundation.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 * You should have received a copy of the GNU General Public License along with
20 * this program. If not, see <http://www.gnu.org/licenses/>.
22 * As a special exception, AlliedModders LLC gives you permission to link the
23 * code of this program (as well as its derivative works) to "Half-Life 2," the
24 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
25 * by the Valve Corporation. You must obey the GNU General Public License in
26 * all respects for all other code used. Additionally, AlliedModders LLC grants
27 * this exception to all derivative works. AlliedModders LLC defines further
28 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
29 * or <http://www.sourcemod.net/license.php>.
38 #define COMMANDS_PER_PAGE 10
40 public Plugin:myinfo =
43 author = "AlliedModders LLC",
44 description = "Display command information",
45 version = SOURCEMOD_VERSION,
46 url = "http://www.sourcemod.net/"
49 public OnPluginStart()
51 LoadTranslations("common.phrases");
52 LoadTranslations("adminhelp.phrases");
53 RegConsoleCmd("sm_help", HelpCmd, "Displays SourceMod commands and descriptions");
54 RegConsoleCmd("sm_searchcmd", HelpCmd, "Searches SourceMod commands");
57 public Action:HelpCmd(client, args)
59 decl String:arg[64], String:CmdName[20];
63 GetCmdArg(0, CmdName, sizeof(CmdName));
65 if (GetCmdArgs() >= 1)
67 GetCmdArg(1, arg, sizeof(arg));
68 StringToIntEx(arg, PageNum);
69 PageNum = (PageNum <= 0) ? 1 : PageNum;
72 DoSearch = (strcmp("sm_help", CmdName) == 0) ? false : true;
74 if (GetCmdReplySource() == SM_REPLY_TO_CHAT)
76 ReplyToCommand(client, "[SM] %t", "See console for output");
80 decl String:Desc[255];
81 decl String:NoDesc[128];
83 new Handle:CmdIter = GetCommandIterator();
85 FormatEx(NoDesc, sizeof(NoDesc), "%t", "No description available");
90 while (ReadCommandIterator(CmdIter, Name, sizeof(Name), Flags, Desc, sizeof(Desc)))
92 if ((StrContains(Name, arg, false) != -1) && CheckCommandAccess(client, Name, Flags))
94 PrintToConsole(client, "[%03d] %s - %s", i++, Name, (Desc[0] == '\0') ? NoDesc : Desc);
100 PrintToConsole(client, "%t", "No matching results found");
103 PrintToConsole(client, "%t", "SM help commands");
105 /* Skip the first N commands if we need to */
109 new EndCmd = (PageNum-1) * COMMANDS_PER_PAGE - 1;
110 for (i=0; ReadCommandIterator(CmdIter, Name, sizeof(Name), Flags, Desc, sizeof(Desc)) && i<EndCmd; )
112 if (CheckCommandAccess(client, Name, Flags))
120 PrintToConsole(client, "%t", "No commands available");
121 CloseHandle(CmdIter);
122 return Plugin_Handled;
126 /* Start printing the commands to the client */
128 new StartCmd = (PageNum-1) * COMMANDS_PER_PAGE;
129 for (i=0; ReadCommandIterator(CmdIter, Name, sizeof(Name), Flags, Desc, sizeof(Desc)) && i<COMMANDS_PER_PAGE; )
131 if (CheckCommandAccess(client, Name, Flags))
134 PrintToConsole(client, "[%03d] %s - %s", i+StartCmd, Name, (Desc[0] == '\0') ? NoDesc : Desc);
140 PrintToConsole(client, "%t", "No commands available");
142 PrintToConsole(client, "%t", "Entries n - m in page k", StartCmd+1, i+StartCmd, PageNum);
145 /* Test if there are more commands available */
146 if (ReadCommandIterator(CmdIter, Name, sizeof(Name), Flags, Desc, sizeof(Desc)) && CheckCommandAccess(client, Name, Flags))
148 PrintToConsole(client, "%t", "Type sm_help to see more", PageNum+1);
152 CloseHandle(CmdIter);
154 return Plugin_Handled;