|
ds@1952
|
1 |
|
|
ds@1952
|
2 |
#define NAME_LENGTH 32 |
|
ds@1952
|
3 |
#define CMD_LENGTH 255 |
|
ds@1952
|
4 |
|
|
ds@1952
|
5 |
#define ARRAY_STRING_LENGTH 32 |
|
ds@1952
|
6 |
|
|
ds@1952
|
7 |
enum GroupCommands |
|
ds@1952
|
8 |
{ |
|
ds@1952
|
9 |
Handle:groupListName, |
|
ds@1952
|
10 |
Handle:groupListCommand |
|
ds@1952
|
11 |
}; |
|
ds@1952
|
12 |
|
|
ds@1952
|
13 |
new g_groupList[GroupCommands]; |
|
ds@1952
|
14 |
new g_groupCount; |
|
ds@1952
|
15 |
|
|
ds@1952
|
16 |
new Handle:g_configParser = INVALID_HANDLE; |
|
ds@1952
|
17 |
|
|
ds@1952
|
18 |
enum Places |
|
ds@1952
|
19 |
{ |
|
ds@1952
|
20 |
Place_Category, |
|
ds@1952
|
21 |
Place_Item, |
|
ds@1952
|
22 |
Place_ReplaceNum |
|
ds@1952
|
23 |
}; |
|
ds@1952
|
24 |
|
|
ds@1952
|
25 |
new String:g_command[MAXPLAYERS+1][CMD_LENGTH]; |
|
ds@1952
|
26 |
new g_currentPlace[MAXPLAYERS+1][Places]; |
|
ds@1952
|
27 |
|
|
ds@1952
|
28 |
/** |
|
ds@1952
|
29 |
* What to put in the 'info' menu field (for PlayerList and Player_Team menus only) |
|
ds@1952
|
30 |
*/ |
|
ds@1952
|
31 |
enum PlayerMethod |
|
ds@1952
|
32 |
{ |
|
ds@1952
|
33 |
ClientId, /** Client id number ( 1 - Maxplayers) */ |
|
ds@1952
|
34 |
UserId, /** Client userid */ |
|
ds@1952
|
35 |
Name, /** Client Name */ |
|
ds@1952
|
36 |
SteamId, /** Client Steamid */ |
|
ds@1952
|
37 |
IpAddress, /** Client's Ip Address */ |
|
ds@1952
|
38 |
UserId2 /** Userid (not prefixed with #) */ |
|
ds@1952
|
39 |
}; |
|
ds@1952
|
40 |
|
|
pred@1953
|
41 |
enum ExecuteType |
|
pred@1953
|
42 |
{ |
|
pred@1953
|
43 |
Execute_Player, |
|
pred@1953
|
44 |
Execute_Server |
|
pred@1953
|
45 |
} |
|
pred@1953
|
46 |
|
|
pred@1953
|
47 |
enum SubMenu_Type |
|
pred@1953
|
48 |
{ |
|
pred@1953
|
49 |
SubMenu_Group, |
|
pred@1953
|
50 |
SubMenu_GroupPlayer, |
|
pred@1953
|
51 |
SubMenu_Player, |
|
pred@1953
|
52 |
SubMenu_MapCycle, |
|
pred@1953
|
53 |
SubMenu_List, |
|
pred@1953
|
54 |
SubMenu_OnOff |
|
pred@1953
|
55 |
} |
|
pred@1953
|
56 |
|
|
pred@1953
|
57 |
enum Item |
|
pred@1953
|
58 |
{ |
|
pred@1953
|
59 |
String:Item_cmd[256], |
|
pred@1953
|
60 |
ExecuteType:Item_execute, |
|
pred@1953
|
61 |
Handle:Item_submenus |
|
pred@1953
|
62 |
} |
|
pred@1953
|
63 |
|
|
pred@1953
|
64 |
enum Submenu |
|
pred@1953
|
65 |
{ |
|
pred@1953
|
66 |
SubMenu_Type:Submenu_type, |
|
pred@1953
|
67 |
String:Submenu_title[32], |
|
pred@1953
|
68 |
PlayerMethod:Submenu_method, |
|
pred@1953
|
69 |
Submenu_listcount, |
|
pred@1953
|
70 |
Handle:Submenu_listdata |
|
pred@1953
|
71 |
} |
|
pred@1953
|
72 |
|
|
pred@1953
|
73 |
new Handle:g_DataArray; |
|
pred@1953
|
74 |
|
|
ds@1952
|
75 |
BuildDynamicMenu() |
|
ds@1952
|
76 |
{ |
|
pred@1953
|
77 |
new itemInput[Item]; |
|
pred@1953
|
78 |
g_DataArray = CreateArray(sizeof(itemInput)); |
|
ds@1952
|
79 |
|
|
pred@1953
|
80 |
new String:executeBuffer[32]; |
|
pred@1953
|
81 |
|
|
pred@1953
|
82 |
new Handle:kvMenu; |
|
pred@1953
|
83 |
kvMenu = CreateKeyValues("Commands"); |
|
ds@1952
|
84 |
new String:file[256]; |
|
ds@1952
|
85 |
BuildPath(Path_SM, file, 255, "configs/dynamicmenu/menu.ini"); |
|
pred@1953
|
86 |
FileToKeyValues(kvMenu, file); |
|
ds@1952
|
87 |
|
|
ds@1952
|
88 |
new String:name[NAME_LENGTH]; |
|
ds@1952
|
89 |
new String:buffer[NAME_LENGTH]; |
|
ds@1952
|
90 |
|
|
pred@1953
|
91 |
KvSetEscapeSequences(kvMenu, true); |
|
pred@1953
|
92 |
|
|
pred@1953
|
93 |
if (!KvGotoFirstSubKey(kvMenu)) |
|
ds@1952
|
94 |
{ |
|
ds@1952
|
95 |
return; |
|
ds@1952
|
96 |
} |
|
ds@1952
|
97 |
|
|
ds@1952
|
98 |
decl String:admin[30]; |
|
ds@1952
|
99 |
|
|
ds@1952
|
100 |
new TopMenuObject:categoryId; |
|
ds@1952
|
101 |
|
|
ds@1952
|
102 |
do |
|
ds@1952
|
103 |
{ |
|
pred@1953
|
104 |
KvGetSectionName(kvMenu, buffer, sizeof(buffer)); |
|
ds@1952
|
105 |
|
|
pred@1953
|
106 |
KvGetString(kvMenu, "admin", admin, sizeof(admin),"sm_admin"); |
|
ds@1952
|
107 |
|
|
ds@1952
|
108 |
if ((categoryId =FindTopMenuCategory(hAdminMenu, buffer)) == INVALID_TOPMENUOBJECT) |
|
ds@1952
|
109 |
{ |
|
ds@1952
|
110 |
categoryId = AddToTopMenu(hAdminMenu, |
|
ds@1952
|
111 |
buffer, |
|
ds@1952
|
112 |
TopMenuObject_Category, |
|
ds@1952
|
113 |
DynamicMenuCategoryHandler, |
|
ds@1952
|
114 |
INVALID_TOPMENUOBJECT, |
|
ds@1952
|
115 |
admin, |
|
ds@1952
|
116 |
ADMFLAG_GENERIC, |
|
ds@1952
|
117 |
name); |
|
ds@1952
|
118 |
|
|
ds@1952
|
119 |
} |
|
ds@1952
|
120 |
|
|
pred@1953
|
121 |
if (!KvGotoFirstSubKey(kvMenu)) |
|
ds@1952
|
122 |
{ |
|
ds@1952
|
123 |
return; |
|
ds@1952
|
124 |
} |
|
ds@1952
|
125 |
|
|
ds@1952
|
126 |
do |
|
ds@1952
|
127 |
{ |
|
pred@1953
|
128 |
KvGetSectionName(kvMenu, buffer, sizeof(buffer)); |
|
pred@1953
|
129 |
|
|
pred@1953
|
130 |
KvGetString(kvMenu, "admin", admin, sizeof(admin),""); |
|
ds@1952
|
131 |
|
|
ds@1952
|
132 |
if (admin[0] == '\0') |
|
ds@1952
|
133 |
{ |
|
ds@1952
|
134 |
//No 'admin' keyvalue was found |
|
ds@1952
|
135 |
//Use the first argument of the 'cmd' string instead |
|
ds@1952
|
136 |
|
|
ds@1952
|
137 |
decl String:temp[64]; |
|
pred@1953
|
138 |
KvGetString(kvMenu, "cmd", temp, sizeof(temp),""); |
|
ds@1952
|
139 |
|
|
ds@1952
|
140 |
BreakString(temp, admin, sizeof(admin)); |
|
ds@1952
|
141 |
} |
|
pred@1953
|
142 |
|
|
pred@1953
|
143 |
|
|
pred@1953
|
144 |
KvGetString(kvMenu, "cmd", itemInput[Item_cmd], sizeof(itemInput[Item_cmd])); |
|
pred@1953
|
145 |
KvGetString(kvMenu, "execute", executeBuffer, sizeof(executeBuffer)); |
|
pred@1953
|
146 |
|
|
pred@1953
|
147 |
if (StrEqual(executeBuffer, "server")) |
|
ds@1952
|
148 |
{ |
|
pred@1953
|
149 |
itemInput[Item_execute] = Execute_Server; |
|
pred@1953
|
150 |
} |
|
pred@1953
|
151 |
else //assume player type execute |
|
pred@1953
|
152 |
{ |
|
pred@1953
|
153 |
itemInput[Item_execute] = Execute_Player; |
|
ds@1952
|
154 |
} |
|
pred@1953
|
155 |
|
|
pred@1953
|
156 |
/* iterate all submenus and load data into itemInput[Item_submenus] (adt array handle) */ |
|
pred@1953
|
157 |
|
|
pred@1953
|
158 |
new count = 1; |
|
pred@1953
|
159 |
decl String:countBuffer[10] = "1"; |
|
pred@1953
|
160 |
|
|
pred@1953
|
161 |
decl String:inputBuffer[32]; |
|
pred@1953
|
162 |
|
|
pred@1953
|
163 |
while (KvJumpToKey(kvMenu, countBuffer)) |
|
pred@1953
|
164 |
{ |
|
pred@1953
|
165 |
new submenuInput[Submenu]; |
|
pred@1953
|
166 |
|
|
pred@1953
|
167 |
if (count == 1) |
|
pred@1953
|
168 |
{ |
|
pred@1953
|
169 |
itemInput[Item_submenus] = CreateArray(sizeof(submenuInput)); |
|
pred@1953
|
170 |
} |
|
pred@1953
|
171 |
|
|
pred@1953
|
172 |
KvGetString(kvMenu, "type", inputBuffer, sizeof(inputBuffer)); |
|
pred@1953
|
173 |
|
|
pred@1953
|
174 |
if (strncmp(inputBuffer,"group",5)==0) |
|
pred@1953
|
175 |
{ |
|
pred@1953
|
176 |
if (StrContains(inputBuffer, "player") != -1) |
|
pred@1953
|
177 |
{ |
|
pred@1953
|
178 |
submenuInput[Submenu_type] = SubMenu_GroupPlayer; |
|
pred@1953
|
179 |
} |
|
pred@1953
|
180 |
else |
|
pred@1953
|
181 |
{ |
|
pred@1953
|
182 |
submenuInput[Submenu_type] = SubMenu_Group; |
|
pred@1953
|
183 |
} |
|
pred@1953
|
184 |
} |
|
pred@1953
|
185 |
else if (StrEqual(inputBuffer,"mapcycle")) |
|
pred@1953
|
186 |
{ |
|
pred@1953
|
187 |
submenuInput[Submenu_type] = SubMenu_MapCycle; |
|
pred@1953
|
188 |
|
|
pred@1953
|
189 |
KvGetString(kvMenu, "path", inputBuffer, sizeof(inputBuffer),"mapcycle.txt"); |
|
pred@1953
|
190 |
|
|
pred@1953
|
191 |
submenuInput[Submenu_listdata] = CreateDataPack(); |
|
pred@1953
|
192 |
WritePackString(submenuInput[Submenu_listdata], inputBuffer); |
|
pred@1953
|
193 |
ResetPack(submenuInput[Submenu_listdata]); |
|
pred@1953
|
194 |
} |
|
pred@1953
|
195 |
else if (StrContains(inputBuffer, "player") != -1) |
|
pred@1953
|
196 |
{ |
|
pred@1953
|
197 |
submenuInput[Submenu_type] = SubMenu_Player; |
|
pred@1953
|
198 |
} |
|
pred@1953
|
199 |
else if (StrEqual(inputBuffer,"onoff")) |
|
pred@1953
|
200 |
{ |
|
pred@1953
|
201 |
submenuInput[Submenu_type] = SubMenu_OnOff; |
|
pred@1953
|
202 |
} |
|
pred@1953
|
203 |
else //assume 'list' type |
|
pred@1953
|
204 |
{ |
|
pred@1953
|
205 |
submenuInput[Submenu_type] = SubMenu_List; |
|
pred@1953
|
206 |
|
|
pred@1953
|
207 |
submenuInput[Submenu_listdata] = CreateDataPack(); |
|
pred@1953
|
208 |
|
|
pred@1953
|
209 |
new String:temp[6]; |
|
pred@1953
|
210 |
new String:value[64]; |
|
pred@1953
|
211 |
new String:text[64]; |
|
pred@1953
|
212 |
new i=1; |
|
pred@1953
|
213 |
new bool:more = true; |
|
pred@1953
|
214 |
|
|
pred@1953
|
215 |
new listcount = 0; |
|
pred@1953
|
216 |
|
|
pred@1953
|
217 |
do |
|
pred@1953
|
218 |
{ |
|
pred@1953
|
219 |
Format(temp,3,"%i",i); |
|
pred@1953
|
220 |
KvGetString(kvMenu, temp, value, sizeof(value), ""); |
|
pred@1953
|
221 |
|
|
pred@1953
|
222 |
Format(temp,5,"%i.",i); |
|
pred@1953
|
223 |
KvGetString(kvMenu, temp, text, sizeof(text), value); |
|
pred@1953
|
224 |
|
|
pred@1953
|
225 |
Format(temp,5,"%i*",i); |
|
pred@1953
|
226 |
KvGetString(kvMenu, temp, admin, sizeof(admin),""); |
|
pred@1953
|
227 |
|
|
pred@1953
|
228 |
if (value[0]=='\0') |
|
pred@1953
|
229 |
{ |
|
pred@1953
|
230 |
more = false; |
|
pred@1953
|
231 |
} |
|
pred@1953
|
232 |
else |
|
pred@1953
|
233 |
{ |
|
pred@1953
|
234 |
listcount++; |
|
pred@1953
|
235 |
WritePackString(submenuInput[Submenu_listdata], value); |
|
pred@1953
|
236 |
WritePackString(submenuInput[Submenu_listdata], text); |
|
pred@1953
|
237 |
WritePackString(submenuInput[Submenu_listdata], admin); |
|
pred@1953
|
238 |
} |
|
pred@1953
|
239 |
|
|
pred@1953
|
240 |
i++; |
|
pred@1953
|
241 |
|
|
pred@1953
|
242 |
} while (more); |
|
pred@1953
|
243 |
|
|
pred@1953
|
244 |
ResetPack(submenuInput[Submenu_listdata]); |
|
pred@1953
|
245 |
submenuInput[Submenu_listcount] = listcount; |
|
pred@1953
|
246 |
} |
|
pred@1953
|
247 |
|
|
pred@1953
|
248 |
if ((submenuInput[Submenu_type] == SubMenu_Player) || (submenuInput[Submenu_type] == SubMenu_GroupPlayer)) |
|
pred@1953
|
249 |
{ |
|
pred@1953
|
250 |
KvGetString(kvMenu, "method", inputBuffer, sizeof(inputBuffer)); |
|
pred@1953
|
251 |
|
|
pred@1953
|
252 |
if (StrEqual(inputBuffer, "clientid")) |
|
pred@1953
|
253 |
{ |
|
pred@1953
|
254 |
submenuInput[Submenu_method] = ClientId; |
|
pred@1953
|
255 |
} |
|
pred@1953
|
256 |
else if (StrEqual(inputBuffer, "steamid")) |
|
pred@1953
|
257 |
{ |
|
pred@1953
|
258 |
submenuInput[Submenu_method] = SteamId; |
|
pred@1953
|
259 |
} |
|
pred@1953
|
260 |
else if (StrEqual(inputBuffer, "userid2")) |
|
pred@1953
|
261 |
{ |
|
pred@1953
|
262 |
submenuInput[Submenu_method] = UserId2; |
|
pred@1953
|
263 |
} |
|
pred@1953
|
264 |
else if (StrEqual(inputBuffer, "userid")) |
|
pred@1953
|
265 |
{ |
|
pred@1953
|
266 |
submenuInput[Submenu_method] = UserId; |
|
pred@1953
|
267 |
} |
|
pred@1953
|
268 |
else if (StrEqual(inputBuffer, "ip")) |
|
pred@1953
|
269 |
{ |
|
pred@1953
|
270 |
submenuInput[Submenu_method] = IpAddress; |
|
pred@1953
|
271 |
} |
|
pred@1953
|
272 |
else |
|
pred@1953
|
273 |
{ |
|
pred@1953
|
274 |
submenuInput[Submenu_method] = Name; |
|
pred@1953
|
275 |
} |
|
pred@1953
|
276 |
|
|
pred@1953
|
277 |
} |
|
pred@1953
|
278 |
|
|
pred@1953
|
279 |
KvGetString(kvMenu, "title", inputBuffer, sizeof(inputBuffer)); |
|
pred@1953
|
280 |
strcopy(submenuInput[Submenu_title], sizeof(submenuInput[Submenu_title]), inputBuffer); |
|
pred@1953
|
281 |
|
|
pred@1953
|
282 |
count++; |
|
pred@1953
|
283 |
Format(countBuffer, sizeof(countBuffer), "%i", count); |
|
pred@1953
|
284 |
|
|
pred@1953
|
285 |
PushArrayArray(itemInput[Item_submenus], submenuInput[0]); |
|
pred@1953
|
286 |
|
|
pred@1953
|
287 |
KvGoBack(kvMenu); |
|
pred@1953
|
288 |
} |
|
pred@1953
|
289 |
|
|
pred@1953
|
290 |
/* Save this entire item into the global items array and add it to the menu */ |
|
pred@1953
|
291 |
|
|
pred@1953
|
292 |
new location = PushArrayArray(g_DataArray, itemInput[0]); |
|
ds@1952
|
293 |
|
|
pred@1953
|
294 |
decl String:locString[10]; |
|
pred@1953
|
295 |
IntToString(location, locString, sizeof(locString)); |
|
pred@1953
|
296 |
|
|
ds@1952
|
297 |
AddToTopMenu(hAdminMenu, |
|
ds@1952
|
298 |
buffer, |
|
ds@1952
|
299 |
TopMenuObject_Item, |
|
ds@1952
|
300 |
DynamicMenuItemHandler, |
|
ds@1952
|
301 |
categoryId, |
|
ds@1952
|
302 |
admin, |
|
ds@1952
|
303 |
ADMFLAG_GENERIC, |
|
pred@1953
|
304 |
locString); |
|
ds@1952
|
305 |
|
|
pred@1953
|
306 |
} while (KvGotoNextKey(kvMenu)); |
|
ds@1952
|
307 |
|
|
pred@1953
|
308 |
KvGoBack(kvMenu); |
|
ds@1952
|
309 |
|
|
pred@1953
|
310 |
} while (KvGotoNextKey(kvMenu)); |
|
ds@1952
|
311 |
|
|
pred@1953
|
312 |
CloseHandle(kvMenu); |
|
ds@1952
|
313 |
} |
|
ds@1952
|
314 |
|
|
ds@1952
|
315 |
ParseConfigs() |
|
ds@1952
|
316 |
{ |
|
ds@1952
|
317 |
if (g_configParser == INVALID_HANDLE) |
|
ds@1952
|
318 |
{ |
|
ds@1952
|
319 |
g_configParser = SMC_CreateParser(); |
|
ds@1952
|
320 |
} |
|
ds@1952
|
321 |
|
|
ds@1952
|
322 |
SMC_SetReaders(g_configParser, NewSection, KeyValue, EndSection); |
|
ds@1952
|
323 |
|
|
ds@1952
|
324 |
if (g_groupList[groupListName] != INVALID_HANDLE) |
|
ds@1952
|
325 |
{ |
|
ds@1952
|
326 |
CloseHandle(g_groupList[groupListName]); |
|
ds@1952
|
327 |
} |
|
ds@1952
|
328 |
|
|
ds@1952
|
329 |
if (g_groupList[groupListCommand] != INVALID_HANDLE) |
|
ds@1952
|
330 |
{ |
|
ds@1952
|
331 |
CloseHandle(g_groupList[groupListCommand]); |
|
ds@1952
|
332 |
} |
|
ds@1952
|
333 |
|
|
ds@1952
|
334 |
g_groupList[groupListName] = CreateArray(ARRAY_STRING_LENGTH); |
|
ds@1952
|
335 |
g_groupList[groupListCommand] = CreateArray(ARRAY_STRING_LENGTH); |
|
ds@1952
|
336 |
|
|
ds@1952
|
337 |
decl String:configPath[256]; |
|
ds@1952
|
338 |
BuildPath(Path_SM, configPath, sizeof(configPath), "configs/dynamicmenu/adminmenu_grouping.txt"); |
|
ds@1952
|
339 |
|
|
ds@1952
|
340 |
if (!FileExists(configPath)) |
|
ds@1952
|
341 |
{ |
|
ds@1952
|
342 |
LogError("Unable to locate admin menu groups file, no groups loaded."); |
|
ds@1952
|
343 |
|
|
ds@1952
|
344 |
return; |
|
ds@1952
|
345 |
} |
|
ds@1952
|
346 |
|
|
ds@1952
|
347 |
new line; |
|
ds@1952
|
348 |
new SMCError:err = SMC_ParseFile(g_configParser, configPath, line); |
|
ds@1952
|
349 |
if (err != SMCError_Okay) |
|
ds@1952
|
350 |
{ |
|
ds@1952
|
351 |
decl String:error[256]; |
|
ds@1952
|
352 |
SMC_GetErrorString(err, error, sizeof(error)); |
|
ds@1952
|
353 |
LogError("Could not parse file (line %d, file \"%s\"):", line, configPath); |
|
ds@1952
|
354 |
LogError("Parser encountered error: %s", error); |
|
ds@1952
|
355 |
} |
|
ds@1952
|
356 |
|
|
ds@1952
|
357 |
return; |
|
ds@1952
|
358 |
} |
|
ds@1952
|
359 |
|
|
ds@1952
|
360 |
public SMCResult:NewSection(Handle:smc, const String:name[], bool:opt_quotes) |
|
ds@1952
|
361 |
{ |
|
ds@1952
|
362 |
|
|
ds@1952
|
363 |
} |
|
ds@1952
|
364 |
|
|
ds@1952
|
365 |
public SMCResult:KeyValue(Handle:smc, const String:key[], const String:value[], bool:key_quotes, bool:value_quotes) |
|
ds@1952
|
366 |
{ |
|
ds@1952
|
367 |
PushArrayString(g_groupList[groupListName], key); |
|
ds@1952
|
368 |
PushArrayString(g_groupList[groupListCommand], value); |
|
ds@1952
|
369 |
} |
|
ds@1952
|
370 |
|
|
ds@1952
|
371 |
public SMCResult:EndSection(Handle:smc) |
|
ds@1952
|
372 |
{ |
|
ds@1952
|
373 |
g_groupCount = GetArraySize(g_groupList[groupListName]); |
|
ds@1952
|
374 |
} |
|
ds@1952
|
375 |
|
|
ds@1952
|
376 |
public DynamicMenuCategoryHandler(Handle:topmenu, |
|
ds@1952
|
377 |
TopMenuAction:action, |
|
ds@1952
|
378 |
TopMenuObject:object_id, |
|
ds@1952
|
379 |
param, |
|
ds@1952
|
380 |
String:buffer[], |
|
ds@1952
|
381 |
maxlength) |
|
ds@1952
|
382 |
{ |
|
ds@1952
|
383 |
if ((action == TopMenuAction_DisplayTitle) || (action == TopMenuAction_DisplayOption)) |
|
ds@1952
|
384 |
{ |
|
ds@1952
|
385 |
GetTopMenuObjName(topmenu, object_id, buffer, maxlength); |
|
ds@1952
|
386 |
} |
|
ds@1952
|
387 |
} |
|
ds@1952
|
388 |
|
|
ds@1952
|
389 |
public DynamicMenuItemHandler(Handle:topmenu, |
|
ds@1952
|
390 |
TopMenuAction:action, |
|
ds@1952
|
391 |
TopMenuObject:object_id, |
|
ds@1952
|
392 |
param, |
|
ds@1952
|
393 |
String:buffer[], |
|
ds@1952
|
394 |
maxlength) |
|
ds@1952
|
395 |
{ |
|
ds@1952
|
396 |
if (action == TopMenuAction_DisplayOption) |
|
ds@1952
|
397 |
{ |
|
ds@1952
|
398 |
GetTopMenuObjName(topmenu, object_id, buffer, maxlength); |
|
ds@1952
|
399 |
} |
|
ds@1952
|
400 |
else if (action == TopMenuAction_SelectOption) |
|
ds@1952
|
401 |
{ |
|
pred@1953
|
402 |
new String:locString[10]; |
|
pred@1953
|
403 |
GetTopMenuInfoString(topmenu, object_id, locString, sizeof(locString)); |
|
ds@1952
|
404 |
|
|
pred@1953
|
405 |
new location = StringToInt(locString); |
|
ds@1952
|
406 |
|
|
pred@1953
|
407 |
new output[Item]; |
|
pred@1953
|
408 |
GetArrayArray(g_DataArray, location, output[0]); |
|
ds@1952
|
409 |
|
|
pred@1953
|
410 |
strcopy(g_command[param], sizeof(g_command[]), output[Item_cmd]); |
|
ds@1952
|
411 |
|
|
pred@1953
|
412 |
g_currentPlace[param][Place_Item] = location; |
|
ds@1952
|
413 |
|
|
ds@1952
|
414 |
ParamCheck(param); |
|
ds@1952
|
415 |
} |
|
ds@1952
|
416 |
} |
|
ds@1952
|
417 |
|
|
ds@1952
|
418 |
public ParamCheck(client) |
|
ds@1952
|
419 |
{ |
|
ds@1952
|
420 |
new String:buffer[6]; |
|
ds@1952
|
421 |
new String:buffer2[6]; |
|
ds@1952
|
422 |
|
|
pred@1953
|
423 |
new outputItem[Item]; |
|
pred@1953
|
424 |
new outputSubmenu[Submenu]; |
|
pred@1953
|
425 |
|
|
pred@1953
|
426 |
GetArrayArray(g_DataArray, g_currentPlace[client][Place_Item], outputItem[0]); |
|
ds@1952
|
427 |
|
|
ds@1952
|
428 |
if (g_currentPlace[client][Place_ReplaceNum] < 1) |
|
ds@1952
|
429 |
{ |
|
ds@1952
|
430 |
g_currentPlace[client][Place_ReplaceNum] = 1; |
|
ds@1952
|
431 |
} |
|
ds@1952
|
432 |
|
|
ds@1952
|
433 |
Format(buffer, 5, "#%i", g_currentPlace[client][Place_ReplaceNum]); |
|
ds@1952
|
434 |
Format(buffer2, 5, "@%i", g_currentPlace[client][Place_ReplaceNum]); |
|
ds@1952
|
435 |
|
|
ds@1952
|
436 |
if (StrContains(g_command[client], buffer) != -1 || StrContains(g_command[client], buffer2) != -1) |
|
ds@1952
|
437 |
{ |
|
pred@1953
|
438 |
GetArrayArray(outputItem[Item_submenus], g_currentPlace[client][Place_ReplaceNum] - 1, outputSubmenu[0]); |
|
ds@1952
|
439 |
|
|
ds@1952
|
440 |
new Handle:itemMenu = CreateMenu(Menu_Selection); |
|
ds@1952
|
441 |
|
|
pred@1953
|
442 |
if ((outputSubmenu[Submenu_type] == SubMenu_Group) || (outputSubmenu[Submenu_type] == SubMenu_GroupPlayer)) |
|
ds@1952
|
443 |
{ |
|
ds@1952
|
444 |
decl String:nameBuffer[ARRAY_STRING_LENGTH]; |
|
ds@1952
|
445 |
decl String:commandBuffer[ARRAY_STRING_LENGTH]; |
|
ds@1952
|
446 |
|
|
ds@1952
|
447 |
for (new i = 0; i<g_groupCount; i++) |
|
ds@1952
|
448 |
{ |
|
ds@1952
|
449 |
GetArrayString(g_groupList[groupListName], i, nameBuffer, sizeof(nameBuffer)); |
|
ds@1952
|
450 |
GetArrayString(g_groupList[groupListCommand], i, commandBuffer, sizeof(commandBuffer)); |
|
ds@1952
|
451 |
AddMenuItem(itemMenu, commandBuffer, nameBuffer); |
|
ds@1952
|
452 |
} |
|
ds@1952
|
453 |
} |
|
ds@1952
|
454 |
|
|
pred@1953
|
455 |
if (outputSubmenu[Submenu_type] == SubMenu_MapCycle) |
|
pred@1953
|
456 |
{ |
|
ds@1952
|
457 |
decl String:path[200]; |
|
pred@1953
|
458 |
ReadPackString(outputSubmenu[Submenu_listdata], path, sizeof(path)); |
|
pred@1953
|
459 |
ResetPack(outputSubmenu[Submenu_listdata]); |
|
ds@1952
|
460 |
|
|
ds@1952
|
461 |
new Handle:file = OpenFile(path, "rt"); |
|
ds@1952
|
462 |
new String:readData[128]; |
|
ds@1952
|
463 |
|
|
ds@1952
|
464 |
if(file != INVALID_HANDLE) |
|
ds@1952
|
465 |
{ |
|
ds@1952
|
466 |
while(!IsEndOfFile(file) && ReadFileLine(file, readData, sizeof(readData))) |
|
ds@1952
|
467 |
{ |
|
ds@1952
|
468 |
TrimString(readData); |
|
ds@1952
|
469 |
|
|
ds@1952
|
470 |
if (IsMapValid(readData)) |
|
ds@1952
|
471 |
{ |
|
ds@1952
|
472 |
AddMenuItem(itemMenu, readData, readData); |
|
ds@1952
|
473 |
} |
|
ds@1952
|
474 |
} |
|
ds@1952
|
475 |
} |
|
ds@1952
|
476 |
} |
|
pred@1953
|
477 |
else if ((outputSubmenu[Submenu_type] == SubMenu_Player) || (outputSubmenu[Submenu_type] == SubMenu_GroupPlayer)) |
|
ds@1952
|
478 |
{ |
|
pred@1953
|
479 |
new PlayerMethod:playermethod = outputSubmenu[Submenu_method]; |
|
pred@1953
|
480 |
|
|
ds@1952
|
481 |
new String:nameBuffer[32]; |
|
ds@1952
|
482 |
new String:infoBuffer[32]; |
|
ds@1952
|
483 |
new String:temp[4]; |
|
ds@1952
|
484 |
|
|
ds@1952
|
485 |
//loop through players. Add name as text and name/userid/steamid as info |
|
ds@1952
|
486 |
for (new i=1; i<=g_maxPlayers; i++) |
|
ds@1952
|
487 |
{ |
|
ds@1952
|
488 |
if (IsClientInGame(i)) |
|
ds@1952
|
489 |
{ |
|
ds@1952
|
490 |
GetClientName(i, nameBuffer, 31); |
|
ds@1952
|
491 |
|
|
ds@1952
|
492 |
switch (playermethod) |
|
ds@1952
|
493 |
{ |
|
ds@1952
|
494 |
case UserId: |
|
ds@1952
|
495 |
{ |
|
ds@1952
|
496 |
new userid = GetClientUserId(i); |
|
ds@1952
|
497 |
Format(infoBuffer, sizeof(infoBuffer), "#%i", userid); |
|
ds@1952
|
498 |
AddMenuItem(itemMenu, infoBuffer, nameBuffer); |
|
ds@1952
|
499 |
} |
|
ds@1952
|
500 |
case UserId2: |
|
ds@1952
|
501 |
{ |
|
ds@1952
|
502 |
new userid = GetClientUserId(i); |
|
ds@1952
|
503 |
Format(infoBuffer, sizeof(infoBuffer), "%i", userid); |
|
ds@1952
|
504 |
AddMenuItem(itemMenu, infoBuffer, nameBuffer); |
|
ds@1952
|
505 |
} |
|
ds@1952
|
506 |
case SteamId: |
|
ds@1952
|
507 |
{ |
|
ds@1952
|
508 |
GetClientAuthString(i, infoBuffer, sizeof(infoBuffer)); |
|
ds@1952
|
509 |
AddMenuItem(itemMenu, infoBuffer, nameBuffer); |
|
ds@1952
|
510 |
} |
|
ds@1952
|
511 |
case IpAddress: |
|
ds@1952
|
512 |
{ |
|
ds@1952
|
513 |
GetClientIP(i, infoBuffer, sizeof(infoBuffer)); |
|
ds@1952
|
514 |
AddMenuItem(itemMenu, infoBuffer, nameBuffer); |
|
ds@1952
|
515 |
} |
|
ds@1952
|
516 |
case Name: |
|
ds@1952
|
517 |
{ |
|
ds@1952
|
518 |
AddMenuItem(itemMenu, nameBuffer, nameBuffer); |
|
ds@1952
|
519 |
} |
|
ds@1952
|
520 |
default: //assume client id |
|
ds@1952
|
521 |
{ |
|
ds@1952
|
522 |
Format(temp,3,"%i",i); |
|
ds@1952
|
523 |
AddMenuItem(itemMenu, temp, nameBuffer); |
|
ds@1952
|
524 |
} |
|
ds@1952
|
525 |
} |
|
ds@1952
|
526 |
} |
|
ds@1952
|
527 |
} |
|
ds@1952
|
528 |
} |
|
pred@1953
|
529 |
else if (outputSubmenu[Submenu_type] == SubMenu_OnOff) |
|
ds@1952
|
530 |
{ |
|
ds@1952
|
531 |
AddMenuItem(itemMenu, "1", "On"); |
|
ds@1952
|
532 |
AddMenuItem(itemMenu, "0", "Off"); |
|
ds@1952
|
533 |
} |
|
ds@1952
|
534 |
else |
|
ds@1952
|
535 |
{ |
|
ds@1952
|
536 |
new String:value[64]; |
|
ds@1952
|
537 |
new String:text[64]; |
|
ds@1952
|
538 |
|
|
ds@1952
|
539 |
new String:admin[NAME_LENGTH]; |
|
pred@1953
|
540 |
|
|
pred@1953
|
541 |
for (new i=0; i<outputSubmenu[Submenu_listcount]; i++) |
|
ds@1952
|
542 |
{ |
|
pred@1953
|
543 |
ReadPackString(outputSubmenu[Submenu_listdata], value, sizeof(value)); |
|
pred@1953
|
544 |
ReadPackString(outputSubmenu[Submenu_listdata], text, sizeof(text)); |
|
pred@1953
|
545 |
ReadPackString(outputSubmenu[Submenu_listdata], admin, sizeof(admin)); |
|
ds@1952
|
546 |
|
|
pred@1953
|
547 |
if (CheckCommandAccess(client, admin, 0)) |
|
ds@1952
|
548 |
{ |
|
ds@1952
|
549 |
AddMenuItem(itemMenu, value, text); |
|
ds@1952
|
550 |
} |
|
pred@1953
|
551 |
} |
|
pred@1953
|
552 |
|
|
pred@1953
|
553 |
ResetPack(outputSubmenu[Submenu_listdata]); |
|
ds@1952
|
554 |
} |
|
ds@1952
|
555 |
|
|
pred@1953
|
556 |
SetMenuTitle(itemMenu, outputSubmenu[Submenu_title]); |
|
ds@1952
|
557 |
|
|
ds@1952
|
558 |
DisplayMenu(itemMenu, client, MENU_TIME_FOREVER); |
|
ds@1952
|
559 |
} |
|
ds@1952
|
560 |
else |
|
ds@1952
|
561 |
{ |
|
ds@1952
|
562 |
//nothing else need to be done. Run teh command. |
|
ds@1952
|
563 |
|
|
ds@1952
|
564 |
DisplayTopMenu(hAdminMenu, client, TopMenuPosition_LastCategory); |
|
ds@1952
|
565 |
|
|
pred@1953
|
566 |
if (outputItem[Item_execute] == Execute_Player) // assume 'player' type execute option |
|
ds@1952
|
567 |
{ |
|
ds@1952
|
568 |
FakeClientCommand(client, g_command[client]); |
|
ds@1952
|
569 |
} |
|
ds@1952
|
570 |
else // assume 'server' type execute option |
|
ds@1952
|
571 |
{ |
|
ds@1952
|
572 |
InsertServerCommand(g_command[client]); |
|
ds@1952
|
573 |
ServerExecute(); |
|
ds@1952
|
574 |
} |
|
ds@1952
|
575 |
|
|
ds@1952
|
576 |
g_command[client][0] = '\0'; |
|
ds@1952
|
577 |
g_currentPlace[client][Place_ReplaceNum] = 1; |
|
ds@1952
|
578 |
} |
|
ds@1952
|
579 |
} |
|
ds@1952
|
580 |
|
|
ds@1952
|
581 |
public Menu_Selection(Handle:menu, MenuAction:action, param1, param2) |
|
ds@1952
|
582 |
{ |
|
ds@1952
|
583 |
if (action == MenuAction_End) |
|
ds@1952
|
584 |
{ |
|
ds@1952
|
585 |
CloseHandle(menu); |
|
ds@1952
|
586 |
} |
|
ds@1952
|
587 |
|
|
ds@1952
|
588 |
if (action == MenuAction_Select) |
|
ds@1952
|
589 |
{ |
|
ds@1952
|
590 |
new String:info[NAME_LENGTH]; |
|
ds@1952
|
591 |
|
|
ds@1952
|
592 |
/* Get item info */ |
|
ds@1952
|
593 |
new bool:found = GetMenuItem(menu, param2, info, sizeof(info)); |
|
ds@1952
|
594 |
|
|
ds@1952
|
595 |
if (!found) |
|
ds@1952
|
596 |
{ |
|
ds@1952
|
597 |
return; |
|
ds@1952
|
598 |
} |
|
ds@1952
|
599 |
|
|
ds@1952
|
600 |
new String:buffer[6]; |
|
ds@1952
|
601 |
new String:infobuffer[NAME_LENGTH+2]; |
|
ds@1952
|
602 |
Format(infobuffer, sizeof(infobuffer), "\"%s\"", info); |
|
ds@1952
|
603 |
|
|
ds@1952
|
604 |
Format(buffer, 5, "#%i", g_currentPlace[param1][Place_ReplaceNum]); |
|
ds@1952
|
605 |
ReplaceString(g_command[param1], sizeof(g_command[]), buffer, infobuffer); |
|
ds@1952
|
606 |
//replace #num with the selected option (quoted) |
|
ds@1952
|
607 |
|
|
ds@1952
|
608 |
Format(buffer, 5, "@%i", g_currentPlace[param1][Place_ReplaceNum]); |
|
ds@1952
|
609 |
ReplaceString(g_command[param1], sizeof(g_command[]), buffer, info); |
|
ds@1952
|
610 |
//replace @num with the selected option (unquoted) |
|
ds@1952
|
611 |
|
|
ds@1952
|
612 |
// Increment the parameter counter. |
|
ds@1952
|
613 |
g_currentPlace[param1][Place_ReplaceNum]++; |
|
ds@1952
|
614 |
|
|
ds@1952
|
615 |
ParamCheck(param1); |
|
ds@1952
|
616 |
} |
|
ds@1952
|
617 |
|
|
ds@1952
|
618 |
if (action == MenuAction_Cancel && param2 == MenuCancel_Exit) |
|
ds@1952
|
619 |
{ |
|
ds@1952
|
620 |
//client exited we should go back to submenu i think |
|
ds@1952
|
621 |
DisplayTopMenu(hAdminMenu, param1, TopMenuPosition_LastCategory); |
|
ds@1952
|
622 |
} |
|
ds@1952
|
623 |
} |