Parent Directory | Revision Log
Revision 17 - (view) (download)
1 : | ian | 1 | /* AMX Mod X |
2 : | * Admin Help Plugin | ||
3 : | * | ||
4 : | * by the AMX Mod X Development Team | ||
5 : | * originally developed by tcquest78 | ||
6 : | * | ||
7 : | * This file is part of AMX Mod X. | ||
8 : | * | ||
9 : | * | ||
10 : | * This program is free software; you can redistribute it and/or modify it | ||
11 : | * under the terms of the GNU General Public License as published by the | ||
12 : | * Free Software Foundation; either version 2 of the License, or (at | ||
13 : | * your option) any later version. | ||
14 : | * | ||
15 : | * This program is distributed in the hope that it will be useful, but | ||
16 : | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 : | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
18 : | * General Public License for more details. | ||
19 : | * | ||
20 : | * You should have received a copy of the GNU General Public License | ||
21 : | * along with this program; if not, write to the Free Software Foundation, | ||
22 : | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
23 : | * | ||
24 : | * In addition, as a special exception, the author gives permission to | ||
25 : | * link the code of this program with the Half-Life Game Engine ("HL | ||
26 : | * Engine") and Modified Game Libraries ("MODs") developed by Valve, | ||
27 : | * L.L.C ("Valve"). You must obey the GNU General Public License in all | ||
28 : | * respects for all of the code used other than the HL Engine and MODs | ||
29 : | * from Valve. If you modify this file, you may extend this exception | ||
30 : | * to your version of the file, but you are not obligated to do so. If | ||
31 : | * you do not wish to do so, delete this exception statement from your | ||
32 : | * version. | ||
33 : | */ | ||
34 : | |||
35 : | #include <amxmodx> | ||
36 : | |||
37 : | #define DISPLAY_MSG // Comment to disable message on join | ||
38 : | #define HELPAMOUNT 10 // Number of commands per page | ||
39 : | |||
40 : | public plugin_init() | ||
41 : | { | ||
42 : | register_plugin("Admin Help", AMXX_VERSION_STR, "AMXX Dev Team") | ||
43 : | register_dictionary("adminhelp.txt") | ||
44 : | register_concmd("amx_help", "cmdHelp", 0, "<page> [nr of cmds (only for server)] - displays this help") | ||
45 : | } | ||
46 : | |||
47 : | #if defined DISPLAY_MSG | ||
48 : | public client_putinserver(id) | ||
49 : | { | ||
50 : | if (is_user_bot(id)) | ||
51 : | return | ||
52 : | |||
53 : | set_task(15.0, "dispInfo", id) | ||
54 : | } | ||
55 : | |||
56 : | public client_disconnect(id) | ||
57 : | { | ||
58 : | remove_task(id) | ||
59 : | } | ||
60 : | #endif | ||
61 : | |||
62 : | public cmdHelp(id, level, cid) | ||
63 : | { | ||
64 : | new arg1[8], flags = get_user_flags(id) | ||
65 : | new start = read_argv(1, arg1, 7) ? str_to_num(arg1) : 1 | ||
66 : | new lHelpAmount = HELPAMOUNT | ||
67 : | |||
68 : | ian | 17 | // HACK: ADMIN_ADMIN is never set as a user's actual flags, so those types of commands never show |
69 : | if (flags > 0 && !(flags & ADMIN_USER)) | ||
70 : | { | ||
71 : | flags |= ADMIN_ADMIN; | ||
72 : | } | ||
73 : | |||
74 : | ian | 1 | if (id == 0 && read_argc() == 3) |
75 : | lHelpAmount = read_argv(2, arg1, 7) ? str_to_num(arg1) : HELPAMOUNT | ||
76 : | |||
77 : | if (--start < 0) | ||
78 : | start = 0 | ||
79 : | |||
80 : | new clcmdsnum = get_concmdsnum(flags, id) | ||
81 : | |||
82 : | if (start >= clcmdsnum) | ||
83 : | start = clcmdsnum - 1 | ||
84 : | |||
85 : | console_print(id, "^n----- %L -----", id, "HELP_COMS") | ||
86 : | |||
87 : | new info[128], cmd[32], eflags | ||
88 : | new end = start + lHelpAmount // HELPAMOUNT | ||
89 : | |||
90 : | if (end > clcmdsnum) | ||
91 : | end = clcmdsnum | ||
92 : | |||
93 : | for (new i = start; i < end; i++) | ||
94 : | { | ||
95 : | get_concmd(i, cmd, 31, eflags, info, 127, flags, id) | ||
96 : | console_print(id, "%3d: %s %s", i + 1, cmd, info) | ||
97 : | } | ||
98 : | |||
99 : | console_print(id, "----- %L -----", id, "HELP_ENTRIES", start + 1, end, clcmdsnum) | ||
100 : | |||
101 : | if (end < clcmdsnum) | ||
102 : | console_print(id, "----- %L -----", id, "HELP_USE_MORE", end + 1) | ||
103 : | else | ||
104 : | console_print(id, "----- %L -----", id, "HELP_USE_BEGIN") | ||
105 : | |||
106 : | return PLUGIN_HANDLED | ||
107 : | } | ||
108 : | |||
109 : | #if defined DISPLAY_MSG | ||
110 : | public dispInfo(id) | ||
111 : | { | ||
112 : | client_print(id, print_chat, "%L", id, "TYPE_HELP") | ||
113 : | |||
114 : | new nextmap[32] | ||
115 : | get_cvar_string("amx_nextmap", nextmap, 31) | ||
116 : | |||
117 : | if (get_cvar_float("mp_timelimit")) | ||
118 : | { | ||
119 : | new timeleft = get_timeleft() | ||
120 : | |||
121 : | if (timeleft > 0) | ||
122 : | { | ||
123 : | client_print(id, print_chat, "%L", id, "TIME_INFO_1", timeleft / 60, timeleft % 60, nextmap) | ||
124 : | } else { | ||
125 : | client_print(id, print_chat, "%L", id, "TIME_INFO_2", nextmap) | ||
126 : | } | ||
127 : | } | ||
128 : | } | ||
129 : | #endif |
Contact | ViewVC Help |
Powered by ViewVC 1.0.4 |