Quote:
Originally Posted by ComedyShotsGamer
Someone?
|
At the top of the plugin add:
In public plugin_init() function add:
PHP Code:
g_gmtvalue = register_cvar("amx_gmtzone", "2")
And Finally replace saythetime function with this:
PHP Code:
public sayTheTime(id)
{
new shours[6], sday[6]
get_time("%H", shours, 5)
get_time("%d", sday, 5)
new hrs = str_to_num(shours) + get_pcvar_num(g_gmtvalue);
new day = str_to_num(sday);
if(hrs>=24){
hrs-=24
day++
}
else
{
if(hrs<0){
hrs=24+hrs;
day--;
}
}
formatex(shours, 5, "%s%d", hrs > 9 ? "" : "0")
formatex(sday, 5, "%s%d", day > 9 ? "" : "0")
if (get_cvar_num("amx_time_voice"))
{
new mhours[6], mmins[6], whours[32], wmins[32], wpm[6]
get_time("%H", mhours, 5)
get_time("%M", mmins, 5)
new mins = str_to_num(mmins)
new hrs = str_to_num(mhours)
if (mins)
num_to_word(mins, wmins, 31)
else
wmins[0] = 0
if (hrs < 12)
wpm = "am "
else
{
if (hrs > 12) hrs -= 12
wpm = "pm "
}
if (hrs)
num_to_word(hrs, whours, 31)
else
whours = "twelve "
client_cmd(id, "spk ^"fvox/time_is_now %s_period %s%s^"", whours, wmins, wpm)
}
new ctime[64];
get_time("%m/x/%Y - x:%M:%S", ctime, 63)
replace( ctime, 63, "x", sday )
replace( ctime, 63, "x", shours )
client_print(0, print_chat, "[AMXX] %L: %s", LANG_PLAYER, "THE_TIME", ctime)
return PLUGIN_CONTINUE
}
But one more thing that i can't make.
For example if time is 23 and you have gmt cvar set to 2, then the date should be tomorrow. But if server date is 30 april and tomorrow is 1 may then it will add 30+1 and it will be 31 april which is not correct...
I cant fix it because i don't know how to determine when it's 30 and when it's 31, i know that february once in 4 years is 28 days and then is 29, but don't know how to calculate.
The same thing with 1st date.
If server's time is 1:00 morning and you have gtm -2 the it shall be 23:00 night but a day before , so it will do 1 - 1 = 0 and it will display date 0.
Shortly, it will work good until date is 1 or 30, 31....