Parent Directory | Revision Log
Revision 17 - (view) (download)
1 : | ian | 1 | /* AMX Mod X |
2 : | * Teleport Menu Plugin | ||
3 : | * | ||
4 : | * by the AMX Mod X Development Team | ||
5 : | * originally developed by OLO | ||
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 : | #include <amxmisc> | ||
37 : | #include <fun> | ||
38 : | |||
39 : | new g_menuPosition[33] | ||
40 : | new g_menuPlayers[33][32] | ||
41 : | new g_menuPlayersNum[33] | ||
42 : | new g_menuOption[33] = {-1, ...} | ||
43 : | new g_menuOrgin[33][3] | ||
44 : | new g_coloredMenus | ||
45 : | |||
46 : | public plugin_init() | ||
47 : | { | ||
48 : | register_plugin("Teleport Menu", AMXX_VERSION_STR, "AMXX Dev Team") | ||
49 : | register_dictionary("telemenu.txt") | ||
50 : | register_dictionary("common.txt") | ||
51 : | register_clcmd("amx_teleportmenu", "cmdTelMenu", ADMIN_CFG, "- displays teleport menu") | ||
52 : | register_menucmd(register_menuid("Teleport Menu"), 1023, "actionTelMenu") | ||
53 : | |||
54 : | g_coloredMenus = colored_menus() | ||
55 : | } | ||
56 : | |||
57 : | public actionTelMenu(id, key) | ||
58 : | { | ||
59 : | switch (key) | ||
60 : | { | ||
61 : | case 6: | ||
62 : | { | ||
63 : | g_menuOption[id] = 1 - g_menuOption[id] | ||
64 : | displayTelMenu(id, g_menuPosition[id]) | ||
65 : | } | ||
66 : | case 7: | ||
67 : | { | ||
68 : | if (g_menuOption[id] < 0) /* unlocking position for the first time */ | ||
69 : | g_menuOption[id] = 0 | ||
70 : | |||
71 : | get_user_origin(id, g_menuOrgin[id]) | ||
72 : | displayTelMenu(id, g_menuPosition[id]) | ||
73 : | } | ||
74 : | case 8: displayTelMenu(id, ++g_menuPosition[id]) | ||
75 : | case 9: displayTelMenu(id, --g_menuPosition[id]) | ||
76 : | default: | ||
77 : | { | ||
78 : | new player = g_menuPlayers[id][g_menuPosition[id] * 6 + key] | ||
79 : | new name2[32] | ||
80 : | |||
81 : | get_user_name(player, name2, 31) | ||
82 : | |||
83 : | if (!is_user_alive(player)) | ||
84 : | { | ||
85 : | client_print(id, print_chat, "%L", id, "CANT_PERF_DEAD", name2) | ||
86 : | displayTelMenu(id, g_menuPosition[id]) | ||
87 : | return PLUGIN_HANDLED | ||
88 : | } | ||
89 : | |||
90 : | if (g_menuOption[id] > 0) | ||
91 : | { | ||
92 : | set_user_origin(player, g_menuOrgin[id]) | ||
93 : | } else { | ||
94 : | new origin[3] | ||
95 : | |||
96 : | get_user_origin(id, origin) | ||
97 : | set_user_origin(player, origin) | ||
98 : | } | ||
99 : | |||
100 : | new authid[32], authid2[32], name[32] | ||
101 : | |||
102 : | get_user_authid(id, authid, 31) | ||
103 : | get_user_authid(player, authid2, 31) | ||
104 : | get_user_name(id, name, 31) | ||
105 : | |||
106 : | log_amx("Cmd: ^"%s<%d><%s><>^" teleport ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2) | ||
107 : | |||
108 : | ian | 17 | show_activity_key("ADMIN_TELEPORT_1", "ADMIN_TELEPORT_2", name, name2); |
109 : | ian | 1 | |
110 : | displayTelMenu(id, g_menuPosition[id]) | ||
111 : | } | ||
112 : | } | ||
113 : | |||
114 : | return PLUGIN_HANDLED | ||
115 : | } | ||
116 : | |||
117 : | displayTelMenu(id, pos) | ||
118 : | { | ||
119 : | if (pos < 0) | ||
120 : | return | ||
121 : | |||
122 : | get_players(g_menuPlayers[id], g_menuPlayersNum[id]) | ||
123 : | |||
124 : | new menuBody[512] | ||
125 : | new b = 0 | ||
126 : | new i | ||
127 : | new name[32] | ||
128 : | new start = pos * 6 | ||
129 : | new bool:blockMenu = (is_user_alive(id) && g_menuOption[id] < 1) ? true : false | ||
130 : | |||
131 : | if (start >= g_menuPlayersNum[id]) | ||
132 : | start = pos = g_menuPosition[id] = 0 | ||
133 : | |||
134 : | new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "TELE_MENU", pos + 1, (g_menuPlayersNum[id] / 6 + ((g_menuPlayersNum[id] % 6) ? 1 : 0))) | ||
135 : | new end = start + 6 | ||
136 : | new keys = MENU_KEY_0|MENU_KEY_8 | ||
137 : | |||
138 : | if (end > g_menuPlayersNum[id]) | ||
139 : | end = g_menuPlayersNum[id] | ||
140 : | |||
141 : | for (new a = start; a < end; ++a) | ||
142 : | { | ||
143 : | i = g_menuPlayers[id][a] | ||
144 : | get_user_name(i, name, 31) | ||
145 : | |||
146 : | if (blockMenu || !is_user_alive(i) || (id != i && get_user_flags(i) & ADMIN_IMMUNITY)) | ||
147 : | { | ||
148 : | ++b | ||
149 : | |||
150 : | if (g_coloredMenus) | ||
151 : | len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name) | ||
152 : | else | ||
153 : | len += format(menuBody[len], 511-len, "#. %s^n", name) | ||
154 : | } else { | ||
155 : | keys |= (1<<b) | ||
156 : | |||
157 : | if (is_user_admin(i)) | ||
158 : | len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*^n\w" : "%d. %s *^n", ++b, name) | ||
159 : | else | ||
160 : | len += format(menuBody[len], 511-len, "%d. %s^n", ++b, name) | ||
161 : | } | ||
162 : | } | ||
163 : | |||
164 : | if (g_menuOption[id] > 0) // 1 | ||
165 : | { | ||
166 : | keys |= MENU_KEY_7 | ||
167 : | len += format(menuBody[len], 511-len, "^n7. To location: %d %d %d^n", g_menuOrgin[id][0], g_menuOrgin[id][1], g_menuOrgin[id][2]) | ||
168 : | } | ||
169 : | else if (g_menuOption[id]) // -1 | ||
170 : | { | ||
171 : | if (g_coloredMenus) | ||
172 : | len += format(menuBody[len], 511-len, "^n\d7. %L^n\w", id, "CUR_LOC") | ||
173 : | else | ||
174 : | len += format(menuBody[len], 511-len, "^n#. %L^n", id, "CUR_LOC") | ||
175 : | } else { // 0 | ||
176 : | keys |= MENU_KEY_7 | ||
177 : | len += format(menuBody[len], 511-len, "^n7. %L^n", id, "CUR_LOC") | ||
178 : | } | ||
179 : | |||
180 : | len += format(menuBody[len], 511-len, "8. %L^n", id, "SAVE_LOC") | ||
181 : | |||
182 : | if (end != g_menuPlayersNum[id]) | ||
183 : | { | ||
184 : | format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT") | ||
185 : | keys |= MENU_KEY_9 | ||
186 : | } | ||
187 : | else | ||
188 : | format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT") | ||
189 : | |||
190 : | show_menu(id, keys, menuBody, -1, "Teleport Menu") | ||
191 : | } | ||
192 : | |||
193 : | public cmdTelMenu(id, level, cid) | ||
194 : | { | ||
195 : | if (cmd_access(id, level, cid, 1)) | ||
196 : | displayTelMenu(id, g_menuPosition[id] = 0) | ||
197 : | |||
198 : | return PLUGIN_HANDLED | ||
199 : | } |
Contact | ViewVC Help |
Powered by ViewVC 1.0.4 |