/* Plugin generated by AMXX-Studio */ #include #include #define PLUGIN "AlMod's VoteMap" #define VERSION "1.2" #define AUTHOR "AlMod" #define MAXMAPS 300 #define MAXPLAYERS 32 #define MINPLAYERS 2 #define BAD_MAP -1 #define MAPPERPAGE 20 #define CHANGEMAPTASK 23495 new g_Mod, c_Mod, Float:g_Ratio, c_Ratio new g_MapList[MAXMAPS+1][32] new g_Votes[MAXMAPS+1] new g_Total = 0 new g_VotedFor[MAXPLAYERS+1] = 0 new g_WinMap[32] new g_IsCstrike public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) c_Mod = register_cvar("sv_votemap","1") c_Ratio = register_cvar("vm_ratio","0.6") // of 5 for example register_clcmd("say","on_say1") register_clcmd("say_team","on_say1") register_clcmd("say","on_say2") register_clcmd("say_team","on_say2") g_IsCstrike = cstrike_running() } public plugin_cfg() { get_settings() get_maplist() } public client_connect(id) { g_VotedFor[id] = 0 } public client_disconnect(id) { if (g_VotedFor[id]!=0) { new imap = g_VotedFor[id] g_Votes[imap]-- } } public get_settings() { g_Mod = get_pcvar_num(c_Mod) g_Ratio = get_pcvar_float(c_Ratio) } public get_maplist() { if (!g_Mod) return new config[32], file[64] get_configsdir(config, 31 ) format(file, 63, "%s\maplist.ini", config) g_Total = 0 if (file_exists(file) && file_size(file)!=0) { new Data[124], len new line = 0 new map[32] while(g_Total < MAXMAPS+1 && (line = read_file(file , line , Data , 123 , len) ) != 0 ) { if (strlen(Data)<2 || Data[0] == '[') continue parse(Data, map, 31) g_MapList[g_Total] = map g_Votes[g_Total] = 0 g_Total++ } server_cmd("echo ^"* [VOTEMAP] %d maps loaded^"",g_Total) } else { server_cmd("echo ^"* [VOTEMAP] No maps found^"") } } public show_maplist_html(id,page) { new in = page-1 new start = MAPPERPAGE*in new total = get_pages_num() new MapMOTDList[3072] new forindex new mapinfo[64] new msg[128] if (page*MAPPERPAGEg_Total) { forindex = g_Total } else { forindex = g_Total - MAPPERPAGE } } add(MapMOTDList,sizeof(MapMOTDList)-1,"Maps List
")
	format(msg,sizeof(msg)-1,"

Maps List [%d/%d]


^nVotes to change map: %d
^n",page,total,get_player_ratio()) add(MapMOTDList,sizeof(MapMOTDList)-1,msg) for (new i=0;i",start+i+1,g_MapList[start+i],g_Votes[start+i]) add(MapMOTDList,sizeof(MapMOTDList)-1,mapinfo) } if (page!=total) { format(msg,sizeof(msg)-1,"^n

Type /maps%d for more...",page+1) add(MapMOTDList,sizeof(MapMOTDList)-1,msg) } add(MapMOTDList,2047,"
") show_motd(id,MapMOTDList,"Maps List") } public show_maplist(id,page) { new in = page-1 new start = MAPPERPAGE*in new total = get_pages_num() new MapMOTDList[3072] new forindex new mapinfo[64] new msg[128] if (page*MAPPERPAGEg_Total) { forindex = g_Total } else { forindex = g_Total - MAPPERPAGE } } format(msg,sizeof(msg)-1,"Maps List [%d/%d]^n^nVotes to change map: %d^n^n",page,total,get_player_ratio()) add(MapMOTDList,sizeof(MapMOTDList)-1,msg) for (new i=0;i=g_Ratio) { client_print(0,print_chat,"* [VOTEMAP] Map '%s' wins! (%d votes)",map,g_Votes[imap]) server_cmd("echo ^"* [VOTEMAP] Map '%s' wins! (%d votes)^"",map,g_Votes[imap]) g_WinMap = map set_task(3.0,"change_map",CHANGEMAPTASK) } } else { client_print(id,print_chat,"* [VOTEMAP] Map '%s' is not found",map) } } else { if (strlen(map)==0) { client_print(id,print_chat,"* [VOTEMAP] Usage: /votemap ") client_print(id,print_chat,"* [VOTEMAP] Full maps list you can get with /maps") } else { client_print(id,print_chat,"* [VOTEMAP] Map '%s' is not found",map) } } } return PLUGIN_CONTINUE } public on_say2(id) { if (!g_Mod) return PLUGIN_CONTINUE new msg[192], name[32] get_user_name(id,name,sizeof(name)-1) read_args(msg, sizeof(msg)-1) remove_quotes(msg) if (containi(msg,"/maps")!=-1) { new page new total = get_pages_num() replace(msg,sizeof(msg)-1,"/maps","") if (strlen(msg)!=0) { page = str_to_num(msg) } else { page = 1 } if (page>total) { page = total } if (g_IsCstrike) { show_maplist_html(id,page) } else { show_maplist(id,page) } } return PLUGIN_CONTINUE } public find_map(const map[]) { for (new i=0;i