35 |
#include <amxmodx> |
#include <amxmodx> |
36 |
#include <amxmisc> |
#include <amxmisc> |
37 |
|
|
|
#define MAX_MAPS 128 |
|
38 |
#define SELECTMAPS 5 |
#define SELECTMAPS 5 |
39 |
|
|
40 |
new g_mapName[MAX_MAPS][32] |
#define charsof(%1) (sizeof(%1)-1) |
41 |
new g_mapNums |
|
42 |
|
new Array:g_mapName; |
43 |
|
new g_mapNums; |
44 |
|
|
45 |
new g_nextName[SELECTMAPS] |
new g_nextName[SELECTMAPS] |
46 |
new g_voteCount[SELECTMAPS + 2] |
new g_voteCount[SELECTMAPS + 2] |
57 |
register_dictionary("mapchooser.txt") |
register_dictionary("mapchooser.txt") |
58 |
register_dictionary("common.txt") |
register_dictionary("common.txt") |
59 |
|
|
60 |
|
g_mapName=ArrayCreate(32); |
61 |
|
|
62 |
new MenuName[64] |
new MenuName[64] |
63 |
|
|
64 |
format(MenuName, 63, "%L", "en", "CHOOSE_NEXTM") |
format(MenuName, 63, "%L", "en", "CHOOSE_NEXTM") |
82 |
set_task(15.0, "voteNextmap", 987456, "", 0, "b") |
set_task(15.0, "voteNextmap", 987456, "", 0, "b") |
83 |
|
|
84 |
g_coloredMenus = colored_menus() |
g_coloredMenus = colored_menus() |
85 |
|
|
86 |
} |
} |
87 |
|
|
88 |
public checkVotes() |
public checkVotes() |
108 |
return |
return |
109 |
} |
} |
110 |
|
|
111 |
|
new smap[32] |
112 |
if (g_voteCount[b] && g_voteCount[SELECTMAPS + 1] <= g_voteCount[b]) |
if (g_voteCount[b] && g_voteCount[SELECTMAPS + 1] <= g_voteCount[b]) |
113 |
{ |
{ |
114 |
set_cvar_string("amx_nextmap", g_mapName[g_nextName[b]]) |
ArrayGetString(g_mapName, g_nextName[b], smap, charsof(smap)); |
115 |
|
set_cvar_string("amx_nextmap", smap); |
116 |
} |
} |
117 |
|
|
|
new smap[32] |
|
118 |
|
|
119 |
get_cvar_string("amx_nextmap", smap, 31) |
get_cvar_string("amx_nextmap", smap, 31) |
120 |
client_print(0, print_chat, "%L", LANG_PLAYER, "CHO_FIN_NEXT", smap) |
client_print(0, print_chat, "%L", LANG_PLAYER, "CHO_FIN_NEXT", smap) |
131 |
if (key == SELECTMAPS) |
if (key == SELECTMAPS) |
132 |
client_print(0, print_chat, "%L", LANG_PLAYER, "CHOSE_EXT", name) |
client_print(0, print_chat, "%L", LANG_PLAYER, "CHOSE_EXT", name) |
133 |
else if (key < SELECTMAPS) |
else if (key < SELECTMAPS) |
134 |
client_print(0, print_chat, "%L", LANG_PLAYER, "X_CHOSE_X", name, g_mapName[g_nextName[key]]) |
{ |
135 |
|
new map[32]; |
136 |
|
ArrayGetString(g_mapName, g_nextName[key], map, charsof(map)); |
137 |
|
client_print(0, print_chat, "%L", LANG_PLAYER, "X_CHOSE_X", name, map); |
138 |
|
} |
139 |
} |
} |
140 |
++g_voteCount[key] |
++g_voteCount[key] |
141 |
|
|
188 |
g_selected = true |
g_selected = true |
189 |
|
|
190 |
new menu[512], a, mkeys = (1<<SELECTMAPS + 1) |
new menu[512], a, mkeys = (1<<SELECTMAPS + 1) |
191 |
|
|
192 |
new pos = format(menu, 511, g_coloredMenus ? "\y%L:\w^n^n" : "%L:^n^n", LANG_SERVER, "CHOOSE_NEXTM") |
new pos = format(menu, 511, g_coloredMenus ? "\y%L:\w^n^n" : "%L:^n^n", LANG_SERVER, "CHOOSE_NEXTM") |
193 |
new dmax = (g_mapNums > SELECTMAPS) ? SELECTMAPS : g_mapNums |
new dmax = (g_mapNums > SELECTMAPS) ? SELECTMAPS : g_mapNums |
194 |
|
|
200 |
if (++a >= g_mapNums) a = 0 |
if (++a >= g_mapNums) a = 0 |
201 |
|
|
202 |
g_nextName[g_mapVoteNum] = a |
g_nextName[g_mapVoteNum] = a |
203 |
pos += format(menu[pos], 511, "%d. %s^n", g_mapVoteNum + 1, g_mapName[a]) |
pos += format(menu[pos], 511, "%d. %a^n", g_mapVoteNum + 1, ArrayGetStringHandle(g_mapName, a)); |
204 |
mkeys |= (1<<g_mapVoteNum) |
mkeys |= (1<<g_mapVoteNum) |
205 |
g_voteCount[g_mapVoteNum] = 0 |
g_voteCount[g_mapVoteNum] = 0 |
206 |
} |
} |
228 |
client_cmd(0, "spk Gman/Gman_Choose2") |
client_cmd(0, "spk Gman/Gman_Choose2") |
229 |
log_amx("Vote: Voting for the nextmap started") |
log_amx("Vote: Voting for the nextmap started") |
230 |
} |
} |
231 |
|
stock bool:ValidMap(mapname[]) |
232 |
|
{ |
233 |
|
if ( is_map_valid(mapname) ) |
234 |
|
{ |
235 |
|
return true; |
236 |
|
} |
237 |
|
// If the is_map_valid check failed, check the end of the string |
238 |
|
new len = strlen(mapname) - 4; |
239 |
|
|
240 |
|
// The mapname was too short to possibly house the .bsp extension |
241 |
|
if (len < 0) |
242 |
|
{ |
243 |
|
return false; |
244 |
|
} |
245 |
|
if ( equali(mapname[len], ".bsp") ) |
246 |
|
{ |
247 |
|
// If the ending was .bsp, then cut it off. |
248 |
|
// the string is byref'ed, so this copies back to the loaded text. |
249 |
|
mapname[len] = '^0'; |
250 |
|
|
251 |
|
// recheck |
252 |
|
if ( is_map_valid(mapname) ) |
253 |
|
{ |
254 |
|
return true; |
255 |
|
} |
256 |
|
} |
257 |
|
|
258 |
|
return false; |
259 |
|
} |
260 |
|
|
261 |
loadSettings(filename[]) |
loadSettings(filename[]) |
262 |
{ |
{ |
264 |
return 0 |
return 0 |
265 |
|
|
266 |
new szText[32] |
new szText[32] |
|
new a, pos = 0 |
|
267 |
new currentMap[32] |
new currentMap[32] |
268 |
|
|
269 |
|
new buff[256]; |
270 |
|
|
271 |
get_mapname(currentMap, 31) |
get_mapname(currentMap, 31) |
272 |
|
|
273 |
while ((g_mapNums < MAX_MAPS) && read_file(filename, pos++, szText, 31, a)) |
new fp=fopen(filename,"r"); |
274 |
|
|
275 |
|
while (!feof(fp)) |
276 |
{ |
{ |
277 |
if (szText[0] != ';' && parse(szText, g_mapName[g_mapNums], 31) && is_map_valid(g_mapName[g_mapNums]) |
buff[0]='^0'; |
278 |
&& !equali(g_mapName[g_mapNums], g_lastMap) && !equali(g_mapName[g_mapNums], currentMap)) |
|
279 |
++g_mapNums |
fgets(fp, buff, charsof(buff)); |
280 |
|
|
281 |
|
parse(buff, szText, charsof(szText)); |
282 |
|
|
283 |
|
|
284 |
|
if (szText[0] != ';' && |
285 |
|
ValidMap(szText) && |
286 |
|
!equali(szText, g_lastMap) && |
287 |
|
!equali(szText, currentMap)) |
288 |
|
{ |
289 |
|
ArrayPushString(g_mapName, szText); |
290 |
|
++g_mapNums; |
291 |
} |
} |
292 |
|
|
293 |
|
} |
294 |
|
|
295 |
|
fclose(fp); |
296 |
|
|
297 |
return g_mapNums |
return g_mapNums |
298 |
} |
} |
299 |
|
|