Hi. I was searching for a plugin which on the end of map will start vote for map extending. I found OLO's plugin on AMX mod official forum, but unfortunately it does not work with AMXX. Could someone look at this and correct it or something?
It would be great. Here's the plugin code:
Code:
/* AMX Mod script.
*
* (c) Copyright 2002, OLO
* This file is provided as is (no warranties).
*
*/
#include <amxmod>
/* cvars:
* max. time on which map can be extended (there will be always min. one vote)
* amx_extendmap_max < value >
*
* when voting is successful set how much time we want play
* amx_extendmap_step < value >
*/
new gShowVote = 1
new gVotes
new bool:cstrike_running
new logfilename[256]
public check_votes(){
new players[32], inum
get_players(players,inum,"c")
new Float:step_time = get_cvar_float("amx_extendmap_step")
new Float:mp_time = get_cvar_float("mp_timelimit")
new Float:vote_ratio = get_cvar_float("amx_extendmap_ratio")
new Float:result_v = inum ? (float(gVotes) / float(inum)) : 0.0
if (result_v >= vote_ratio) {
client_print(0,print_chat,"* Voting successful. Map will be extended to next %.0f minutes",step_time)
log_to_file(logfilename,"Vote: Voting for the map extending successful (ratio ^"%.2f^") (needed ^"%.2f^") (time ^"%.0f^")",
result_v,vote_ratio,step_time)
new Float:new_time = mp_time + step_time
set_cvar_float("mp_timelimit",new_time)
if (new_time < get_cvar_float("amx_extendmap_max") )
gShowVote = 1
else
remove_task(7777)
}
else {
remove_task(7777)
client_print(0,print_chat,"* Voting failed. Map won't be extended")
log_to_file(logfilename,"Vote: Voting for the map extending failed (ratio ^"%.2f^") (needed ^"%.2f^")",
result_v, vote_ratio)
}
return PLUGIN_HANDLED
}
public vote_count(id,key){
if (get_cvar_float("amx_vote_answers")) {
new name[32]
get_user_name(id,name,31)
client_print(0,print_chat,"* %s voted %s extending",name,key ? "against" : "for")
}
if (!key) ++gVotes
return PLUGIN_HANDLED
}
public vote_extend(){
new timeleft = get_timeleft()
if (gShowVote&&(timeleft>0)&&(timeleft<120)){
gShowVote = 0
gVotes = 0
new mapname[64]
get_mapname(mapname,63)
new menu[256]
if (cstrike_running)
format(menu,255,"\yAMX Extend map %s?\w^n^n1. Yes^n2. No",mapname)
else
format(menu,255,"AMX Extend map %s?^n^n1. Yes^n2. No",mapname)
show_menu(0,(1<<0)|(1<<1),menu,10)
set_task(10.0,"check_votes")
client_cmd(0,"spk Gman/Gman_Choose2")
client_print(0,print_chat,"* Voting for the map extending started...")
log_to_file(logfilename,"Vote: Voting for the map extending started (map ^"%s^")",mapname)
}
return PLUGIN_HANDLED
}
public plugin_init(){
register_plugin("Map Extend Vote","1.0","default")
register_menucmd(register_menuid("AMX Extend map "),(1<<0)|(1<<1),"vote_count")
register_cvar("amx_extendmap_ratio","0.4")
register_cvar("amx_extendmap_max","90")
register_cvar("amx_extendmap_step","15")
register_cvar("amx_vote_answers","0")
set_task(10.0,"