Code:
#include <amxmodx>
// Stores the amount of votes
new votes;
// Tells whether or not timeleft thing has already been done
new bool:switchy;
public plugin_init()
{
register_plugin("NS Combat Extender","1.0","semaja2 and Hawk552");
// Catches when someone says anything
register_clcmd("say","Hook_Say");
// cvars
register_cvar("amx_extend","1");
register_cvar("amx_extend_votes","5");
register_cvar("amx_extend_checktime", "5");
register_cvar("amx_extend_time","5");
// sets task for checking timeleft
set_task(get_cvar_float ( "amx_extend_time" ),"check_tl");
}
public Hook_Say(id)
{
// if extend off, stop
if(!get_cvar_num("amx_extend") || get_timeleft() > get_cvar_num("amx_extend_time"))
return 0;
// reads what the person said
new arg[128];
read_argv(1,arg,127);
client_print(id,print_chat,arg);
// if it contains "extend", increase votes
if(containi(arg,"extend") != -1)
votes++;
client_print(id,print_chat,"You have voted to extend the map.");
return 0;
}
public check_tl()
{
if(!get_cvar_num("amx_extend") || switchy)
return 0;
// get timeleft
new timeleft = get_timeleft();
if(timeleft <= 300 && votes >= get_cvar_num("amx_extend_votes"))
{
// timeleft stuff said now
switchy = true;
//cmds to extend
new maptime = get_cvar_num ( "mp_timeleft" )
set_cvar_num ( "mp_timeleft" , maptime+10 )
}
else
{
// if that stuff above doesn't happen, then check again in 5 seconds
set_task(get_cvar_float ( "amx_extend_checktime" ),"check_tl");
}
return 0;
}