AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Could anybody help with thetime every 15 minutes? (+KARMA) (https://forums.alliedmods.net/showthread.php?t=85269)

UberStrike 02-07-2009 22:29

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

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

IE:

1:15
1:30
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.

jim_yang 02-07-2009 22:34

Re: Could anybody help with thetime every 15 minutes? (+KARMA)
 
if (g_min == 0)=> if(g_min % 15 == 0)

UberStrike 02-08-2009 15:19

Re: Could anybody help with thetime every 15 minutes? (+KARMA)
 
Thanks!
+karma

ConnorMcLeod 02-08-2009 16:12

Re: Could anybody help with thetime every 15 minutes? (+KARMA)
 
What is the smurf model doing here ? :mrgreen:
Could you attach it pleaaaaase ?

Dores 02-08-2009 16:19

Re: Could anybody help with thetime every 15 minutes? (+KARMA)
 
LoLz, many funny things can be made with a smurf model. :crab:


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

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