Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #define PLUGIN "Menu Vote map"
- #define VERSION "1.0"
- #define AUTHOR "Sugisaki"
- #define MAX_MAPS 15
- #define MAXVOTE 8
- #define ADMIN_ACCESS ADMIN_MAP
- #define FILENAME "listmap"
- new g_test[MAX_MAPS][32], g_count[MAX_MAPS], bool:blockmenu, mapwin, bool:plaver_vote[33 char], last_playervote[33 char]
- public plugin_init()
- {
- register_plugin(PLUGIN, VERSION, AUTHOR)
- register_clcmd("say /votemap", "fw_votemap")
- register_concmd("amx_reloadmaps", "fw_reloadmaps")
- load_file()
- blockmenu = false
- }
- load_file()
- {
- new path[38]
- get_localinfo("amxx_configsdir",path,charsmax(path))
- formatex(path, charsmax(path), "%s/%s.txt", path, FILENAME)
- if(!file_exists(path))
- {
- write_file(path, "; Tus mapas aqui abajo")
- }
- new linedata[32], line
- new file = fopen(path, "rt")
- while (!feof(file))
- {
- fgets(file, linedata, charsmax(linedata))
- replace(linedata, charsmax(linedata), "^n", "")
- if (linedata[0] == ';' || !linedata[0]) continue
- g_test[line] = linedata
- line++
- }
- fclose(file)
- }
- public fw_votemap(id)
- {
- if(blockmenu)
- {
- client_print(id, print_chat, "[AMXX] Se ha elegido el mapa %s, no puedes abrir el menu de votos.", g_test[mapwin])
- return
- }
- new menu = menu_create("\rVote Menu", "Handler")
- new temp[sizeof g_test[]]
- for(new i = 0 ; i < sizeof g_test ; i++)
- {
- if(equal(g_test[i], "")) continue
- formatex(temp, charsmax(temp), "%s [%i | %i]", g_test[i], g_count[i], MAXVOTE)
- menu_additem(menu, temp)
- }
- menu_setprop(menu, MPROP_EXITNAME, "Salir")
- menu_setprop(menu, MPROP_BACKNAME, "Atras")
- menu_setprop(menu, MPROP_NEXTNAME, "Siguiente")
- menu_display(id, menu)
- }
- public Handler(id, menu, item)
- {
- if(item == MENU_EXIT)
- {
- menu_cancel(id)
- return PLUGIN_HANDLED
- }
- if(plaver_vote[id])
- {
- if(item == last_playervote[id])
- {
- client_print(id, print_chat, "[AMXX] Ya has votado por este mapa.")
- return PLUGIN_HANDLED
- }
- else
- {
- g_count[last_playervote[id]] --
- client_print(id, print_chat, "[AMXX] Se ha eliminado tu anterior voto hecho por %s.", g_test[item])
- }
- }
- new name[32]
- get_user_name(id, name, 31)
- client_print(0, print_chat, "[AMXX] %s Hizo un voto por %s.", name, g_test[item])
- g_count[item]++
- plaver_vote[id] = true
- last_playervote[id] = item
- if(g_count[item] == MAXVOTE)
- {
- blockmenu = true
- set_task(5.0, "changelevel", _, g_test[item], charsmax(g_test[]))
- mapwin = item
- client_print(0, print_chat, "[AMXX] Mapa se cambiara a %s", g_test[item])
- }
- menu_destroy(menu)
- return PLUGIN_HANDLED
- }
- public fw_reloadmaps(id)
- {
- if(!(get_user_flags(id) & ADMIN_ACCESS))
- {
- console_print(id, "[AMXX] No tienes acceso a este comando")
- return PLUGIN_HANDLED
- }
- load_file()
- console_print(id, "[AMXX] Lista de mapas recarga")
- return PLUGIN_HANDLED
- }
- public changelevel(map[])
- {
- server_cmd("changelevel %s", map)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement