I noticed some error in my code, and also documented it
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");
// Catches when someone says anything
register_clcmd("say","Hook_Say");
// cvars
register_cvar("amx_extend","1");
register_cvar("amx_extend_votes","5");
// sets task for checking timeleft
set_task(5.0,"check_tl");
}
public Hook_Say(id)
{
// if extend off, stop
if(!get_cvar_num("amx_extend"))
return 0;
// reads what the person said
new arg[128];
read_argv(1,arg,127);
// 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;
// place your voting stuff here
// whatever vote stuff
}
else
{
// if that stuff above doesn't happen, then check again in 5 seconds
set_task(5.0,"check_tl");
}
return 0;
}
__________________