TIMELEFT RUS

TIMELEFT RUS 3.0

Нет прав для скачивания
Код:
/* TIMELEFT RUS ( РУССКАЯ ОЗВУЧКА ВРЕМЕНИ )

    Оригинальный Автор : AMXX Dev Team
    Автор Русской Озвучки и изменений : MayroN | German
    Версия : 3.0

    Описание :
        Плагин выводит информацию в чат времени до конца карты,текущей дате и показывает общее время.
        Также проигрывает Русским голосом оставшееся время на карте в минутах.

    Изменения :
        - Русская озвучка звуков от German'а от 1 минуты и до 20 минут
        - Поставлен ColorChat
        - Правильное отображение HUD сообщений о остатке времени ( stock get_ending )
        - Правильное отображение в Чате сообщений о остатке времени
                    | минута , минуты , минут | секунда , секунды , секунд |
        - Добавлен отдельный LANG файл сообщений - timeleft_rus.txt
        - Зарегистрирована дополнительная команда say_team для timeleft и thetime
        - Удалено проигрывание английской озвучки звуков команды thetime
*/

#include <amxmodx>
#include <fakemeta>

#define PLUGIN_NAME    "TIMELEFT RUS"
#define PLUGIN_VERSION    "3.0"
#define PLUGIN_AUTHOR    "AMXX Dev Team | MayroN | German"

new g_TimeSet[32][2]
new g_LastTime
new g_CountDown
new g_Switch

public plugin_init()
{
    register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)

    register_dictionary("timeleft_rus.txt")
    register_cvar("amx_time_voice", "1")
    register_srvcmd("amx_time_display", "setDisplaying")
    register_cvar("amx_timeleft", "00:00", FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)
    register_clcmd("say timeleft", "sayTimeLeft", 0, "- displays timeleft")
    register_clcmd("say_team timeleft", "sayTimeLeft", 0, "- displays timeleft")
    register_clcmd("say thetime", "sayTheTime", 0, "- displays current time")
        register_clcmd("say_team thetime", "sayTheTime", 0, "- displays current time")
 
    set_task(0.8, "timeRemain", 8648458, "", 0, "b")
}

new const TIMELEFT_RUS[][] =
{
        "timeleft_rus/eight.wav",
        "timeleft_rus/eighteen.wav",
        "timeleft_rus/eleven.wav",
        "timeleft_rus/fifteen.wav",
        "timeleft_rus/five.wav",
        "timeleft_rus/four.wav",
        "timeleft_rus/fourteen.wav",
        "timeleft_rus/nine.wav",
        "timeleft_rus/nineteen.wav",
        "timeleft_rus/one.wav",
        "timeleft_rus/seven.wav",
        "timeleft_rus/seventeen.wav",
        "timeleft_rus/six.wav",
        "timeleft_rus/sixteen.wav",
        "timeleft_rus/ten.wav",
        "timeleft_rus/thirteen.wav",
        "timeleft_rus/three.wav",
        "timeleft_rus/twelve.wav",
        "timeleft_rus/twenty.wav",
        "timeleft_rus/two.wav"
}

public plugin_precache()
{
        for(new i; i < sizeof(TIMELEFT_RUS); i++)
            engfunc(EngFunc_PrecacheSound, TIMELEFT_RUS[i])
}

public sayTheTime(id)
{
    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 "
        
    }
 
    new date[64], time[64]

    get_time("%d / %m / %Y", date, 63)
    get_time("%H : %M", time, 63)

        client_print_color(0, print_team_default, "^4%L: ^3%s ^4%L: ^3%s", LANG_PLAYER, "DATE", date, LANG_PLAYER, "TIME", time)
 
    return PLUGIN_CONTINUE
}

public sayTimeLeft(id)
{
    if (get_cvar_float("mp_timelimit"))
    {
        new a = get_timeleft()

        new words_minutes[][] = {"минута", "минуты", "минут"}
        new words_seconds[][] = {"секунда", "секунды", "секунд"}

        if (get_cvar_num("amx_time_voice"))
        {
            new svoice[128]
            setTimeVoice(svoice, 127, 0, a)
            client_cmd(id, "%s", svoice)
        }
                if((a / 60) > 0)
            client_print_color(0, print_team_default, "^4%L^1  •  ^3%d %s", LANG_PLAYER, "TIME_LEFT", (a / 60), words_minutes[declOfNum((a / 60))]);
            else
            client_print_color(0, print_team_default, "^4%L^1  •  ^3%d %s", LANG_PLAYER, "TIME_LEFT", (a % 60), words_seconds[declOfNum((a % 60))]);
        }
        else
                      client_print_color(0, print_team_default, "^4%L", LANG_PLAYER, "NO_T_LIMIT")
 
    return PLUGIN_CONTINUE
}

