From 2659c906fb79de25979ed015860661ac13a3caf9 Mon Sep 17 00:00:00 2001 From: Steve Dudenhoeffer Date: Tue, 24 Apr 2007 17:41:56 +0000 Subject: [PATCH] Changed map list to use dynamic arrays --- plugins/mapchooser.sma | 53 ++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/plugins/mapchooser.sma b/plugins/mapchooser.sma index fd3c0703..2ae57f12 100755 --- a/plugins/mapchooser.sma +++ b/plugins/mapchooser.sma @@ -35,11 +35,12 @@ #include #include -#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) ? 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<