I loved the old mapchooser OLO had where you could define the votes...
This was really useful for custom days we had on our server, would anyone be kind enough to make a new plugin that allowed you to define all the votes (then the script selects one of the vote options at random rather than random maps!)
Code:
/* AMX Mod script.
*
* (c) Copyright 2002-2003, OLO
* This file is provided as is (no warranties).
*
*/
#include <amxmod>
#include <amxmisc>
/*
* On two minutes before the timelimit plugin
* displays menu with 5 random maps to select.
* One of the options is also map extending.
* Map with most votes becomes the nextmap.
*
* Maps to selected are entered by amx_nextmapch server command:
* amx_nextmapch <mapname> ...
*
* Cvars:
* amx_extendmap_max <time in mins.> - max. time for overall extending
* amx_extendmap_step <time in mins.> - with what time the map will be extended
*
* You can specify the map list f.e. in admin.cfg like
amx_nextmapch de_dust de_dust2 de_vegas de_storm de_nuke de_aztec
amx_nextmapch cs_militia de_prodigy cs_office de_piranesi
amx_nextmapch cs_italy de_cbble de_torn de_survivor cs_747 cs_assault
amx_nextmapch de_chateau cs_backalley cs_havana cs_thunder de_vertigo
*
* NOTE: Nextmap plugin is required for proper working of this plugin.
* Command amx_nextmapch can accept more than one map in command line.
*/
#define MAX_MAPS_AMOUNT 128
#define MAPS_TO_SELECET 5
new nmaps[MAX_MAPS_AMOUNT][32]
new nmaps_num
new bool:cstrike_running
new nnextmaps[MAPS_TO_SELECET]
new nvotes[MAPS_TO_SELECET+2]
new nmapstoch
new bool:mselected = false
new logfilename[256]
new teamscore[2]
new last_map[32]
public check_votes(){
new b = 0
for(new a = 0; a < nmapstoch; ++a)
if (nvotes[b] < nvotes[a])
b = a
if ( nvotes[MAPS_TO_SELECET] > nvotes[b] ) {
new mapname[32]
get_mapname(mapname,31)
new Float:steptime = get_cvar_float("amx_extendmap_step")
set_cvar_float("mp_timelimit", get_cvar_float("mp_timelimit") + steptime )
client_print(0,print_chat,"* Choosing finished. Current map will be extended to next %.0f minutes", steptime )
log_to_file(logfilename,"Vote: Voting for the nextmap finished. Map %s will be extended to next %.0f minutes",
mapname , steptime )
return PLUGIN_HANDLED
}
if ( nvotes[b] && nvotes[MAPS_TO_SELECET+1] <= nvotes[b] )
set_cvar_string("amx_nextmap", nmaps[nnextmaps[b]] )
new smap[32]
get_cvar_string("amx_nextmap",smap,31)
client_print(0,print_chat,"* Choosing finished. The nextmap will be %s", smap )
log_to_file(logfilename,"Vote: Voting for the nextmap finished. The nextmap will be %s", smap)
return PLUGIN_HANDLED
}
public vote_count(id,key){
if ( get_cvar_float("amx_vote_answers") ) {
new name[32]
get_user_name(id,name,31)
if ( key == MAPS_TO_SELECET )
client_print(0,print_chat,"* %s chose map extending", name )
else if ( key < MAPS_TO_SELECET )
client_print(0,print_chat,"* %s chose %s", name, nmaps[nnextmaps[key]] )
}
++nvotes[key]
return PLUGIN_HANDLED
}
bool:isinmenu(id){
for(new a=0; a<nmapstoch; ++a)
if (id==nnextmaps[a])
return true
return false
}
public askfornextmap(){
if (nmaps_num == 0){
remove_task(987456)
return PLUGIN_HANDLED
}
new mp_winlimit = get_cvar_num("mp_winlimit")
if (mp_winlimit){
if ((mp_winlimit - 2) > (teamscore[0] + teamscore[1])){
mselected = false
return PLUGIN_HANDLED
}
}
else {
new timeleft = get_timeleft()
if (timeleft<1||timeleft>129){
mselected = false
return PLUGIN_HANDLED
}
}
if (mselected)
return PLUGIN_HANDLED
mselected = true
new menu[512], a, mkeys = (1<<MAPS_TO_SELECET+1)
new pos = copy(menu,511,cstrike_running ? "\yAMX Choose nextmap:\w^n^n" : "AMX Choose nextmap:^n^n")
new dmax = (nmaps_num > MAPS_TO_SELECET) ? MAPS_TO_SELECET : nmaps_num
for(nmapstoch = 0;nmapstoch<dmax;++nmapstoch){
a=random_num(0,nmaps_num-1)
while( isinmenu(a) )
if (++a >= nmaps_num) a = 0
nnextmaps[nmapstoch] = a
pos += format(menu[pos],511,"%d. %s^n",nmapstoch+1,nmaps[a])
mkeys |= (1<<nmapstoch)
nvotes[nmapstoch] = 0
}
menu[pos++]='^n'
nvotes[MAPS_TO_SELECET] = 0
nvotes[MAPS_TO_SELECET+1] = 0
new mapname[32]
get_mapname(mapname,31)
if (!mp_winlimit && get_cvar_float("mp_timelimit") < get_cvar_float("amx_extendmap_max")){
pos += format(menu[pos],511,"%d. Extend map %s^n",MAPS_TO_SELECET+1,mapname)
mkeys |= (1<<MAPS_TO_SELECET)
}
format(menu[pos],511,"%d. None",MAPS_TO_SELECET+2)
show_menu(0,mkeys,menu,15)
set_task(15.0,"check_votes")
client_print(0,print_chat,"* It's time to choose the nextmap...")
client_cmd(0,"spk Gman/Gman_Choose2")
log_to_file(logfilename,"Vote: Voting for the nextmap started")
return PLUGIN_HANDLED
}
public addmaptolist(id,level,cid){
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
new arg[32], argcl = read_argc()
new current_map[32]
get_mapname(current_map,31)
for(new a = 1; a < argcl; ++a){
read_argv(a,arg,31)
if (is_map_valid(arg)){
if (equali(arg,current_map) || equali(arg,last_map))
continue
for(new i = 0; i < nmaps_num; ++i)
if (equali(arg,nmaps[i])){
console_print(id,"Map ^"%s^" is already in list",arg)
return PLUGIN_HANDLED
}
copy(nmaps[nmaps_num++],31,arg)
}
else
console_print(id,"Map ^"%s^" not found or is invalid",arg)
}
return PLUGIN_HANDLED
}
public team_score(){
new team[2]
read_data(1,team,1)
teamscore[ (team[0]=='C') ? 0 : 1 ] = read_data(2)
return PLUGIN_CONTINUE
}
public plugin_end(){
new current_map[32]
get_mapname(current_map,31)
set_localinfo("amx_lastmap",current_map)
return PLUGIN_CONTINUE
}
public plugin_init(){
register_plugin("Nextmap chooser","0.9.2","default")
register_srvcmd("amx_nextmapch","addmaptolist",0,"<mapname> ...")
register_menucmd(register_menuid("AMX Choose nextmap:"),(-1^(-1<<(MAPS_TO_SELECET+2))),"vote_count")
register_cvar("amx_extendmap_max","90")
register_cvar("amx_extendmap_step","15")
new mod_name[32]
get_modname(mod_name,31)
cstrike_running = equal(mod_name,"cstrike") ? true : false
if (cstrike_running)
register_event("TeamScore", "team_score", "a")
set_task(15.0,"askfornextmap",987456,"",0,"b")
get_time("addons/amx/logs/admin%m%d.log",logfilename,255)
get_localinfo("amx_lastmap",last_map,31)
set_localinfo("amx_lastmap","")
return PLUGIN_CONTINUE
}