Raised This Month: $ Target: $400
 0% 

Could anybody help with thetime every 15 minutes? (+KARMA)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
UberStrike
Junior Member
Join Date: Nov 2007
Old 02-07-2009 , 22:29   Could anybody help with thetime every 15 minutes? (+KARMA)
Reply With Quote #1

Can anybody help with this?

I want to make it announce the time every 15 minutes instead of each hour.

IE:

1:15
10
1:45
2:00
etc.
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 
    } 
}
Thanks, I'll give karma.
UberStrike is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:51.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode