CREATE VIEW [Top maps] AS
SELECT map_name as Map, SUM(result) as Score, COUNT(*) as Occurances FROM koppling, maps WHERE maps.map_id = koppling.map_id GROUP BY Map ORDER BY Score DESC;
It can end up like this, example from my test server:
RecNo Map Score Occurances
1 fy_simpsons 142 86
2 fy_iceworld_cz 134 82
3 fy_pool_day 131 79
4 gg_boot-camp 115 100
5 fy_waterland_cz 108 91
6 mindmaze2 102 95
7 cs_crackhouse 99 91
8 cs_triggerhappy 43 60
9 fy_iceworld3000 10 2
10 ka_japarena 5 4
Score is the # of votes on a certain map, and Occurances is the number of appearances in Mapchooser vote sessions.
What you wanna do with it from here I don't know but... maybe it can give people some idea? Of what maps to remove cause they're impopular, and so on...
However as I've been out for a while I might not really have kept up with the latest do:s and don't:s. Feel free to comment on the coding, especially the new SQL interface which I'm not sure I've used correctly.
Code: Select all
public countVote(id, key)
{
if (get_cvar_float("amx_vote_answers"))
{
new name[32]
get_user_name(id, name, 31)
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]])
}
++g_voteCount[key]
return PLUGIN_HANDLED
}
bool:isInMenu(id)
{
for (new a = 0; a < g_mapVoteNum; ++a)
if (id == g_nextName[a])
return true
return false
}
public voteNextmap()
{
new winlimit = get_cvar_num("mp_winlimit")
new maxrounds = get_cvar_num("mp_maxrounds")
if (winlimit)
{
new c = winlimit - 2
if ((c > g_teamScore[0]) && (c > g_teamScore[1]))
{
g_selected = false
return
}
}
else if (maxrounds)
{
if ((maxrounds - 2) > (g_teamScore[0] + g_teamScore[1]))
{
g_selected = false
return
}
} else {
new timeleft = get_timeleft()
if (timeleft < 1 || timeleft > 129)
{
g_selected = false
return
}
}
if (g_selected)
return
g_selected = true
new menu[512], a, mkeys = (1<<SELECTMAPS + 1)
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
for (g_mapVoteNum = 0; g_mapVoteNum < dmax; ++g_mapVoteNum)
{
a = random_num(0, g_mapNums - 1)
while (isInMenu(a))
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])
mkeys |= (1<<g_mapVoteNum)
g_voteCount[g_mapVoteNum] = 0
}
menu[pos++] = '^n'
g_voteCount[SELECTMAPS] = 0
g_voteCount[SELECTMAPS + 1] = 0
new mapname[32]
get_mapname(mapname, 31)
if ((winlimit + maxrounds) == 0 && (get_cvar_float("mp_timelimit") < get_cvar_float("amx_extendmap_max")))
{
pos += format(menu[pos], 511, "%d. %L^n", SELECTMAPS + 1, LANG_SERVER, "EXTED_MAP", mapname)
mkeys |= (1<<SELECTMAPS)
}
format(menu[pos], 511, "%d. %L", SELECTMAPS+2, LANG_SERVER, "NONE")
new MenuName[64]
format(MenuName, 63, "%L", "en", "CHOOSE_NEXTM")
show_menu(0, mkeys, menu, 15, MenuName)
set_task(15.0, "checkVotes")
client_print(0, print_chat, "%L", LANG_SERVER, "TIME_CHOOSE")
client_cmd(0, "spk Gman/Gman_Choose2")
log_amx("Vote: Voting for the nextmap started")
server_print(menu)
}
loadSettings(filename[])
{
if (!file_exists(filename))
return 0
new szText[32]
new a, pos = 0
new currentMap[32]
get_mapname(currentMap, 31)
while ((g_mapNums < MAX_MAPS) && read_file(filename, pos++, szText, 31, a))
{
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
}
return g_mapNums
}
public team_score()
{
new team[2]
read_data(1, team, 1)
g_teamScore[(team[0]=='C') ? 0 : 1] = read_data(2)
}
public plugin_end()
{
new current_map[32]
get_mapname(current_map, 31)
set_localinfo("lastMap", current_map)
}