mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-24 13:55:36 +03:00
Changed map list to use dynamic arrays
This commit is contained in:
parent
d563ecb060
commit
2659c906fb
@ -35,11 +35,12 @@
|
||||
#include <amxmodx>
|
||||
#include <amxmisc>
|
||||
|
||||
#define MAX_MAPS 128
|
||||
#define SELECTMAPS 5
|
||||
|
||||
new g_mapName[MAX_MAPS][32]
|
||||
new g_mapNums
|
||||
#define charsof(%1) (sizeof(%1)-1)
|
||||
|
||||
new Array:g_mapName;
|
||||
new g_mapNums;
|
||||
|
||||
new g_nextName[SELECTMAPS]
|
||||
new g_voteCount[SELECTMAPS + 2]
|
||||
@ -56,6 +57,8 @@ public plugin_init()
|
||||
register_dictionary("mapchooser.txt")
|
||||
register_dictionary("common.txt")
|
||||
|
||||
g_mapName=ArrayCreate(32);
|
||||
|
||||
new MenuName[64]
|
||||
|
||||
format(MenuName, 63, "%L", "en", "CHOOSE_NEXTM")
|
||||
@ -79,6 +82,7 @@ public plugin_init()
|
||||
set_task(15.0, "voteNextmap", 987456, "", 0, "b")
|
||||
|
||||
g_coloredMenus = colored_menus()
|
||||
|
||||
}
|
||||
|
||||
public checkVotes()
|
||||
@ -104,12 +108,13 @@ public checkVotes()
|
||||
return
|
||||
}
|
||||
|
||||
new smap[32]
|
||||
if (g_voteCount[b] && g_voteCount[SELECTMAPS + 1] <= g_voteCount[b])
|
||||
{
|
||||
set_cvar_string("amx_nextmap", g_mapName[g_nextName[b]])
|
||||
ArrayGetString(g_mapName, g_nextName[b], smap, charsof(smap));
|
||||
set_cvar_string("amx_nextmap", smap);
|
||||
}
|
||||
|
||||
new smap[32]
|
||||
|
||||
get_cvar_string("amx_nextmap", smap, 31)
|
||||
client_print(0, print_chat, "%L", LANG_PLAYER, "CHO_FIN_NEXT", smap)
|
||||
@ -126,7 +131,11 @@ public countVote(id, key)
|
||||
if (key == SELECTMAPS)
|
||||
client_print(0, print_chat, "%L", LANG_PLAYER, "CHOSE_EXT", name)
|
||||
else if (key < SELECTMAPS)
|
||||
client_print(0, print_chat, "%L", LANG_PLAYER, "X_CHOSE_X", name, g_mapName[g_nextName[key]])
|
||||
{
|
||||
new map[32];
|
||||
ArrayGetString(g_mapName, g_nextName[key], map, charsof(map));
|
||||
client_print(0, print_chat, "%L", LANG_PLAYER, "X_CHOSE_X", name, map);
|
||||
}
|
||||
}
|
||||
++g_voteCount[key]
|
||||
|
||||
@ -179,6 +188,7 @@ public voteNextmap()
|
||||
g_selected = true
|
||||
|
||||
new menu[512], a, mkeys = (1<<SELECTMAPS + 1)
|
||||
new tempmap[32];
|
||||
new pos = format(menu, 511, g_coloredMenus ? "\y%L:\w^n^n" : "%L:^n^n", LANG_SERVER, "CHOOSE_NEXTM")
|
||||
new dmax = (g_mapNums > SELECTMAPS) ? SELECTMAPS : g_mapNums
|
||||
|
||||
@ -190,7 +200,8 @@ public voteNextmap()
|
||||
if (++a >= g_mapNums) a = 0
|
||||
|
||||
g_nextName[g_mapVoteNum] = a
|
||||
pos += format(menu[pos], 511, "%d. %s^n", g_mapVoteNum + 1, g_mapName[a])
|
||||
ArrayGetString(g_mapName, a, tempmap, charsof(tempmap));
|
||||
pos += format(menu[pos], 511, "%d. %s^n", g_mapVoteNum + 1, tempmap);
|
||||
mkeys |= (1<<g_mapVoteNum)
|
||||
g_voteCount[g_mapVoteNum] = 0
|
||||
}
|
||||
@ -225,17 +236,35 @@ loadSettings(filename[])
|
||||
return 0
|
||||
|
||||
new szText[32]
|
||||
new a, pos = 0
|
||||
new currentMap[32]
|
||||
|
||||
new buff[256];
|
||||
|
||||
get_mapname(currentMap, 31)
|
||||
|
||||
while ((g_mapNums < MAX_MAPS) && read_file(filename, pos++, szText, 31, a))
|
||||
new fp=fopen(filename,"r");
|
||||
|
||||
while (!feof(fp))
|
||||
{
|
||||
if (szText[0] != ';' && parse(szText, g_mapName[g_mapNums], 31) && is_map_valid(g_mapName[g_mapNums])
|
||||
&& !equali(g_mapName[g_mapNums], g_lastMap) && !equali(g_mapName[g_mapNums], currentMap))
|
||||
++g_mapNums
|
||||
buff[0]='^0';
|
||||
|
||||
fgets(fp, buff, charsof(buff));
|
||||
|
||||
parse(buff, szText, charsof(szText));
|
||||
|
||||
|
||||
if (szText[0] != ';' &&
|
||||
is_map_valid(szText) &&
|
||||
!equali(szText, g_lastMap) &&
|
||||
!equali(szText, currentMap))
|
||||
{
|
||||
ArrayPushString(g_mapName, szText);
|
||||
++g_mapNums;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return g_mapNums
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user