setTimeText(text[], len, tmlf, id)
{
    new secs = tmlf % 60
    new mins = tmlf / 60
    new countMin[16]; get_ending(mins, "TIME_M1", "TIME_M2", "TIME_M3", countMin, charsmax(countMin))
    new countSec[16]; get_ending(secs, "TIME_S1", "TIME_S2", "TIME_S3", countSec, charsmax(countSec))
 
    if (secs == 0)
        format(text, len, "%d %L", mins, id, countMin, id, "TIME_M1", "TIME_M2", "TIME_M3")
    else if (mins == 0)
        format(text, len, "%d %L", secs, id, countSec, id, "TIME_S1", "TIME_S2", "TIME_S3")
    else
        format(text, len, "%d %L %d %L", mins, id, countMin, secs, id, countSec, id, "TIME_M1", "TIME_M2", "TIME_M3")
}

setTimeVoice(text[], len, flags, tmlf)
{
    new temp[7][32]
    new mins = tmlf / 60
 
    for (new a = 0;a < 7;++a)
        temp[a][0] = 0
 
    if (0 < mins < 21)
    {
        num_to_word(mins, temp[0], 31)
 
        if (!(flags & 8))
            temp[1] = "minutes "
    }
 
    return format(text, len, "spk ^"timeleft_rus/%s%s^"", temp[0], temp[1])
}

findDispFormat(time)
{
    for (new i = 0; g_TimeSet[i][0]; ++i)
    {
        if (g_TimeSet[i][1] & 16)
        {
            if (g_TimeSet[i][0] > time)
            {
                if (!g_Switch)
                {
                    g_CountDown = g_Switch = time
                    remove_task(8648458)
                    set_task(1.0, "timeRemain", 34543, "", 0, "b")
                }
        
                return i
            }
        }
        else if (g_TimeSet[i][0] == time)
        {
            return i
        }
    }
 
    return -1
}

public setDisplaying()
{
    new arg[32], flags[32], num[32]
    new argc = read_argc() - 1
    new i = 0

    while (i < argc && i < 32)
    {
        read_argv(i + 1, arg, 31)
        parse(arg, flags, 31, num, 31)
 
        g_TimeSet[i][0] = str_to_num(num)
        g_TimeSet[i][1] = read_flags(flags)
 
        i++
    }
    g_TimeSet[i][0] = 0
 
    return PLUGIN_HANDLED
}

public timeRemain(param[])
{
    new gmtm = get_timeleft()
    new tmlf = g_Switch ? --g_CountDown : gmtm
    new stimel[12]
 
    format(stimel, 11, "%02d:%02d", gmtm / 60, gmtm % 60)
    set_cvar_string("amx_timeleft", stimel)
 
    if (g_Switch && gmtm > g_Switch)
    {
        remove_task(34543)
        g_Switch = 0
        set_task(0.8, "timeRemain", 8648458, "", 0, "b")
 
        return
    }

    if (tmlf > 0 && g_LastTime != tmlf)
    {
        g_LastTime = tmlf
        new tm_set = findDispFormat(tmlf)
 
        if (tm_set != -1)
        {
            new flags = g_TimeSet[tm_set][1]
            new arg[128]
    
            if (flags & 1)
            {
                new players[32], pnum
        
                get_players(players, pnum, "c")
        
                for (new i = 0; i < pnum; i++)
                {
                    setTimeText(arg, 127, tmlf, players[i])
            
                    if (flags & 16)
                        set_hudmessage(255, 255, 255, -1.0, 0.89, 0, 0.0, 1.1, 0.1, 0.5, -1)
                    else
                        set_hudmessage(255, 255, 255, -1.0, 0.89, 0, 0.0, 3.0, 0.0, 0.5, -1)
            
                    show_hudmessage(players[i], "%s", arg)
                }
            }

            if (flags & 2)
            {
                setTimeVoice(arg, 127, flags, tmlf)
                client_cmd(0, "%s", arg)
            }
        }
    }
}

stock get_ending(num, const a[], const b[], const c[], output[], lenght)
{
    new num100 = num % 100, num10 = num % 10;
    if(num100 >=5 && num100 <= 20 || num10 == 0 || num10 >= 5 && num10 <= 9) formatex(output, lenght, "%s", a);
    else if(num10 == 1) formatex(output, lenght, "%s", b);
    else if(num10 >= 2 && num10 <= 4) formatex(output, lenght, "%s", c);
}

declOfNum(number)
{
    new cases[] = {2, 0, 1, 1, 1, 2};
    return (number % 100 > 4 && number % 100 < 20) ? 2 : cases[(number % 10 < 5) ? number % 10 : 5];
}
Назад
Верх