Added some useful IDA scripts (NPOTB).
3 * =============================================================================
4 * SourceMod Basevotes Plugin
5 * Provides map functionality
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>.
34 new Handle:g_MapList = INVALID_HANDLE;
37 new Handle:g_SelectedMaps;
38 new bool:g_VoteMapInUse;
40 DisplayVoteMapMenu(client, mapCount, String:maps[5][])
42 LogAction(client, -1, "\"%L\" initiated a map vote.", client);
43 ShowActivity2(client, "[SM] ", "%t", "Initiated Vote Map");
45 g_voteType = voteType:map;
47 g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
51 strcopy(g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]), maps[0]);
53 SetMenuTitle(g_hVoteMenu, "Change Map To");
54 AddMenuItem(g_hVoteMenu, maps[0], "Yes");
55 AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
59 g_voteInfo[VOTE_NAME][0] = '\0';
61 SetMenuTitle(g_hVoteMenu, "Map Vote");
62 for (new i = 0; i < mapCount; i++)
64 AddMenuItem(g_hVoteMenu, maps[i], maps[i]);
68 SetMenuExitButton(g_hVoteMenu, false);
69 VoteMenuToAll(g_hVoteMenu, 20);
74 g_VoteMapInUse = false;
75 ClearArray(g_SelectedMaps);
80 new Handle:menu = CreateMenu(MenuHandler_Confirm);
82 decl String:title[100];
83 Format(title, sizeof(title), "%T:", "Confirm Vote", client);
84 SetMenuTitle(menu, title);
85 SetMenuExitBackButton(menu, true);
87 AddMenuItem(menu, "Confirm", "Start the Vote");
89 DisplayMenu(menu, client, MENU_TIME_FOREVER);
92 public MenuHandler_Confirm(Handle:menu, MenuAction:action, param1, param2)
94 if (action == MenuAction_End)
97 g_VoteMapInUse = false;
99 else if (action == MenuAction_Cancel)
103 if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
105 DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
108 else if (action == MenuAction_Select)
110 decl String:maps[5][64];
111 new selectedmaps = GetArraySize(g_SelectedMaps);
113 for (new i = 0; i < selectedmaps; i++)
115 GetArrayString(g_SelectedMaps, i, maps[i], sizeof(maps[]));
118 DisplayVoteMapMenu(param1, selectedmaps, maps);
124 public MenuHandler_Map(Handle:menu, MenuAction:action, param1, param2)
126 if (action == MenuAction_Cancel)
128 if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
132 else // no action was selected.
134 /* Re-enable the menu option */
138 else if (action == MenuAction_DrawItem)
140 decl String:info[32], String:name[32];
142 GetMenuItem(menu, param2, info, sizeof(info), _, name, sizeof(name));
144 if (FindStringInArray(g_SelectedMaps, info) != -1)
146 return ITEMDRAW_IGNORE;
150 return ITEMDRAW_DEFAULT;
153 else if (action == MenuAction_Select)
155 decl String:info[32], String:name[32];
157 GetMenuItem(menu, param2, info, sizeof(info), _, name, sizeof(name));
159 PushArrayString(g_SelectedMaps, info);
161 /* Redisplay the list */
162 if (GetArraySize(g_SelectedMaps) < 5)
164 DisplayMenu(g_MapList, param1, MENU_TIME_FOREVER);
175 public AdminMenu_VoteMap(Handle:topmenu,
176 TopMenuAction:action,
177 TopMenuObject:object_id,
182 if (action == TopMenuAction_DisplayOption)
184 Format(buffer, maxlength, "%T", "Map vote", param);
186 else if (action == TopMenuAction_SelectOption)
191 g_VoteMapInUse = true;
192 DisplayMenu(g_MapList, param, MENU_TIME_FOREVER);
196 PrintToChat(param, "[SM] %T", "Map Vote In Use", param);
199 else if (action == TopMenuAction_DrawOption)
201 /* disable this option if a vote is already running, theres no maps listed or someone else has already acessed this menu */
202 buffer[0] = (!IsNewVoteAllowed() || g_mapCount < 1 || g_VoteMapInUse) ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
206 public Action:Command_Votemap(client, args)
210 ReplyToCommand(client, "[SM] Usage: sm_votemap <mapname> [mapname2] ... [mapname5]");
211 return Plugin_Handled;
214 if (IsVoteInProgress())
216 ReplyToCommand(client, "[SM] %t", "Vote in Progress");
217 return Plugin_Handled;
220 if (!TestVoteDelay(client))
222 return Plugin_Handled;
225 decl String:text[256];
226 GetCmdArgString(text, sizeof(text));
228 decl String:maps[5][64];
232 while (pos != -1 && mapCount < 5)
234 pos = BreakString(text[len], maps[mapCount], sizeof(maps[]));
236 if (!IsMapValid(maps[mapCount]))
238 ReplyToCommand(client, "[SM] %t", "Map was not found", maps[mapCount]);
239 return Plugin_Handled;
250 DisplayVoteMapMenu(client, mapCount, maps);
252 return Plugin_Handled;
255 new Handle:g_map_array = INVALID_HANDLE;
256 new g_map_serial = -1;
258 LoadMapList(Handle:menu)
260 new Handle:map_array;
262 if ((map_array = ReadMapList(g_map_array,
265 MAPLIST_FLAG_CLEARARRAY|MAPLIST_FLAG_NO_DEFAULT|MAPLIST_FLAG_MAPSFOLDER))
268 g_map_array = map_array;
271 if (g_map_array == INVALID_HANDLE)
276 RemoveAllMenuItems(menu);
278 decl String:map_name[64];
279 new map_count = GetArraySize(g_map_array);
281 for (new i = 0; i < map_count; i++)
283 GetArrayString(g_map_array, i, map_name, sizeof(map_name));
284 AddMenuItem(menu, map_name, map_name);