[Half-Life AMXX] / telemenu.sma Repository:
ViewVC logotype

Annotation of /telemenu.sma

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (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 :     switch (get_cvar_num("amx_show_activity"))
109 :     {
110 :     case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_TELEPORT_2", name, name2)
111 :     case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_TELEPORT_1", name2)
112 :     }
113 :    
114 :     displayTelMenu(id, g_menuPosition[id])
115 :     }
116 :     }
117 :    
118 :     return PLUGIN_HANDLED
119 :     }
120 :    
121 :     displayTelMenu(id, pos)
122 :     {
123 :     if (pos < 0)
124 :     return
125 :    
126 :     get_players(g_menuPlayers[id], g_menuPlayersNum[id])
127 :    
128 :     new menuBody[512]
129 :     new b = 0
130 :     new i
131 :     new name[32]
132 :     new start = pos * 6
133 :     new bool:blockMenu = (is_user_alive(id) && g_menuOption[id] < 1) ? true : false
134 :    
135 :     if (start >= g_menuPlayersNum[id])
136 :     start = pos = g_menuPosition[id] = 0
137 :    
138 :     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)))
139 :     new end = start + 6
140 :     new keys = MENU_KEY_0|MENU_KEY_8
141 :    
142 :     if (end > g_menuPlayersNum[id])
143 :     end = g_menuPlayersNum[id]
144 :    
145 :     for (new a = start; a < end; ++a)
146 :     {
147 :     i = g_menuPlayers[id][a]
148 :     get_user_name(i, name, 31)
149 :    
150 :     if (blockMenu || !is_user_alive(i) || (id != i && get_user_flags(i) & ADMIN_IMMUNITY))
151 :     {
152 :     ++b
153 :    
154 :     if (g_coloredMenus)
155 :     len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name)
156 :     else
157 :     len += format(menuBody[len], 511-len, "#. %s^n", name)
158 :     } else {
159 :     keys |= (1<<b)
160 :    
161 :     if (is_user_admin(i))
162 :     len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*^n\w" : "%d. %s *^n", ++b, name)
163 :     else
164 :     len += format(menuBody[len], 511-len, "%d. %s^n", ++b, name)
165 :     }
166 :     }
167 :    
168 :     if (g_menuOption[id] > 0) // 1
169 :     {
170 :     keys |= MENU_KEY_7
171 :     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])
172 :     }
173 :     else if (g_menuOption[id]) // -1
174 :     {
175 :     if (g_coloredMenus)
176 :     len += format(menuBody[len], 511-len, "^n\d7. %L^n\w", id, "CUR_LOC")
177 :     else
178 :     len += format(menuBody[len], 511-len, "^n#. %L^n", id, "CUR_LOC")
179 :     } else { // 0
180 :     keys |= MENU_KEY_7
181 :     len += format(menuBody[len], 511-len, "^n7. %L^n", id, "CUR_LOC")
182 :     }
183 :    
184 :     len += format(menuBody[len], 511-len, "8. %L^n", id, "SAVE_LOC")
185 :    
186 :     if (end != g_menuPlayersNum[id])
187 :     {
188 :     format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
189 :     keys |= MENU_KEY_9
190 :     }
191 :     else
192 :     format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
193 :    
194 :     show_menu(id, keys, menuBody, -1, "Teleport Menu")
195 :     }
196 :    
197 :     public cmdTelMenu(id, level, cid)
198 :     {
199 :     if (cmd_access(id, level, cid, 1))
200 :     displayTelMenu(id, g_menuPosition[id] = 0)
201 :    
202 :     return PLUGIN_HANDLED
203 :     }

Contact
ViewVC Help
Powered by ViewVC 1.0.4