2014-08-04 12:12:15 +00:00
|
|
|
// vim: set ts=4 sw=4 tw=99 noet:
|
|
|
|
//
|
|
|
|
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
|
|
|
|
// Copyright (C) The AMX Mod X Development Team.
|
|
|
|
//
|
|
|
|
// This software is licensed under the GNU General Public License, version 3 or higher.
|
|
|
|
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
|
|
|
// https://alliedmods.net/amxmodx-license
|
|
|
|
|
|
|
|
//
|
|
|
|
// Maps Menu Plugin
|
|
|
|
//
|
2004-01-31 20:56:22 +00:00
|
|
|
|
2004-03-05 19:35:38 +00:00
|
|
|
#include <amxmodx>
|
2004-03-07 14:30:53 +00:00
|
|
|
#include <amxmisc>
|
2004-01-31 20:56:22 +00:00
|
|
|
|
2007-05-24 18:15:41 +00:00
|
|
|
new Array:g_mapName;
|
2004-01-31 20:56:22 +00:00
|
|
|
new g_mapNums
|
2014-07-20 10:27:02 +00:00
|
|
|
new g_menuPosition[MAX_PLAYERS]
|
2004-01-31 20:56:22 +00:00
|
|
|
|
|
|
|
new g_voteCount[5]
|
|
|
|
|
2014-07-20 10:27:02 +00:00
|
|
|
new g_voteSelected[MAX_PLAYERS][4]
|
|
|
|
new g_voteSelectedNum[MAX_PLAYERS]
|
2004-01-31 20:56:22 +00:00
|
|
|
|
2004-07-26 15:48:12 +00:00
|
|
|
new g_coloredMenus
|
2004-01-31 20:56:22 +00:00
|
|
|
|
|
|
|
new g_choosed
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
public plugin_init()
|
|
|
|
{
|
|
|
|
register_plugin("Maps Menu", AMXX_VERSION_STR, "AMXX Dev Team")
|
|
|
|
register_dictionary("mapsmenu.txt")
|
|
|
|
register_dictionary("common.txt")
|
|
|
|
register_clcmd("amx_mapmenu", "cmdMapsMenu", ADMIN_MAP, "- displays changelevel menu")
|
2006-12-19 12:24:36 +00:00
|
|
|
register_clcmd("amx_votemapmenu", "cmdVoteMapMenu", ADMIN_VOTE, "- displays votemap menu")
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
register_menucmd(register_menuid("Changelevel Menu"), 1023, "actionMapsMenu")
|
|
|
|
register_menucmd(register_menuid("Which map do you want?"), 527, "voteCount")
|
|
|
|
register_menucmd(register_menuid("Change map to"), 527, "voteCount")
|
|
|
|
register_menucmd(register_menuid("Votemap Menu"), 1023, "actionVoteMapMenu")
|
|
|
|
register_menucmd(register_menuid("The winner: "), 3, "actionResult")
|
|
|
|
|
2007-05-24 18:15:41 +00:00
|
|
|
g_mapName=ArrayCreate(32);
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
new maps_ini_file[64];
|
2014-07-29 14:32:32 +00:00
|
|
|
get_configsdir(maps_ini_file, charsmax(maps_ini_file));
|
|
|
|
format(maps_ini_file, charsmax(maps_ini_file), "%s/maps.ini", maps_ini_file);
|
2005-09-12 21:06:24 +00:00
|
|
|
|
2007-06-22 18:37:38 +00:00
|
|
|
if (!file_exists(maps_ini_file))
|
2014-07-29 14:32:32 +00:00
|
|
|
get_cvar_string("mapcyclefile", maps_ini_file, charsmax(maps_ini_file));
|
2007-06-22 18:37:38 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
if (!file_exists(maps_ini_file))
|
2014-07-29 14:32:32 +00:00
|
|
|
format(maps_ini_file, charsmax(maps_ini_file), "mapcycle.txt")
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
load_settings(maps_ini_file)
|
|
|
|
|
|
|
|
g_coloredMenus = colored_menus()
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
public autoRefuse()
|
|
|
|
{
|
|
|
|
log_amx("Vote: %L", "en", "RESULT_REF")
|
|
|
|
client_print(0, print_chat, "%L", LANG_PLAYER, "RESULT_REF")
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
public actionResult(id, key)
|
|
|
|
{
|
|
|
|
remove_task(4545454)
|
|
|
|
|
|
|
|
switch (key)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
new _modName[10]
|
2014-07-29 14:32:32 +00:00
|
|
|
get_modname(_modName, charsmax(_modName))
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
if (!equal(_modName, "zp"))
|
|
|
|
{
|
|
|
|
message_begin(MSG_ALL, SVC_INTERMISSION)
|
|
|
|
message_end()
|
|
|
|
}
|
|
|
|
|
2007-05-24 18:15:41 +00:00
|
|
|
new tempMap[32];
|
|
|
|
ArrayGetString(g_mapName, g_choosed, tempMap, charsmax(tempMap));
|
|
|
|
|
|
|
|
set_task(2.0, "delayedChange", 0, tempMap, strlen(tempMap) + 1)
|
2005-09-12 21:06:24 +00:00
|
|
|
log_amx("Vote: %L", "en", "RESULT_ACC")
|
|
|
|
client_print(0, print_chat, "%L", LANG_PLAYER, "RESULT_ACC")
|
|
|
|
}
|
|
|
|
case 1: autoRefuse()
|
|
|
|
}
|
|
|
|
|
|
|
|
return PLUGIN_HANDLED
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
public checkVotes(id)
|
|
|
|
{
|
|
|
|
id -= 34567
|
2014-07-20 13:15:45 +00:00
|
|
|
new num, ppl[32], a = 0
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
get_players(ppl, num, "c")
|
|
|
|
if (num == 0) num = 1
|
|
|
|
g_choosed = -1
|
|
|
|
|
|
|
|
for (new i = 0; i < g_voteSelectedNum[id]; ++i)
|
|
|
|
if (g_voteCount[a] < g_voteCount[i])
|
|
|
|
a = i
|
|
|
|
|
2005-12-06 19:06:05 +00:00
|
|
|
new votesNum = g_voteCount[0] + g_voteCount[1] + g_voteCount[2] + g_voteCount[3] + g_voteCount[4]
|
|
|
|
new iRatio = votesNum ? floatround(get_cvar_float("amx_votemap_ratio") * float(votesNum), floatround_ceil) : 1
|
|
|
|
new iResult = g_voteCount[a]
|
|
|
|
|
|
|
|
if (iResult >= iRatio)
|
2005-09-12 21:06:24 +00:00
|
|
|
{
|
|
|
|
g_choosed = g_voteSelected[id][a]
|
2007-05-24 18:15:41 +00:00
|
|
|
new tempMap[32];
|
|
|
|
ArrayGetString(g_mapName, g_choosed, tempMap, charsmax(tempMap));
|
|
|
|
client_print(0, print_chat, "%L %s", LANG_PLAYER, "VOTE_SUCCESS", tempMap);
|
|
|
|
log_amx("Vote: %L %s", "en", "VOTE_SUCCESS", tempMap);
|
2005-09-12 21:06:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (g_choosed != -1)
|
|
|
|
{
|
|
|
|
if (is_user_connected(id))
|
|
|
|
{
|
|
|
|
new menuBody[512]
|
2007-05-24 18:15:41 +00:00
|
|
|
new tempMap[32];
|
|
|
|
ArrayGetString(g_mapName, g_choosed, tempMap, charsmax(tempMap));
|
2014-07-29 14:32:32 +00:00
|
|
|
new len = format(menuBody, charsmax(menuBody), g_coloredMenus ? "\y%L: \w%s^n^n" : "%L: %s^n^n", id, "THE_WINNER", tempMap)
|
2005-09-12 21:06:24 +00:00
|
|
|
|
2014-07-29 14:32:32 +00:00
|
|
|
len += format(menuBody[len], charsmax(menuBody) - len, g_coloredMenus ? "\y%L^n\w" : "%L^n", id, "WANT_CONT")
|
|
|
|
format(menuBody[len], charsmax(menuBody) - len, "^n1. %L^n2. %L", id, "YES", id, "NO")
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
show_menu(id, 0x03, menuBody, 10, "The winner: ")
|
|
|
|
set_task(10.0, "autoRefuse", 4545454)
|
|
|
|
} else {
|
|
|
|
new _modName[10]
|
2014-07-29 14:32:32 +00:00
|
|
|
get_modname(_modName, charsmax(_modName))
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
if (!equal(_modName, "zp"))
|
|
|
|
{
|
|
|
|
message_begin(MSG_ALL, SVC_INTERMISSION)
|
|
|
|
message_end()
|
|
|
|
}
|
2007-05-24 18:15:41 +00:00
|
|
|
new tempMap[32];
|
|
|
|
ArrayGetString(g_mapName, g_choosed, tempMap, charsmax(tempMap));
|
|
|
|
set_task(2.0, "delayedChange", 0, tempMap, strlen(tempMap) + 1)
|
2005-09-12 21:06:24 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
client_print(0, print_chat, "%L", LANG_PLAYER, "VOTE_FAILED")
|
|
|
|
log_amx("Vote: %L", "en", "VOTE_FAILED")
|
|
|
|
}
|
|
|
|
|
|
|
|
remove_task(34567 + id)
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
public voteCount(id, key)
|
|
|
|
{
|
|
|
|
if (key > 3)
|
|
|
|
{
|
|
|
|
client_print(0, print_chat, "%L", LANG_PLAYER, "VOT_CANC")
|
|
|
|
remove_task(34567 + id)
|
|
|
|
set_cvar_float("amx_last_voting", get_gametime())
|
|
|
|
log_amx("Vote: Cancel vote session")
|
|
|
|
|
|
|
|
return PLUGIN_HANDLED
|
|
|
|
}
|
|
|
|
|
|
|
|
if (get_cvar_float("amx_vote_answers"))
|
|
|
|
{
|
2014-07-20 10:27:02 +00:00
|
|
|
new name[MAX_NAME_LENGTH]
|
2005-09-12 21:06:24 +00:00
|
|
|
|
2014-07-29 14:32:32 +00:00
|
|
|
get_user_name(id, name, charsmax(name))
|
2005-09-12 21:06:24 +00:00
|
|
|
client_print(0, print_chat, "%L", LANG_PLAYER, "X_VOTED_FOR", name, key + 1)
|
|
|
|
}
|
|
|
|
|
|
|
|
++g_voteCount[key]
|
|
|
|
|
|
|
|
return PLUGIN_HANDLED
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
isMapSelected(id, pos)
|
|
|
|
{
|
|
|
|
for (new a = 0; a < g_voteSelectedNum[id]; ++a)
|
|
|
|
if (g_voteSelected[id][a] == pos)
|
|
|
|
return 1
|
|
|
|
return 0
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
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
|
|
|
|
|
2014-07-29 14:32:32 +00:00
|
|
|
new len = format(menuBody, charsmax(menuBody), 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)))
|
2005-09-12 21:06:24 +00:00
|
|
|
new end = start + 7, keys = MENU_KEY_0
|
|
|
|
|
|
|
|
if (end > g_mapNums)
|
|
|
|
end = g_mapNums
|
|
|
|
|
2007-05-24 18:15:41 +00:00
|
|
|
new tempMap[32];
|
2005-09-12 21:06:24 +00:00
|
|
|
for (new a = start; a < end; ++a)
|
|
|
|
{
|
2007-05-24 18:15:41 +00:00
|
|
|
ArrayGetString(g_mapName, a, tempMap, charsmax(tempMap));
|
2005-09-12 21:06:24 +00:00
|
|
|
if (g_voteSelectedNum[id] == 4 || isMapSelected(id, pos * 7 + b))
|
|
|
|
{
|
|
|
|
++b
|
|
|
|
if (g_coloredMenus)
|
2014-07-29 14:32:32 +00:00
|
|
|
len += format(menuBody[len], charsmax(menuBody) - len, "\d%d. %s^n\w", b, tempMap)
|
2005-09-12 21:06:24 +00:00
|
|
|
else
|
2014-07-29 14:32:32 +00:00
|
|
|
len += format(menuBody[len], charsmax(menuBody) - len, "#. %s^n", tempMap)
|
2005-09-12 21:06:24 +00:00
|
|
|
} else {
|
|
|
|
keys |= (1<<b)
|
2014-07-29 14:32:32 +00:00
|
|
|
len += format(menuBody[len], charsmax(menuBody) - len, "%d. %s^n", ++b, tempMap)
|
2005-09-12 21:06:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_voteSelectedNum[id])
|
|
|
|
{
|
|
|
|
keys |= MENU_KEY_8
|
2014-07-29 14:32:32 +00:00
|
|
|
len += format(menuBody[len], charsmax(menuBody) - len, "^n8. %L^n", id, "START_VOT")
|
2005-09-12 21:06:24 +00:00
|
|
|
}
|
|
|
|
else
|
2014-07-29 14:32:32 +00:00
|
|
|
len += format(menuBody[len], charsmax(menuBody) - len, g_coloredMenus ? "^n\d8. %L^n\w" : "^n#. %L^n", id, "START_VOT")
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
if (end != g_mapNums)
|
|
|
|
{
|
2014-07-29 14:32:32 +00:00
|
|
|
len += format(menuBody[len], charsmax(menuBody) - len, "^n9. %L...^n0. %L^n", id, "MORE", id, pos ? "BACK" : "EXIT")
|
2005-09-12 21:06:24 +00:00
|
|
|
keys |= MENU_KEY_9
|
|
|
|
}
|
|
|
|
else
|
2014-07-29 14:32:32 +00:00
|
|
|
len += format(menuBody[len], charsmax(menuBody) - len, "^n0. %L^n", id, pos ? "BACK" : "EXIT")
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
if (g_voteSelectedNum[id])
|
2014-07-29 14:32:32 +00:00
|
|
|
len += format(menuBody[len], charsmax(menuBody) - len, g_coloredMenus ? "^n\y%L:^n\w" : "^n%L:^n", id, "SEL_MAPS")
|
2005-09-12 21:06:24 +00:00
|
|
|
else
|
2014-07-29 14:32:32 +00:00
|
|
|
len += format(menuBody[len], charsmax(menuBody) - len, "^n^n")
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
for (new c = 0; c < 4; c++)
|
|
|
|
{
|
|
|
|
if (c < g_voteSelectedNum[id])
|
2007-05-24 18:15:41 +00:00
|
|
|
{
|
|
|
|
ArrayGetString(g_mapName, g_voteSelected[id][c], tempMap, charsmax(tempMap));
|
2014-07-29 14:32:32 +00:00
|
|
|
len += format(menuBody[len], charsmax(menuBody) - len, "%s^n", tempMap)
|
2007-05-24 18:15:41 +00:00
|
|
|
}
|
2005-09-12 21:06:24 +00:00
|
|
|
else
|
2014-07-29 14:32:32 +00:00
|
|
|
len += format(menuBody[len], charsmax(menuBody) - len, "^n")
|
2005-09-12 21:06:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
new menuName[64]
|
2014-07-29 14:32:32 +00:00
|
|
|
format(menuName, charsmax(menuName), "%L", "en", "VOTEMAP_MENU")
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
show_menu(id, keys, menuBody, -1, menuName)
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
public cmdVoteMapMenu(id, level, cid)
|
|
|
|
{
|
|
|
|
if (!cmd_access(id, level, cid, 1))
|
|
|
|
return PLUGIN_HANDLED
|
2004-01-31 20:56:22 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
if (get_cvar_float("amx_last_voting") > get_gametime())
|
|
|
|
{
|
|
|
|
client_print(id, print_chat, "%L", id, "ALREADY_VOT")
|
|
|
|
return PLUGIN_HANDLED
|
|
|
|
}
|
2004-01-31 20:56:22 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
g_voteSelectedNum[id] = 0
|
2004-08-05 11:09:16 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
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")
|
|
|
|
}
|
2004-10-05 11:16:27 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
return PLUGIN_HANDLED
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
public cmdMapsMenu(id, level, cid)
|
|
|
|
{
|
|
|
|
if (!cmd_access(id, level, cid, 1))
|
|
|
|
return PLUGIN_HANDLED
|
2004-10-05 11:16:27 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
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")
|
|
|
|
}
|
2004-08-05 11:09:16 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
return PLUGIN_HANDLED
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public delayedChange(mapname[])
|
2005-09-12 21:06:24 +00:00
|
|
|
server_cmd("changelevel %s", mapname)
|
|
|
|
|
|
|
|
public actionVoteMapMenu(id, key)
|
|
|
|
{
|
2007-05-24 18:15:41 +00:00
|
|
|
new tempMap[32];
|
2005-09-12 21:06:24 +00:00
|
|
|
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]
|
2014-07-20 13:15:45 +00:00
|
|
|
new players[32]
|
2005-09-12 21:06:24 +00:00
|
|
|
new pnum, keys, len
|
|
|
|
|
|
|
|
get_players(players, pnum)
|
|
|
|
|
|
|
|
if (g_voteSelectedNum[id] > 1)
|
|
|
|
{
|
2014-07-29 14:32:32 +00:00
|
|
|
len = format(menuBody, charsmax(menuBody), g_coloredMenus ? "\y%L^n\w^n" : "%L^n^n", id, "WHICH_MAP")
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
for (new c = 0; c < g_voteSelectedNum[id]; ++c)
|
|
|
|
{
|
2007-05-24 18:15:41 +00:00
|
|
|
ArrayGetString(g_mapName, g_voteSelected[id][c], tempMap, charsmax(tempMap));
|
2014-07-30 20:43:26 +00:00
|
|
|
len += format(menuBody[len], charsmax(menuBody) - len, "%d. %s^n", c + 1, tempMap)
|
2005-09-12 21:06:24 +00:00
|
|
|
keys |= (1<<c)
|
|
|
|
}
|
|
|
|
|
|
|
|
keys |= (1<<8)
|
2014-07-30 20:43:26 +00:00
|
|
|
len += format(menuBody[len], charsmax(menuBody) - len, "^n9. %L^n", id, "NONE")
|
2005-09-12 21:06:24 +00:00
|
|
|
} else {
|
2007-05-24 18:15:41 +00:00
|
|
|
ArrayGetString(g_mapName, g_voteSelected[id][0], tempMap, charsmax(tempMap));
|
2014-07-29 14:32:32 +00:00
|
|
|
len = format(menuBody, charsmax(menuBody), 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", tempMap, id, "YES", id, "NO")
|
2005-09-12 21:06:24 +00:00
|
|
|
keys = MENU_KEY_1|MENU_KEY_2
|
|
|
|
}
|
|
|
|
|
|
|
|
new menuName[64]
|
2014-07-29 14:32:32 +00:00
|
|
|
format(menuName, charsmax(menuName), "%L", "en", "WHICH_MAP")
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
for (new b = 0; b < pnum; ++b)
|
|
|
|
if (players[b] != id)
|
|
|
|
show_menu(players[b], keys, menuBody, iVoteTime, menuName)
|
|
|
|
|
2014-07-29 14:32:32 +00:00
|
|
|
format(menuBody[len], charsmax(menuBody), "^n0. %L", id, "CANC_VOTE")
|
2005-09-12 21:06:24 +00:00
|
|
|
keys |= MENU_KEY_0
|
|
|
|
show_menu(id, keys, menuBody, iVoteTime, menuName)
|
|
|
|
|
2014-07-20 10:27:02 +00:00
|
|
|
new authid[32], name[MAX_NAME_LENGTH]
|
2005-09-12 21:06:24 +00:00
|
|
|
|
2014-07-29 14:32:32 +00:00
|
|
|
get_user_authid(id, authid, charsmax(authid))
|
|
|
|
get_user_name(id, name, charsmax(name))
|
2005-09-12 21:06:24 +00:00
|
|
|
|
2007-05-24 18:15:41 +00:00
|
|
|
show_activity_key("ADMIN_V_MAP_1", "ADMIN_V_MAP_2", name);
|
|
|
|
|
|
|
|
new tempMapA[32];
|
|
|
|
new tempMapB[32];
|
|
|
|
new tempMapC[32];
|
|
|
|
new tempMapD[32];
|
|
|
|
if (g_voteSelectedNum[id] > 0)
|
2005-09-12 21:06:24 +00:00
|
|
|
{
|
2007-05-24 18:15:41 +00:00
|
|
|
ArrayGetString(g_mapName, g_voteSelected[id][0], tempMapA, charsmax(tempMapA));
|
2005-09-12 21:06:24 +00:00
|
|
|
}
|
2007-05-24 18:15:41 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
copy(tempMapA, charsmax(tempMapA), "");
|
|
|
|
}
|
|
|
|
if (g_voteSelectedNum[id] > 1)
|
|
|
|
{
|
|
|
|
ArrayGetString(g_mapName, g_voteSelected[id][1], tempMapB, charsmax(tempMapB));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
copy(tempMapB, charsmax(tempMapB), "");
|
|
|
|
}
|
|
|
|
if (g_voteSelectedNum[id] > 2)
|
|
|
|
{
|
|
|
|
ArrayGetString(g_mapName, g_voteSelected[id][2], tempMapC, charsmax(tempMapC));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
copy(tempMapC, charsmax(tempMapC), "");
|
|
|
|
}
|
|
|
|
if (g_voteSelectedNum[id] > 3)
|
|
|
|
{
|
|
|
|
ArrayGetString(g_mapName, g_voteSelected[id][3], tempMapD, charsmax(tempMapD));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
copy(tempMapD, charsmax(tempMapD), "");
|
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
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,
|
2007-05-24 18:15:41 +00:00
|
|
|
tempMapA, tempMapB, tempMapC, tempMapD)
|
2005-09-12 21:06:24 +00:00
|
|
|
}
|
|
|
|
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
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
public actionMapsMenu(id, key)
|
|
|
|
{
|
|
|
|
switch (key)
|
|
|
|
{
|
|
|
|
case 8: displayMapsMenu(id, ++g_menuPosition[id])
|
|
|
|
case 9: displayMapsMenu(id, --g_menuPosition[id])
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
new a = g_menuPosition[id] * 8 + key
|
|
|
|
new _modName[10]
|
|
|
|
|
2014-07-29 14:32:32 +00:00
|
|
|
get_modname(_modName, charsmax(_modName))
|
2005-09-12 21:06:24 +00:00
|
|
|
if (!equal(_modName, "zp"))
|
|
|
|
{
|
|
|
|
message_begin(MSG_ALL, SVC_INTERMISSION)
|
|
|
|
message_end()
|
|
|
|
}
|
|
|
|
|
2014-07-20 10:27:02 +00:00
|
|
|
new authid[32], name[MAX_NAME_LENGTH]
|
2005-09-12 21:06:24 +00:00
|
|
|
|
2014-07-29 14:32:32 +00:00
|
|
|
get_user_authid(id, authid, charsmax(authid))
|
|
|
|
get_user_name(id, name, charsmax(name))
|
2005-09-12 21:06:24 +00:00
|
|
|
|
2007-05-24 18:15:41 +00:00
|
|
|
new tempMap[32];
|
|
|
|
ArrayGetString(g_mapName, a, tempMap, charsmax(tempMap));
|
|
|
|
|
|
|
|
show_activity_key("ADMIN_CHANGEL_1", "ADMIN_CHANGEL_2", name, tempMap);
|
2005-09-12 21:06:24 +00:00
|
|
|
|
2007-05-24 18:15:41 +00:00
|
|
|
log_amx("Cmd: ^"%s<%d><%s><>^" changelevel ^"%s^"", name, get_user_userid(id), authid, tempMap)
|
|
|
|
set_task(2.0, "delayedChange", 0, tempMap, strlen(tempMap) + 1)
|
2005-09-12 21:06:24 +00:00
|
|
|
/* displayMapsMenu(id, g_menuPosition[id]) */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return PLUGIN_HANDLED
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
displayMapsMenu(id, pos)
|
|
|
|
{
|
|
|
|
if (pos < 0)
|
|
|
|
return
|
2004-08-05 11:09:16 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
new menuBody[512]
|
2007-05-24 18:15:41 +00:00
|
|
|
new tempMap[32]
|
2005-09-12 21:06:24 +00:00
|
|
|
new start = pos * 8
|
|
|
|
new b = 0
|
2004-08-05 11:09:16 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
if (start >= g_mapNums)
|
|
|
|
start = pos = g_menuPosition[id] = 0
|
2004-08-05 11:09:16 +00:00
|
|
|
|
2014-07-29 14:32:32 +00:00
|
|
|
new len = format(menuBody, charsmax(menuBody), g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "CHANGLE_MENU", pos + 1, (g_mapNums / 8 + ((g_mapNums % 8) ? 1 : 0)))
|
2005-09-12 21:06:24 +00:00
|
|
|
new end = start + 8
|
|
|
|
new keys = MENU_KEY_0
|
2004-08-05 11:09:16 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
if (end > g_mapNums)
|
|
|
|
end = g_mapNums
|
2004-08-05 11:09:16 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
for (new a = start; a < end; ++a)
|
|
|
|
{
|
|
|
|
keys |= (1<<b)
|
2007-05-24 18:15:41 +00:00
|
|
|
ArrayGetString(g_mapName, a, tempMap, charsmax(tempMap));
|
2014-07-29 14:32:32 +00:00
|
|
|
len += format(menuBody[len], charsmax(menuBody) - len, "%d. %s^n", ++b, tempMap)
|
2005-09-12 21:06:24 +00:00
|
|
|
}
|
2004-08-05 11:09:16 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
if (end != g_mapNums)
|
|
|
|
{
|
2014-07-29 14:32:32 +00:00
|
|
|
format(menuBody[len], charsmax(menuBody) - len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
|
2005-09-12 21:06:24 +00:00
|
|
|
keys |= MENU_KEY_9
|
|
|
|
}
|
|
|
|
else
|
2014-07-29 14:32:32 +00:00
|
|
|
format(menuBody[len], charsmax(menuBody) - len, "^n0. %L", id, pos ? "BACK" : "EXIT")
|
2004-08-05 11:09:16 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
new menuName[64]
|
|
|
|
format(menuName, 63, "%L", "en", "CHANGLE_MENU")
|
2004-08-05 11:09:16 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
show_menu(id, keys, menuBody, -1, menuName)
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
2007-05-24 18:15:41 +00:00
|
|
|
stock bool:ValidMap(mapname[])
|
|
|
|
{
|
|
|
|
if ( is_map_valid(mapname) )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// If the is_map_valid check failed, check the end of the string
|
|
|
|
new len = strlen(mapname) - 4;
|
|
|
|
|
|
|
|
// The mapname was too short to possibly house the .bsp extension
|
|
|
|
if (len < 0)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if ( equali(mapname[len], ".bsp") )
|
|
|
|
{
|
|
|
|
// If the ending was .bsp, then cut it off.
|
|
|
|
// the string is byref'ed, so this copies back to the loaded text.
|
|
|
|
mapname[len] = '^0';
|
|
|
|
|
|
|
|
// recheck
|
|
|
|
if ( is_map_valid(mapname) )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2004-01-31 20:56:22 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
load_settings(filename[])
|
|
|
|
{
|
2007-05-24 18:15:41 +00:00
|
|
|
new fp = fopen(filename, "r");
|
|
|
|
|
|
|
|
if (!fp)
|
2005-09-12 21:06:24 +00:00
|
|
|
{
|
2007-05-24 18:15:41 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-08-05 11:09:16 +00:00
|
|
|
|
2007-05-24 18:15:41 +00:00
|
|
|
new text[256];
|
|
|
|
new tempMap[32];
|
|
|
|
|
|
|
|
while (!feof(fp))
|
|
|
|
{
|
|
|
|
fgets(fp, text, charsmax(text));
|
|
|
|
|
|
|
|
if (text[0] == ';')
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (parse(text, tempMap, charsmax(tempMap)) < 1)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!ValidMap(tempMap))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ArrayPushString(g_mapName, tempMap);
|
|
|
|
g_mapNums++;
|
2005-09-12 21:06:24 +00:00
|
|
|
}
|
2004-08-05 11:09:16 +00:00
|
|
|
|
2010-04-27 07:40:38 +00:00
|
|
|
fclose(fp);
|
|
|
|
|
2007-05-24 18:15:41 +00:00
|
|
|
return 1;
|
2004-09-19 00:37:58 +00:00
|
|
|
}
|