I want to make it announce the time every 15 minutes instead of each hour.
Code:
/* AMX Mod X
* Time announcer
*/
#include <amxmodx>
//#define USE_24_HOURS
new g_str_hour[4];
new g_str_min[4];
new g_hour;
new g_min;
new bool:g_PM;
public plugin_precache()
{
precache_model("models/player/smurf/smurf.mdl")
}
public plugin_init()
{
register_plugin("Time announcer", "1.1", "BMJ");
set_task(60.0, "check_time", 0, "", 0, "b");
register_clcmd("say thetime", "say_time");
}
public say_time(id)
{
get_time("%M", g_str_min, 3);
g_min = str_to_num(g_str_min);
get_time("%H", g_str_hour, 3);
g_hour = str_to_num(g_str_hour);
#if !defined USE_24_HOURS
if (g_hour > 12)
{
g_hour -= 12;
g_PM = true;
}
else if (g_hour == 12)
g_PM = true;
else if (g_hour == 0)
{
g_hour = 12;
g_PM = false;
}
else
g_PM = false;
set_hudmessage(0, 100, 255, -1.0, 0.2, 0, 0.0, 3.0, 0.5, 1.0, 2);
show_hudmessage(id, "The time is now:");
set_hudmessage(255, 255, 255, -1.0, 0.24, 0, 0.0, 3.0, 0.5, 1.0, 3);
show_hudmessage(id, "%i:%s %s", g_hour, g_str_min, g_PM ? "PM" : "AM");
#else
set_hudmessage(0, 100, 255, -1.0, 0.2, 0, 0.0, 3.0, 0.5, 1.0, 2);
show_hudmessage(id, "The time is now:");
set_hudmessage(255, 255, 255, -1.0, 0.24, 0, 0.0, 3.0, 0.5, 1.0, 3);
show_hudmessage(id, "%i:%s", g_hour, g_str_min);
#endif
}
public check_time()
{
get_time("%M", g_str_min, 3);
g_min = str_to_num(g_str_min);
if (g_min == 0)
{
get_time("%H", g_str_hour, 3);
g_hour = str_to_num(g_str_hour);
#if !defined USE_24_HOURS
if (g_hour > 12)
{
g_hour -= 12;
g_PM = true;
}
else if (g_hour == 12)
g_PM = true;
else if (g_hour == 0)
{
g_hour = 12;
g_PM = false;
}
else
g_PM = false;
set_hudmessage(0, 100, 255, -1.0, 0.2, 0, 0.0, 3.0, 0.5, 1.0, 2);
show_hudmessage(0, "The time is now:");
set_hudmessage(255, 255, 255, -1.0, 0.24, 0, 0.0, 3.0, 0.5, 1.0, 3);
show_hudmessage(0, "%i:%s %s", g_hour, g_str_min, g_PM ? "PM" : "AM");
if (get_cvar_num("amx_time_voice"))
{
new whour[32];
num_to_word(g_hour, whour, 31);
new wmin[32];
num_to_word(g_min, wmin, 31);
new wpm[] = "pm";
if (!g_PM) wpm[0] = 'a';
client_cmd(0, "spk ^"fvox/bell time_is_now %s %s %s^"", whour, (g_min > 9) ? wmin : "", wpm);
}
#else
set_hudmessage(0, 100, 255, -1.0, 0.2, 0, 0.0, 3.0, 0.5, 1.0, 2);
show_hudmessage(0, "The time is now:");
set_hudmessage(255, 255, 255, -1.0, 0.24, 0, 0.0, 3.0, 0.5, 1.0, 3);
show_hudmessage(0, "%i:%s", g_hour, g_str_min);
if (get_cvar_num("amx_time_voice"))
{
new whour[32];
num_to_word(g_hour, whour, 31);
new wmin[32];
num_to_word(g_min, wmin, 31);
client_cmd(0, "spk ^"fvox/bell time_is_now %s %s^"", whour, (g_min > 9) ? wmin : "");
}
#endif
}
}