|
楼主 |
发表于 2009-8-7 10:09:12
|
显示全部楼层
来自 中国–广东–深圳–福田区
displayVoteMapsMenu(id, pos)
{
if (pos < 0)
return
new menuBody[512], b = 0, start = pos * 7
if (start >= g_mapNums)
start = pos = g_menuPosition[id] = 0
new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "VOTEMAP_MENU", pos + 1, (g_mapNums / 7 + ((g_mapNums % 7) ? 1 : 0)))
new end = start + 7, keys = MENU_KEY_0
if (end > g_mapNums)
end = g_mapNums
for (new a = start; a < end; ++a)
{
if (g_voteSelectedNum[id] == 4 || isMapSelected(id, pos * 7 + b))
{
++b
if (g_coloredMenus)
len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, g_mapName[a])
else
len += format(menuBody[len], 511-len, "#. %s^n", g_mapName[a])
} else {
keys |= (1<<b)
len += format(menuBody[len], 511-len, "%d. %s^n", ++b, g_mapName[a])
}
}
if (g_voteSelectedNum[id])
{
keys |= MENU_KEY_8
len += format(menuBody[len], 511-len, "^n8. %L^n", id, "START_VOT")
}
else
len += format(menuBody[len], 511-len, g_coloredMenus ? "^n\d8. %L^n\w" : "^n#. %L^n", id, "START_VOT")
if (end != g_mapNums)
{
len += format(menuBody[len], 511-len, "^n9. %L...^n0. %L^n", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else
len += format(menuBody[len], 511-len, "^n0. %L^n", id, pos ? "BACK" : "EXIT")
if (g_voteSelectedNum[id])
len += format(menuBody[len], 511-len, g_coloredMenus ? "^n\y%L:^n\w" : "^n%L:^n", id, "SEL_MAPS")
else
len += format(menuBody[len], 511-len, "^n^n")
for (new c = 0; c < 4; c++)
{
if (c < g_voteSelectedNum[id])
len += format(menuBody[len], 511-len, "%s^n", g_mapName[g_voteSelected[id][c]])
else
len += format(menuBody[len], 511-len, "^n")
}
new menuName[64]
format(menuName, 63, "%L", "en", "VOTEMAP_MENU")
show_menu(id, keys, menuBody, -1, menuName)
}
public cmdVoteMapMenu(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
if (get_cvar_float("amx_last_voting") > get_gametime())
{
client_print(id, print_chat, "%L", id, "ALREADY_VOT")
return PLUGIN_HANDLED
}
g_voteSelectedNum[id] = 0
if (g_mapNums)
{
displayVoteMapsMenu(id, g_menuPosition[id] = 0)
} else {
console_print(id, "%L", id, "NO_MAPS_MENU")
client_print(id, print_chat, "%L", id, "NO_MAPS_MENU")
}
return PLUGIN_HANDLED
}
public cmdMapsMenu(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
if (g_mapNums)
{
displayMapsMenu(id, g_menuPosition[id] = 0)
} else {
console_print(id, "%L", id, "NO_MAPS_MENU")
client_print(id, print_chat, "%L", id, "NO_MAPS_MENU")
}
return PLUGIN_HANDLED
}
public delayedChange(mapname[])
server_cmd("changelevel %s", mapname)
public actionVoteMapMenu(id, key)
{
switch (key)
{
case 7:
{
new Float:voting = get_cvar_float("amx_last_voting")
if (voting > get_gametime())
{
client_print(id, print_chat, "%L", id, "ALREADY_VOT")
return PLUGIN_HANDLED
}
if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime())
{
client_print(id, print_chat, "%L", id, "VOT_NOW_ALLOW")
return PLUGIN_HANDLED
}
g_voteCount = {0, 0, 0, 0, 0}
new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0
set_cvar_float("amx_last_voting", get_gametime() + vote_time)
new iVoteTime = floatround(vote_time)
set_task(vote_time, "checkVotes", 34567 + id)
new menuBody[512]
new players[32]
new pnum, keys, len
get_players(players, pnum)
if (g_voteSelectedNum[id] > 1)
{
len = format(menuBody, 511, g_coloredMenus ? "\y%L^n\w^n" : "%L^n^n", id, "WHICH_MAP")
for (new c = 0; c < g_voteSelectedNum[id]; ++c)
{
len += format(menuBody[len], 511, "%d. %s^n", c + 1, g_mapName[g_voteSelected[id][c]])
keys |= (1<<c)
}
keys |= (1<<8)
len += format(menuBody[len], 511, "^n9. %L^n", id, "NONE")
} else {
len = format(menuBody, 511, g_coloredMenus ? "\y%L^n%s?^n\w^n1. %L^n2. %L^n" : "%L^n%s?^n^n1. %L^n2. %L^n", id, "CHANGE_MAP_TO", g_mapName[g_voteSelected[id][0]], id, "YES", id, "NO")
keys = MENU_KEY_1|MENU_KEY_2
}
new menuName[64]
format(menuName, 63, "%L", "en", "WHICH_MAP")
for (new b = 0; b < pnum; ++b)
if (players[b] != id)
show_menu(players[b], keys, menuBody, iVoteTime, menuName)
format(menuBody[len], 511, "^n0. %L", id, "CANC_VOTE")
keys |= MENU_KEY_0
show_menu(id, keys, menuBody, iVoteTime, menuName)
new authid[32], name[32]
get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
switch (get_cvar_num("amx_show_activity"))
{
case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_V_MAP_2", name)
case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_V_MAP_1")
}
log_amx("Vote: ^"%s<%d><%s><>^" vote maps (map#1 ^"%s^") (map#2 ^"%s^") (map#3 ^"%s^") (map#4 ^"%s^")",
name, get_user_userid(id), authid,
g_voteSelectedNum[id] > 0 ? g_mapName[g_voteSelected[id][0]] : "",
g_voteSelectedNum[id] > 1 ? g_mapName[g_voteSelected[id][1]] : "",
g_voteSelectedNum[id] > 2 ? g_mapName[g_voteSelected[id][2]] : "",
g_voteSelectedNum[id] > 3 ? g_mapName[g_voteSelected[id][3]] : "")
}
case 8: displayVoteMapsMenu(id, ++g_menuPosition[id])
case 9: displayVoteMapsMenu(id, --g_menuPosition[id])
default:
{
g_voteSelected[id][g_voteSelectedNum[id]++] = g_menuPosition[id] * 7 + key
displayVoteMapsMenu(id, g_menuPosition[id])
}
}
return PLUGIN_HANDLED
} |
|