Code:
#include <amxmodx>
#define HP_TASK 543221588
new HappyHourStart,HappyHourStop,maxplayers,HappyHour;
new bool:is_happy_hour;
new Float:HP_RATE,cvar_hp_rate
new szFlags[ 33 ];
public plugin_init()
{
HappyHour = register_cvar("happy_hour", "1")
HappyHourStart = register_cvar("happy_hour_start", "21.00")
HappyHourStop = register_cvar("happy_hour_end", "11.00")
cvar_hp_rate = register_cvar("happy_hour_rate","10.0")
HappyHourCheck(HP_TASK)
update_cvars()
maxplayers = get_maxplayers();
}
public update_cvars()
{
HP_RATE = get_pcvar_float(cvar_hp_rate)
}
public HappyHourCheck(taskid)
{
if(get_pcvar_num(HappyHour) == 1)
{
is_happy_hour = true;
}
else if(get_pcvar_num(HappyHour) == 0)
{
is_happy_hour = false;
}
new data[3]
get_time("%H", data, 2)
new Hours = str_to_num(data) //time(Hours);
new BeginHour = get_pcvar_num(HappyHourStart);
new EndHour = get_pcvar_num(HappyHourStop);
if(BeginHour == EndHour || EndHour == Hours)
{
is_happy_hour = false;
}
else if( EndHour> Hours >= BeginHour)
{
is_happy_hour = true;
}
else
{
is_happy_hour = false;
}
if(is_happy_hour)
{
for(new id;id < maxplayers;id++)
{
set_user_flags(id, read_flags("abcdefghijklmnopqrstu"))
//client_print(0,print_console,"DEBUG: TEXT SET (TRUE)")
}
}
else
{
for(new id;id < maxplayers;id++)
{
szFlags[ id ] = get_user_flags( id );
remove_user_flags( id );
//client_print(0,print_console,"DEBUG: TEXT SET (FALSE)")
}
}
set_task(HP_RATE,"HappyHourCheck",HP_TASK)
}