Правила форума Гаранты форума
Размещение рекламы AMX-X компилятор

Здравствуйте, гость Вход | Регистрация

Наши новости:

14-дек
24-апр
10-апр
11-апр

> Правила форума

Этот раздел, как вы могли заметить по названию, предназначен для решения вопросов по поводу уже существующих модов и плагинов.
Пожалуйста, если у вас проблема с написанием плагина, не путайте этот раздел с разделом по скриптингу.
Для поиска плагинов и модов существует соответствующий раздел.

Название темы должно соответствовать содержанию. Темы с названием типа "Помогите", "Вопрос", "парни подскажите..." - будут удалены.
Все темы, не относящиеся к "Вопросам по модам и плагинам", будут удалены или перемещены в соответствующий раздел.

Правила оформления темы:
1. Помимо заголовка не забудьте верно сформулировать свой вопрос.
2. Выложите исходник (в тег кода + ) или ссылку на плагин который вызывает у вас вопросы.
3. Выложите лог с ошибками (если имеется) под спойлер

ColorChat

, Colorchat в lang файлах...
Статус пользователя freeone
сообщение 31.10.2012, 15:45
Сообщение #1
Стаж: 13 лет

Сообщений: 140
Благодарностей: 13
Полезность: 78

Подскажите ))
вот исходник mapchooser'a
.sma
#include <amxmodx>
#include <amxmisc>
#include <colorchat>

#define SELECTMAPS 5

#define charsof(%1) (sizeof(%1)-1)

new Array:g_mapName;
new g_mapNums;

new g_nextName[SELECTMAPS]
new g_voteCount[SELECTMAPS + 2]
new g_mapVoteNum
new g_teamScore[2]
new g_lastMap[32]

new g_coloredMenus
new bool:g_selected = false

public plugin_init()
{
register_plugin("Nextmap Chooser", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("mapchooser.txt")
register_dictionary("common.txt")

g_mapName=ArrayCreate(32);

new MenuName[64]

format(MenuName, 63, "%L", "en", "CHOOSE_NEXTM")
register_menucmd(register_menuid(MenuName), (-1^(-1<<(SELECTMAPS+2))), "countVote")
register_cvar("amx_extendmap_max", "90")
register_cvar("amx_extendmap_step", "15")

if (cstrike_running())
register_event("TeamScore", "team_score", "a")

get_localinfo("lastMap", g_lastMap, 31)
set_localinfo("lastMap", "")

new maps_ini_file[64]
get_configsdir(maps_ini_file, 63);
format(maps_ini_file, 63, "%s/maps.ini", maps_ini_file);

if (!file_exists(maps_ini_file))
get_cvar_string("mapcyclefile", maps_ini_file, 63)
if (loadSettings(maps_ini_file))
set_task(15.0, "voteNextmap", 987456, "", 0, "b")

g_coloredMenus = colored_menus()

}

public checkVotes()
{
new b = 0

for (new a = 0; a < g_mapVoteNum; ++a)
if (g_voteCount[b] < g_voteCount[a])
b = a


if (g_voteCount[SELECTMAPS] > g_voteCount[b]
&& g_voteCount[SELECTMAPS] > g_voteCount[SELECTMAPS+1])
{
new mapname[32]

get_mapname(mapname, 31)
new Float:steptime = get_cvar_float("amx_extendmap_step")
set_cvar_float("mp_timelimit", get_cvar_float("mp_timelimit") + steptime)
ColorChat (0,GREY, "%L", LANG_PLAYER, "CHO_FIN_EXT", steptime)
log_amx("Vote: Voting for the nextmap finished. Map %s will be extended to next %.0f minutes", mapname, steptime)

return
}

new smap[32]
if (g_voteCount[b] && g_voteCount[SELECTMAPS + 1] <= g_voteCount[b])
{
ArrayGetString(g_mapName, g_nextName[b], smap, charsof(smap));
set_cvar_string("amx_nextmap", smap);
}


get_cvar_string("amx_nextmap", smap, 31)
ColorChat (0,GREY, "%L", LANG_PLAYER, "CHO_FIN_NEXT", smap)
log_amx("Vote: Voting for the nextmap finished. The nextmap will be %s", smap)
}

public countVote(id, key)
{
if (get_cvar_float("amx_vote_answers"))
{
new name[32]
get_user_name(id, name, 31)

if (key == SELECTMAPS)
ColorChat (0,GREY, "%L", LANG_PLAYER, "CHOSE_EXT", name)
else if (key < SELECTMAPS)
{
new map[32];
ArrayGetString(g_mapName, g_nextName[key], map, charsof(map));
ColorChat (0,GREY, "%L", LANG_PLAYER, "X_CHOSE_X", name, map);
}
}
++g_voteCount[key]

return PLUGIN_HANDLED
}

bool:isInMenu(id)
{
for (new a = 0; a < g_mapVoteNum; ++a)
if (id == g_nextName[a])
return true
return false
}

public voteNextmap()
{
new winlimit = get_cvar_num("mp_winlimit")
new maxrounds = get_cvar_num("mp_maxrounds")

if (winlimit)
{
new c = winlimit - 2

if ((c > g_teamScore[0]) && (c > g_teamScore[1]))
{
g_selected = false
return
}
}
else if (maxrounds)
{
if ((maxrounds - 2) > (g_teamScore[0] + g_teamScore[1]))
{
g_selected = false
return
}
} else {
new timeleft = get_timeleft()

if (timeleft < 1 || timeleft > 129)
{
g_selected = false
return
}
}

if (g_selected)
return

g_selected = true

new menu[512], a, mkeys = (1<<SELECTMAPS + 1)

new pos = format(menu, 511, g_coloredMenus ? "\y%L:\w^n^n" : "%L:^n^n", LANG_SERVER, "CHOOSE_NEXTM")
new dmax = (g_mapNums > SELECTMAPS) ? SELECTMAPS : g_mapNums

for (g_mapVoteNum = 0; g_mapVoteNum < dmax; ++g_mapVoteNum)
{
a = random_num(0, g_mapNums - 1)

while (isInMenu(a))
if (++a >= g_mapNums) a = 0

g_nextName[g_mapVoteNum] = a
pos += format(menu[pos], 511, "%d. %a^n", g_mapVoteNum + 1, ArrayGetStringHandle(g_mapName, a));
mkeys |= (1<<g_mapVoteNum)
g_voteCount[g_mapVoteNum] = 0
}

menu[pos++] = '^n'
g_voteCount[SELECTMAPS] = 0
g_voteCount[SELECTMAPS + 1] = 0

new mapname[32]
get_mapname(mapname, 31)

if ((winlimit + maxrounds) == 0 && (get_cvar_float("mp_timelimit") < get_cvar_float("amx_extendmap_max")))
{
pos += format(menu[pos], 511, "%d. %L^n", SELECTMAPS + 1, LANG_SERVER, "EXTED_MAP", mapname)
mkeys |= (1<<SELECTMAPS)
}

format(menu[pos], 511, "%d. %L", SELECTMAPS+2, LANG_SERVER, "NONE")
new MenuName[64]

format(MenuName, 63, "%L", "en", "CHOOSE_NEXTM")
show_menu(0, mkeys, menu, 15, MenuName)
set_task(15.0, "checkVotes")
ColorChat (0,GREY, "%L", LANG_SERVER, "TIME_CHOOSE")
client_cmd(0, "spk Gman/Gman_Choose2")
log_amx("Vote: Voting for the nextmap started")
}
stock bool:ValidMap(mapname[])
{
if ( is_map_valid(mapname) )
{
return true;
}
// If the is_map_valid check failed, check the end of the string
new len = strlen(mapname) - 4;

// The mapname was too short to possibly house the .bsp extension
if (len < 0)
{
return false;
}
if ( equali(mapname[len], ".bsp") )
{
// If the ending was .bsp, then cut it off.
// the string is byref'ed, so this copies back to the loaded text.
mapname[len] = '^0';

// recheck
if ( is_map_valid(mapname) )
{
return true;
}
}

return false;
}

loadSettings(filename[])
{
if (!file_exists(filename))
return 0

new szText[32]
new currentMap[32]

new buff[256];

get_mapname(currentMap, 31)

new fp=fopen(filename,"r");

while (!feof(fp))
{
buff[0]='^0';

fgets(fp, buff, charsof(buff));

parse(buff, szText, charsof(szText));


if (szText[0] != ';' &&
ValidMap(szText) &&
!equali(szText, g_lastMap) &&
!equali(szText, currentMap))
{
ArrayPushString(g_mapName, szText);
++g_mapNums;
}

}

fclose(fp);

return g_mapNums
}

public team_score()
{
new team[2]

read_data(1, team, 1)
g_teamScore[(team[0]=='C') ? 0 : 1] = read_data(2)
}

public plugin_end()
{
new current_map[32]

get_mapname(current_map, 31)
set_localinfo("lastMap", current_map)
}


вот текст выводится серым цветом:
ColorChat (0,GREY, "%L", LANG_SERVER, "TIME_CHOOSE")
но мне надо что бы он был не полностью серым)
вот lang
.txt
[en]
CHO_FIN_EXT = Голосование завершено. Текущая карта будет продлена на !g%.0f !tминут
CHO_FIN_NEXT = Голосование завершено. Следующая карта: !g%s
CHOSE_EXT = !g%s !tвыбрал продление карты
X_CHOSE_X = !g%s !tвыбрал !g%s
CHOOSE_NEXTM = Выберите следующую карту:
EXTED_MAP = Продлить карту %s
TIME_CHOOSE = Пришло время выбрать следующую карту...


ставлю !g,!t игнорит,просто выводит сообщение так: !g%s !tвыбрал !g%s, но цвет не меняется(
в чём дело не могу понять,помогите)

вот инклуд если надо)
.inc
/* Fun functions
*
* by Numb
*
* This file is provided as is (no warranties).
*/

#if defined _colorchat_included
#endinput
#endif
#define _colorchat_included

enum Color
{
NORMAL = 1, // clients scr_concolor cvar color
GREEN, // Green Color
TEAM_COLOR, // Red, grey, blue
GREY, // grey
RED, // Red
BLUE, // Blue
}

new TeamName[][] =
{
"",
"TERRORIST",
"CT",
"SPECTATOR"
}

ColorChat(id, Color:type, const msg[], {Float,Sql,Result,_}:...)
{
new message[256];

switch(type)
{
case NORMAL: // clients scr_concolor cvar color
{
message[0] = 0x01;
}
case GREEN: // Green
{
message[0] = 0x04;
}
default: // White, Red, Blue
{
message[0] = 0x03;
}
}

vformat(message[1], 251, msg, 4);

// Make sure message is not longer than 192 character. Will crash the server.
message[192] = '^0';

new team, ColorChange, index, MSG_Type;

if(id)
{
MSG_Type = MSG_ONE;
index = id;
} else {
index = FindPlayer();
MSG_Type = MSG_ALL;
}

team = get_user_team(index);
ColorChange = ColorSelection(index, MSG_Type, type);

ShowColorMessage(index, MSG_Type, message);

if(ColorChange)
{
Team_Info(index, MSG_Type, TeamName[team]);
}
}

ShowColorMessage(id, type, message[])
{
static bool:saytext_used;
static get_user_msgid_saytext;
if(!saytext_used)
{
get_user_msgid_saytext = get_user_msgid("SayText");
saytext_used = true;
}
message_begin(type, get_user_msgid_saytext, _, id);
write_byte(id)
write_string(message);
message_end();
}

Team_Info(id, type, team[])
{
static bool:teaminfo_used;
static get_user_msgid_teaminfo;
if(!teaminfo_used)
{
get_user_msgid_teaminfo = get_user_msgid("TeamInfo");
teaminfo_used = true;
}
message_begin(type, get_user_msgid_teaminfo, _, id);
write_byte(id);
write_string(team);
message_end();

return 1;
}

ColorSelection(index, type, Color:Type)
{
switch(Type)
{
case RED:
{
return Team_Info(index, type, TeamName[1]);
}
case BLUE:
{
return Team_Info(index, type, TeamName[2]);
}
case GREY:
{
return Team_Info(index, type, TeamName[0]);
}
}

return 0;
}

FindPlayer()
{
new i = -1;

while(i <= get_maxplayers())
{
if(is_user_connected(++i))
return i;
}

return -1;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/


Отредактировал: freeone, - 31.10.2012, 15:47
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   Цитировать сообщение
Статус пользователя Nikita1811
сообщение 27.2.2014, 14:30
Сообщение #2
Стаж: 15 лет

Сообщений: 49
Благодарностей: 1
Полезность: 18

Подниму тему так как интересует решение этого вопроса.
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя TarikYuzkiv
сообщение 27.2.2014, 14:33
Сообщение #3
Стаж: 13 лет

Сообщений: 509
Благодарностей: 196
Полезность: 635

ColorChat (0,GREY...
-->
Код
NORMAL = 1, // clients scr_concolor cvar color
GREEN, // Green Color
TEAM_COLOR, // Red, grey, blue
GREY, // grey
RED, // Red
BLUE, // Blue

^1 - Обычный цвет сообщения
^3 - Цвет по умолчанию что мы установили Color:type
^4 - Зеленый цвет


Отредактировал: TarikYuzkiv, - 27.2.2014, 14:35
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Machette
сообщение 27.2.2014, 14:37
Сообщение #4


Стаж: 14 лет

Сообщений: 546
Благодарностей: 419
Полезность: 947

Nikita1811, сами же дали цвет серый.
ColorChat (0,GREY, "%L", LANG_SERVER, "TIME_CHOOSE")
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
TEROR^
сообщение 27.2.2014, 14:37
Сообщение #5
Стаж: 16 лет

Сообщений: 577
Благодарностей: 251
Полезность: 0

Либо используй другой сток колорчата(нормальный, а не г).
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Nikita1811
сообщение 27.2.2014, 14:45
Сообщение #6
Стаж: 15 лет

Сообщений: 49
Благодарностей: 1
Полезность: 18

Это я понимаю, а что необходимо сделать чтобы цвет можно было менять в lang файлах txt?
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя TarikYuzkiv
сообщение 27.2.2014, 14:54
Сообщение #7
Стаж: 13 лет

Сообщений: 509
Благодарностей: 196
Полезность: 635

Используйте сток
Код
stock ChatColor(const id, const input[], any:...)
{
        new count = 1, players[32]
        static msg[191]
        vformat(msg, 190, input, 3)
      
        replace_all(msg, 190, "!g", "^4") // Green Color
        replace_all(msg, 190, "!y", "^1") // Default Color
        replace_all(msg, 190, "!t", "^3") // Team Color
      
        if (id) players[0] = id; else get_players(players, count, "ch")
        {
                for (new i = 0; i < count; i++)
                {
                        if (is_user_connected(players[i]))
                        {
                                message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
                                write_byte(players[i]);
                                write_string(msg);
                                message_end();
                        }
                }
        }
}
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
Поблагодарили 1 раз
   + Цитировать сообщение
Статус пользователя Nikita1811
сообщение 27.2.2014, 17:10
Сообщение #8
Стаж: 15 лет

Сообщений: 49
Благодарностей: 1
Полезность: 18

Пробовал на плагине timeleft сделать: Осталось: 23:23
В timeleft.txt
Код
[ru]
TIME_LEFT = !gОсталось:

timeleft

Код:
* AMX Mod X
* TimeLeft Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* This file is part of AMX Mod X.
*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*/

#include <amxmodx>
#include <colorchat>

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

public plugin_init()
{
register_plugin("TimeLeft", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("timeleft.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 thetime", "sayTheTime", 0, "- displays current time")

set_task(0.8, "timeRemain", 8648458, "", 0, "b")
}

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 "

client_cmd(id, "spk ^"fvox/time_is_now %s_period %s%s^"", whours, wmins, wpm)
}

new ctime[64]

get_time("%m/%d/%Y - %H:%M:%S", ctime, 63)
client_print(0, print_chat, "%L: %s", LANG_PLAYER, "THE_TIME", ctime)

return PLUGIN_CONTINUE
}

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

if (get_cvar_num("amx_time_voice"))
{
new svoice[128]
setTimeVoice(svoice, 127, 0, a)
client_cmd(id, "%s", svoice)
}
ColorChat(0, Red, "%L: %d:%02d", LANG_PLAYER, "TIME_LEFT", (a / 60), (a % 60))
}
else
client_print(0, print_chat, "%L", LANG_PLAYER, "NO_T_LIMIT")

return PLUGIN_CONTINUE
}

setTimeText(text[], len, tmlf, id)
{
new secs = tmlf % 60
new mins = tmlf / 60

if (secs == 0)
format(text, len, "%d %L", mins, id, (mins > 1) ? "MINUTES" : "MINUTE")
else if (mins == 0)
format(text, len, "%d %L", secs, id, (secs > 1) ? "SECONDS" : "SECOND")
else
format(text, len, "%d %L %d %L", mins, id, (mins > 1) ? "MINUTES" : "MINUTE", secs, id, (secs > 1) ? "SECONDS" : "SECOND")
}

setTimeVoice(text[], len, flags, tmlf)
{
new temp[7][32]
new secs = tmlf % 60
new mins = tmlf / 60

for (new a = 0;a < 7;++a)
temp[a][0] = 0

if (secs > 0)
{
num_to_word(secs, temp[4], 31)

if (!(flags & 8))
temp[5] = "seconds " /* there is no "second" in default hl */
}

if (mins > 59)
{
new hours = mins / 60

num_to_word(hours, temp[0], 31)

if (!(flags & 8))
temp[1] = "hours "

mins = mins % 60
}

if (mins > 0)
{
num_to_word(mins, temp[2], 31)

if (!(flags & 8))
temp[3] = "minutes "
}

if (!(flags & 4))
temp[6] = "remaining "

return format(text, len, "spk ^"vox/%s%s%s%s%s%s%s^"", temp[0], temp[1], temp[2], temp[3], temp[4], temp[5], temp[6])
}

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.85, 0, 0.0, 1.1, 0.1, 0.5, -1)
else
set_hudmessage(255, 255, 255, -1.0, 0.85, 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 ColorChat(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)

replace_all(msg, 190, "!g", "^4") // Green Color
replace_all(msg, 190, "!y", "^1") // Default Color
replace_all(msg, 190, "!t", "^3") // Team Color

if (id) players[0] = id; else get_players(players, count, "ch")
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}


При компиляции
Ошибка

Прикрепленное изображение

colorchat.inc

#if defined _colorchat_included
#endinput
#endif
#define _colorchat_included

/* ColorChat Support */
#define RED Red
#define BLUE Blue
#define GREY Grey
#define ColorChat client_print_color
/* ColorChat Support */

enum {
DontChange = 0,
Grey = 33,
Red,
Blue
};

stock client_print_color(id, sender, const fmt[], any:...)
{
// check if id is different from 0
if( id && !is_user_connected(id) )
{
return 0;
}

static const szTeamName[][] =
{
"",
"TERRORIST",
"CT"
};

new szMessage[192];

new iParams = numargs();
// Specific player code
if( id )
{
if( iParams == 3 )
{
copy(szMessage, charsmax(szMessage), fmt); // copy so message length doesn't exceed critical 192 value
}
else
{
vformat(szMessage, charsmax(szMessage), fmt, 4);
}

if( sender > Grey )
{
if( sender > Blue )
{
sender = id;
}
else
{
_CC_TeamInfo(id, sender, szTeamName[sender-Grey]);
}
}
_CC_SayText(id, sender, szMessage);
}

// Send message to all players
else
{
// Figure out if at least 1 player is connected
// so we don't execute useless useless code if not
new iPlayers[32], iNum;
get_players(iPlayers, iNum, "ch");
if( !iNum )
{
return 0;
}

new iMlNumber, i, j;
new Array:aStoreML = ArrayCreate();
if( iParams >= 5 ) // ML can be used
{
for(j=3; j<iParams; j++)
{
// retrieve original param value and check if it's LANG_PLAYER value
if( getarg(j) == LANG_PLAYER )
{
i=0;
// as LANG_PLAYER == -1, check if next parm string is a registered language translation
while( ( szMessage[ i ] = getarg( j + 1, i++ ) ) ) {}
if( GetLangTransKey(szMessage) != TransKey_Bad )
{
// Store that arg as LANG_PLAYER so we can alter it later
ArrayPushCell(aStoreML, j++);

// Update ML array saire so we'll know 1st if ML is used,
// 2nd how many args we have to alterate
iMlNumber++;
}
}
}
}

// If arraysize == 0, ML is not used
// we can only send 1 MSG_ALL message if sender != 0
if( !iMlNumber )
{
if( iParams == 3 )
{
copy(szMessage, charsmax(szMessage), fmt);
}
else
{
vformat(szMessage, charsmax(szMessage), fmt, 4);
}
if( 0 < sender < Blue ) // if 0 is passed, need to loop
{
if( sender > Grey )
{
_CC_TeamInfo(0, sender, szTeamName[sender-Grey]);
}
_CC_SayText(0, sender, szMessage);
return 1;
}
}

if( sender > Blue )
{
sender = 0; // use receiver index
}

for(--iNum; iNum>=0; iNum--)
{
id = iPlayers[iNum];

if( iMlNumber )
{
for(j=0; j<iMlNumber; j++)
{
// Set all LANG_PLAYER args to player index ( = id )
// so we can format the text for that specific player
setarg(ArrayGetCell(aStoreML, j), _, id);
}

// format string for specific player
vformat(szMessage, charsmax(szMessage), fmt, 4);
}

if( sender > Grey )
{
_CC_TeamInfo(id, sender, szTeamName[sender-Grey]);
}
_CC_SayText(id, sender, szMessage);
}

ArrayDestroy(aStoreML);
}
return 1;
}

stock _CC_TeamInfo(iReceiver, iSender, szTeam[])
{
static iTeamInfo = 0;
if( !iTeamInfo )
{
iTeamInfo = get_user_msgid("TeamInfo");
}
message_begin(iReceiver ? MSG_ONE : MSG_ALL, iTeamInfo, _, iReceiver);
write_byte(iSender);
write_string(szTeam);
message_end();
}

stock _CC_SayText(iReceiver, iSender, szMessage[])
{
static iSayText = 0;
if( !iSayText )
{
iSayText = get_user_msgid("SayText");
}
message_begin(iReceiver ? MSG_ONE : MSG_ALL, iSayText, _, iReceiver);
write_byte(iSender ? iSender : iReceiver);
write_string(szMessage);
message_end();
}

stock register_dictionary_colored(const filename[])
{
if( !register_dictionary(filename) )
{
return 0;
}

new szFileName[256];
get_localinfo("amxx_datadir", szFileName, charsmax(szFileName));
format(szFileName, charsmax(szFileName), "%s/lang/%s", szFileName, filename);
new fp = fopen(szFileName, "rt");
if( !fp )
{
log_amx("Failed to open %s", szFileName);
return 0;
}

new szBuffer[512], szLang[3], szKey[64], szTranslation[256], TransKey:iKey;

while( !feof(fp) )
{
fgets(fp, szBuffer, charsmax(szBuffer));
trim(szBuffer);

if( szBuffer[0] == '[' )
{
strtok(szBuffer[1], szLang, charsmax(szLang), szBuffer, 1, ']');
}
else if( szBuffer[0] )
{
strbreak(szBuffer, szKey, charsmax(szKey), szTranslation, charsmax(szTranslation));
iKey = GetLangTransKey(szKey);
if( iKey != TransKey_Bad )
{
replace_all(szTranslation, charsmax(szTranslation), "!g", "^4");
replace_all(szTranslation, charsmax(szTranslation), "!t", "^3");
replace_all(szTranslation, charsmax(szTranslation), "!n", "^1");
AddTranslation(szLang, iKey, szTranslation[2]);
}
}
}


fclose(fp);
return 1;
}

При использовании colorchat.inc из темы
Ошибка

Прикрепленное изображение


Отредактировал: Nikita1811, - 27.2.2014, 20:51
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя TarikYuzkiv
сообщение 27.2.2014, 18:02
Сообщение #9
Стаж: 13 лет

Сообщений: 509
Благодарностей: 196
Полезность: 635

Цитата(Nikita1811 @ 27.2.2014, 19:10) *
Пробовал на плагине timeleft сделать: Осталось: 23:23
В timeleft.txt
Код
[ru]
TIME_LEFT = !gОсталось:

timeleft

* AMX Mod X
* TimeLeft Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* This file is part of AMX Mod X.
*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*/

#include <amxmodx>
#include <colorchat>

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

public plugin_init()
{
register_plugin("TimeLeft", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("timeleft.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 thetime", "sayTheTime", 0, "- displays current time")

set_task(0.8, "timeRemain", 8648458, "", 0, "b")
}

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 "

client_cmd(id, "spk ^"fvox/time_is_now %s_period %s%s^"", whours, wmins, wpm)
}

new ctime[64]

get_time("%m/%d/%Y - %H:%M:%S", ctime, 63)
client_print(0, print_chat, "%L: %s", LANG_PLAYER, "THE_TIME", ctime)

return PLUGIN_CONTINUE
}

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

if (get_cvar_num("amx_time_voice"))
{
new svoice[128]
setTimeVoice(svoice, 127, 0, a)
client_cmd(id, "%s", svoice)
}
ColorChat(0, Red, "%L: %d:%02d", LANG_PLAYER, "TIME_LEFT", (a / 60), (a % 60))
}
else
client_print(0, print_chat, "%L", LANG_PLAYER, "NO_T_LIMIT")

return PLUGIN_CONTINUE
}

setTimeText(text[], len, tmlf, id)
{
new secs = tmlf % 60
new mins = tmlf / 60

if (secs == 0)
format(text, len, "%d %L", mins, id, (mins > 1) ? "MINUTES" : "MINUTE")
else if (mins == 0)
format(text, len, "%d %L", secs, id, (secs > 1) ? "SECONDS" : "SECOND")
else
format(text, len, "%d %L %d %L", mins, id, (mins > 1) ? "MINUTES" : "MINUTE", secs, id, (secs > 1) ? "SECONDS" : "SECOND")
}

setTimeVoice(text[], len, flags, tmlf)
{
new temp[7][32]
new secs = tmlf % 60
new mins = tmlf / 60

for (new a = 0;a < 7;++a)
temp[a][0] = 0

if (secs > 0)
{
num_to_word(secs, temp[4], 31)

if (!(flags & 8))
temp[5] = "seconds " /* there is no "second" in default hl */
}

if (mins > 59)
{
new hours = mins / 60

num_to_word(hours, temp[0], 31)

if (!(flags & 8))
temp[1] = "hours "

mins = mins % 60
}

if (mins > 0)
{
num_to_word(mins, temp[2], 31)

if (!(flags & 8))
temp[3] = "minutes "
}

if (!(flags & 4))
temp[6] = "remaining "

return format(text, len, "spk ^"vox/%s%s%s%s%s%s%s^"", temp[0], temp[1], temp[2], temp[3], temp[4], temp[5], temp[6])
}

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.85, 0, 0.0, 1.1, 0.1, 0.5, -1)
else
set_hudmessage(255, 255, 255, -1.0, 0.85, 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 ColorChat(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)

replace_all(msg, 190, "!g", "^4") // Green Color
replace_all(msg, 190, "!y", "^1") // Default Color
replace_all(msg, 190, "!t", "^3") // Team Color

if (id) players[0] = id; else get_players(players, count, "ch")
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}

При компиляции
Ошибка

Прикрепленное изображение

colorchat.inc

#if defined _colorchat_included
#endinput
#endif
#define _colorchat_included

/* ColorChat Support */
#define RED Red
#define BLUE Blue
#define GREY Grey
#define ColorChat client_print_color
/* ColorChat Support */

enum {
DontChange = 0,
Grey = 33,
Red,
Blue
};

stock client_print_color(id, sender, const fmt[], any:...)
{
// check if id is different from 0
if( id && !is_user_connected(id) )
{
return 0;
}

static const szTeamName[][] =
{
"",
"TERRORIST",
"CT"
};

new szMessage[192];

new iParams = numargs();
// Specific player code
if( id )
{
if( iParams == 3 )
{
copy(szMessage, charsmax(szMessage), fmt); // copy so message length doesn't exceed critical 192 value
}
else
{
vformat(szMessage, charsmax(szMessage), fmt, 4);
}

if( sender > Grey )
{
if( sender > Blue )
{
sender = id;
}
else
{
_CC_TeamInfo(id, sender, szTeamName[sender-Grey]);
}
}
_CC_SayText(id, sender, szMessage);
}

// Send message to all players
else
{
// Figure out if at least 1 player is connected
// so we don't execute useless useless code if not
new iPlayers[32], iNum;
get_players(iPlayers, iNum, "ch");
if( !iNum )
{
return 0;
}

new iMlNumber, i, j;
new Array:aStoreML = ArrayCreate();
if( iParams >= 5 ) // ML can be used
{
for(j=3; j<iParams; j++)
{
// retrieve original param value and check if it's LANG_PLAYER value
if( getarg(j) == LANG_PLAYER )
{
i=0;
// as LANG_PLAYER == -1, check if next parm string is a registered language translation
while( ( szMessage[ i ] = getarg( j + 1, i++ ) ) ) {}
if( GetLangTransKey(szMessage) != TransKey_Bad )
{
// Store that arg as LANG_PLAYER so we can alter it later
ArrayPushCell(aStoreML, j++);

// Update ML array saire so we'll know 1st if ML is used,
// 2nd how many args we have to alterate
iMlNumber++;
}
}
}
}

// If arraysize == 0, ML is not used
// we can only send 1 MSG_ALL message if sender != 0
if( !iMlNumber )
{
if( iParams == 3 )
{
copy(szMessage, charsmax(szMessage), fmt);
}
else
{
vformat(szMessage, charsmax(szMessage), fmt, 4);
}
if( 0 < sender < Blue ) // if 0 is passed, need to loop
{
if( sender > Grey )
{
_CC_TeamInfo(0, sender, szTeamName[sender-Grey]);
}
_CC_SayText(0, sender, szMessage);
return 1;
}
}

if( sender > Blue )
{
sender = 0; // use receiver index
}

for(--iNum; iNum>=0; iNum--)
{
id = iPlayers[iNum];

if( iMlNumber )
{
for(j=0; j<iMlNumber; j++)
{
// Set all LANG_PLAYER args to player index ( = id )
// so we can format the text for that specific player
setarg(ArrayGetCell(aStoreML, j), _, id);
}

// format string for specific player
vformat(szMessage, charsmax(szMessage), fmt, 4);
}

if( sender > Grey )
{
_CC_TeamInfo(id, sender, szTeamName[sender-Grey]);
}
_CC_SayText(id, sender, szMessage);
}

ArrayDestroy(aStoreML);
}
return 1;
}

stock _CC_TeamInfo(iReceiver, iSender, szTeam[])
{
static iTeamInfo = 0;
if( !iTeamInfo )
{
iTeamInfo = get_user_msgid("TeamInfo");
}
message_begin(iReceiver ? MSG_ONE : MSG_ALL, iTeamInfo, _, iReceiver);
write_byte(iSender);
write_string(szTeam);
message_end();
}

stock _CC_SayText(iReceiver, iSender, szMessage[])
{
static iSayText = 0;
if( !iSayText )
{
iSayText = get_user_msgid("SayText");
}
message_begin(iReceiver ? MSG_ONE : MSG_ALL, iSayText, _, iReceiver);
write_byte(iSender ? iSender : iReceiver);
write_string(szMessage);
message_end();
}

stock register_dictionary_colored(const filename[])
{
if( !register_dictionary(filename) )
{
return 0;
}

new szFileName[256];
get_localinfo("amxx_datadir", szFileName, charsmax(szFileName));
format(szFileName, charsmax(szFileName), "%s/lang/%s", szFileName, filename);
new fp = fopen(szFileName, "rt");
if( !fp )
{
log_amx("Failed to open %s", szFileName);
return 0;
}

new szBuffer[512], szLang[3], szKey[64], szTranslation[256], TransKey:iKey;

while( !feof(fp) )
{
fgets(fp, szBuffer, charsmax(szBuffer));
trim(szBuffer);

if( szBuffer[0] == '[' )
{
strtok(szBuffer[1], szLang, charsmax(szLang), szBuffer, 1, ']');
}
else if( szBuffer[0] )
{
strbreak(szBuffer, szKey, charsmax(szKey), szTranslation, charsmax(szTranslation));
iKey = GetLangTransKey(szKey);
if( iKey != TransKey_Bad )
{
replace_all(szTranslation, charsmax(szTranslation), "!g", "^4");
replace_all(szTranslation, charsmax(szTranslation), "!t", "^3");
replace_all(szTranslation, charsmax(szTranslation), "!n", "^1");
AddTranslation(szLang, iKey, szTranslation[2]);
}
}
}

fclose(fp);
return 1;
}

При использовании colorchat.inc из темы
Ошибка

Прикрепленное изображение

Возьмите исходник в [code=][/code], пожалуйста.
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Nikita1811
сообщение 27.2.2014, 19:13
Сообщение #10
Стаж: 15 лет

Сообщений: 49
Благодарностей: 1
Полезность: 18

Цитата(TarikYuzkiv @ 27.2.2014, 19:02) *
Возьмите исходник в [code=][/code], пожалуйста.

Отредактировал!
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя SkiF-1
сообщение 27.2.2014, 20:26
Сообщение #11


Стаж: 16 лет

Сообщений: 297
Благодарностей: 83
Полезность: 177

Исходник в [pawn*] [/pawn*] (* убрать)
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя TarikYuzkiv
сообщение 27.2.2014, 20:44
Сообщение #12
Стаж: 13 лет

Сообщений: 509
Благодарностей: 196
Полезность: 635

Цвет изменять в исходнике
Код
/* AMX Mod X
*   TimeLeft Plugin
*
* by the AMX Mod X Development Team
*  originally developed by OLO
*
* This file is part of AMX Mod X.
*
*
*  This program is free software; you can redistribute it and/or modify it
*  under the terms of the GNU General Public License as published by the
*  Free Software Foundation; either version 2 of the License, or (at
*  your option) any later version.
*
*  This program is distributed in the hope that it will be useful, but
*  WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
*  General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software Foundation,
*  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*  In addition, as a special exception, the author gives permission to
*  link the code of this program with the Half-Life Game Engine ("HL
*  Engine") and Modified Game Libraries ("MODs") developed by Valve,
*  L.L.C ("Valve"). You must obey the GNU General Public License in all
*  respects for all of the code used other than the HL Engine and MODs
*  from Valve. If you modify this file, you may extend this exception
*  to your version of the file, but you are not obligated to do so. If
*  you do not wish to do so, delete this exception statement from your
*  version.
*/

#include <amxmodx>
#include <colorchat>

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

public plugin_init()
{
    register_plugin("TimeLeft", AMXX_VERSION_STR, "AMXX Dev Team")
    register_dictionary("timeleft.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 thetime", "sayTheTime", 0, "- displays current time")
    
    set_task(0.8, "timeRemain", 8648458, "", 0, "b")
}

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 "
        
        client_cmd(id, "spk ^"fvox/time_is_now %s_period %s%s^"", whours, wmins, wpm)
    }
    
    new ctime[64]
    
    get_time("%m/%d/%Y - %H:%M:%S", ctime, 63)
    ColorChat(0, RED, "^1%L:   ^4%s", LANG_PLAYER, "THE_TIME", ctime)
    
    return PLUGIN_CONTINUE
}

public sayTimeLeft(id)
{
    if (get_cvar_float("mp_timelimit"))
    {
        new a = get_timeleft()
        
        if (get_cvar_num("amx_time_voice"))
        {
            new svoice[128]
            setTimeVoice(svoice, 127, 0, a)
            client_cmd(id, "%s", svoice)
        }
        ColorChat(0, RED, "^1%L:  ^4%d:%02d", LANG_PLAYER, "TIME_LEFT", (a / 60), (a % 60))
    }
    else
        ColorChat(0, RED, "^1%L", LANG_PLAYER, "NO_T_LIMIT")
    
    return PLUGIN_CONTINUE
}

setTimeText(text[], len, tmlf, id)
{
    new secs = tmlf % 60
    new mins = tmlf / 60
    
    if (secs == 0)
        format(text, len, "%d %L", mins, id, (mins > 1) ? "MINUTES" : "MINUTE")
    else if (mins == 0)
        format(text, len, "%d %L", secs, id, (secs > 1) ? "SECONDS" : "SECOND")
    else
        format(text, len, "%d %L %d %L", mins, id, (mins > 1) ? "MINUTES" : "MINUTE", secs, id, (secs > 1) ? "SECONDS" : "SECOND")
}

setTimeVoice(text[], len, flags, tmlf)
{
    new temp[7][32]
    new secs = tmlf % 60
    new mins = tmlf / 60
    
    for (new a = 0;a < 7;++a)
        temp[a][0] = 0

    if (secs > 0)
    {
        num_to_word(secs, temp[4], 31)
        
        if (!(flags & 8))
            temp[5] = "seconds "    /* there is no "second" in default hl */
    }
    
    if (mins > 59)
    {
        new hours = mins / 60
        
        num_to_word(hours, temp[0], 31)
        
        if (!(flags & 8))
            temp[1] = "hours "
        
        mins = mins % 60
    }
    
    if (mins > 0)
    {
        num_to_word(mins, temp[2], 31)
        
        if (!(flags & 8))
            temp[3] = "minutes "
    }
    
    if (!(flags & 4))
        temp[6] = "remaining "
    
    return format(text, len, "spk ^"vox/%s%s%s%s%s%s%s^"", temp[0], temp[1], temp[2], temp[3], temp[4], temp[5], temp[6])
}

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.85, 0, 0.0, 1.1, 0.1, 0.5, -1)
                    else
                        set_hudmessage(255, 255, 255, -1.0, 0.85, 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)
            }
        }
    }
}
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
Поблагодарили 1 раз
   + Цитировать сообщение
Статус пользователя Nikita1811
сообщение 27.2.2014, 20:51
Сообщение #13
Стаж: 15 лет

Сообщений: 49
Благодарностей: 1
Полезность: 18

Цитата(TarikYuzkiv @ 27.2.2014, 21:44) *
Цвет изменять в исходнике
Код
/* AMX Mod X
*   TimeLeft Plugin
*
* by the AMX Mod X Development Team
*  originally developed by OLO
*
* This file is part of AMX Mod X.
*
*
*  This program is free software; you can redistribute it and/or modify it
*  under the terms of the GNU General Public License as published by the
*  Free Software Foundation; either version 2 of the License, or (at
*  your option) any later version.
*
*  This program is distributed in the hope that it will be useful, but
*  WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
*  General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software Foundation,
*  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*  In addition, as a special exception, the author gives permission to
*  link the code of this program with the Half-Life Game Engine ("HL
*  Engine") and Modified Game Libraries ("MODs") developed by Valve,
*  L.L.C ("Valve"). You must obey the GNU General Public License in all
*  respects for all of the code used other than the HL Engine and MODs
*  from Valve. If you modify this file, you may extend this exception
*  to your version of the file, but you are not obligated to do so. If
*  you do not wish to do so, delete this exception statement from your
*  version.
*/

#include <amxmodx>
#include <colorchat>

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

public plugin_init()
{
    register_plugin("TimeLeft", AMXX_VERSION_STR, "AMXX Dev Team")
    register_dictionary("timeleft.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 thetime", "sayTheTime", 0, "- displays current time")
    
    set_task(0.8, "timeRemain", 8648458, "", 0, "b")
}

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 "
        
        client_cmd(id, "spk ^"fvox/time_is_now %s_period %s%s^"", whours, wmins, wpm)
    }
    
    new ctime[64]
    
    get_time("%m/%d/%Y - %H:%M:%S", ctime, 63)
    ColorChat(0, RED, "^1%L:   ^4%s", LANG_PLAYER, "THE_TIME", ctime)
    
    return PLUGIN_CONTINUE
}

public sayTimeLeft(id)
{
    if (get_cvar_float("mp_timelimit"))
    {
        new a = get_timeleft()
        
        if (get_cvar_num("amx_time_voice"))
        {
            new svoice[128]
            setTimeVoice(svoice, 127, 0, a)
            client_cmd(id, "%s", svoice)
        }
        ColorChat(0, RED, "^1%L:  ^4%d:%02d", LANG_PLAYER, "TIME_LEFT", (a / 60), (a % 60))
    }
    else
        ColorChat(0, RED, "^1%L", LANG_PLAYER, "NO_T_LIMIT")
    
    return PLUGIN_CONTINUE
}

setTimeText(text[], len, tmlf, id)
{
    new secs = tmlf % 60
    new mins = tmlf / 60
    
    if (secs == 0)
        format(text, len, "%d %L", mins, id, (mins > 1) ? "MINUTES" : "MINUTE")
    else if (mins == 0)
        format(text, len, "%d %L", secs, id, (secs > 1) ? "SECONDS" : "SECOND")
    else
        format(text, len, "%d %L %d %L", mins, id, (mins > 1) ? "MINUTES" : "MINUTE", secs, id, (secs > 1) ? "SECONDS" : "SECOND")
}

setTimeVoice(text[], len, flags, tmlf)
{
    new temp[7][32]
    new secs = tmlf % 60
    new mins = tmlf / 60
    
    for (new a = 0;a < 7;++a)
        temp[a][0] = 0

    if (secs > 0)
    {
        num_to_word(secs, temp[4], 31)
        
        if (!(flags & 8))
            temp[5] = "seconds "    /* there is no "second" in default hl */
    }
    
    if (mins > 59)
    {
        new hours = mins / 60
        
        num_to_word(hours, temp[0], 31)
        
        if (!(flags & 8))
            temp[1] = "hours "
        
        mins = mins % 60
    }
    
    if (mins > 0)
    {
        num_to_word(mins, temp[2], 31)
        
        if (!(flags & 8))
            temp[3] = "minutes "
    }
    
    if (!(flags & 4))
        temp[6] = "remaining "
    
    return format(text, len, "spk ^"vox/%s%s%s%s%s%s%s^"", temp[0], temp[1], temp[2], temp[3], temp[4], temp[5], temp[6])
}

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.85, 0, 0.0, 1.1, 0.1, 0.5, -1)
                    else
                        set_hudmessage(255, 255, 255, -1.0, 0.85, 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)
            }
        }
    }
}

Спасибо конечно, но вопрос был в том как сделать чтобы цвет менять через lang файл!
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя TarikYuzkiv
сообщение 27.2.2014, 20:55
Сообщение #14
Стаж: 13 лет

Сообщений: 509
Благодарностей: 196
Полезность: 635

Цитата(Nikita1811 @ 27.2.2014, 22:51) *
Спасибо конечно, но вопрос был в том как сделать чтобы цвет менять через lang файл!

Вы собираетесь по пять раз в сутки менять цвет? Попробуйте прописать через lang, по идее, должно работать.
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
Поблагодарили 1 раз
   + Цитировать сообщение
Статус пользователя Nikita1811
сообщение 27.2.2014, 20:59
Сообщение #15
Стаж: 15 лет

Сообщений: 49
Благодарностей: 1
Полезность: 18

Цитата(TarikYuzkiv @ 27.2.2014, 21:55) *
Вы собираетесь по пять раз в сутки менять цвет? Попробуйте прописать через lang, по идее, должно работать.

Сейчас попробую, просто на примере данного плагина хотелось бы и в других реализовать подобную функцию (изменение цвета в lang файлах).
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя TarikYuzkiv
сообщение 27.2.2014, 21:03
Сообщение #16
Стаж: 13 лет

Сообщений: 509
Благодарностей: 196
Полезность: 635

Цитата(Nikita1811 @ 27.2.2014, 22:59) *
Сейчас попробую, просто на примере данного плагина хотелось бы и в других реализовать подобную функцию (изменение цвета в lang файлах).

Можно сделать через сток, но будут только зелёный, обычный и "командный" цвета.
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Nikita1811
сообщение 27.2.2014, 21:06
Сообщение #17
Стаж: 15 лет

Сообщений: 49
Благодарностей: 1
Полезность: 18

Цитата(TarikYuzkiv @ 27.2.2014, 22:03) *
Можно сделать через сток, но будут только зелёный, обычный и "командный" цвета.

А можно в примере?
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя TarikYuzkiv
сообщение 27.2.2014, 21:23
Сообщение #18
Стаж: 13 лет

Сообщений: 509
Благодарностей: 196
Полезность: 635

Цитата(Nikita1811 @ 27.2.2014, 23:06) *
А можно в примере?

Скрытый текст
Код
/* AMX Mod X
*   TimeLeft Plugin
*
* by the AMX Mod X Development Team
*  originally developed by OLO
*
* This file is part of AMX Mod X.
*
*
*  This program is free software; you can redistribute it and/or modify it
*  under the terms of the GNU General Public License as published by the
*  Free Software Foundation; either version 2 of the License, or (at
*  your option) any later version.
*
*  This program is distributed in the hope that it will be useful, but
*  WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
*  General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software Foundation,
*  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*  In addition, as a special exception, the author gives permission to
*  link the code of this program with the Half-Life Game Engine ("HL
*  Engine") and Modified Game Libraries ("MODs") developed by Valve,
*  L.L.C ("Valve"). You must obey the GNU General Public License in all
*  respects for all of the code used other than the HL Engine and MODs
*  from Valve. If you modify this file, you may extend this exception
*  to your version of the file, but you are not obligated to do so. If
*  you do not wish to do so, delete this exception statement from your
*  version.
*/

#include <amxmodx>

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

public plugin_init()
{
    register_plugin("TimeLeft", AMXX_VERSION_STR, "AMXX Dev Team")
    register_dictionary("timeleft.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 thetime", "sayTheTime", 0, "- displays current time")
    
    set_task(0.8, "timeRemain", 8648458, "", 0, "b")
}

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 "
        
        client_cmd(id, "spk ^"fvox/time_is_now %s_period %s%s^"", whours, wmins, wpm)
    }
    
    new ctime[64]
    
    get_time("%m/%d/%Y - %H:%M:%S", ctime, 63)
    ChatColor(0, "%L:   %s", LANG_PLAYER, "THE_TIME", ctime)
    
    return PLUGIN_CONTINUE
}

public sayTimeLeft(id)
{
    if (get_cvar_float("mp_timelimit"))
    {
        new a = get_timeleft()
        
        if (get_cvar_num("amx_time_voice"))
        {
            new svoice[128]
            setTimeVoice(svoice, 127, 0, a)
            client_cmd(id, "%s", svoice)
        }
        ChatColor(0, "%L:  %d:%02d", LANG_PLAYER, "TIME_LEFT", (a / 60), (a % 60))
    }
    else
        ChatColor(0, "%L", LANG_PLAYER, "NO_T_LIMIT")
    
    return PLUGIN_CONTINUE
}

setTimeText(text[], len, tmlf, id)
{
    new secs = tmlf % 60
    new mins = tmlf / 60
    
    if (secs == 0)
        format(text, len, "%d %L", mins, id, (mins > 1) ? "MINUTES" : "MINUTE")
    else if (mins == 0)
        format(text, len, "%d %L", secs, id, (secs > 1) ? "SECONDS" : "SECOND")
    else
        format(text, len, "%d %L %d %L", mins, id, (mins > 1) ? "MINUTES" : "MINUTE", secs, id, (secs > 1) ? "SECONDS" : "SECOND")
}

setTimeVoice(text[], len, flags, tmlf)
{
    new temp[7][32]
    new secs = tmlf % 60
    new mins = tmlf / 60
    
    for (new a = 0;a < 7;++a)
        temp[a][0] = 0

    if (secs > 0)
    {
        num_to_word(secs, temp[4], 31)
        
        if (!(flags & 8))
            temp[5] = "seconds "    /* there is no "second" in default hl */
    }
    
    if (mins > 59)
    {
        new hours = mins / 60
        
        num_to_word(hours, temp[0], 31)
        
        if (!(flags & 8))
            temp[1] = "hours "
        
        mins = mins % 60
    }
    
    if (mins > 0)
    {
        num_to_word(mins, temp[2], 31)
        
        if (!(flags & 8))
            temp[3] = "minutes "
    }
    
    if (!(flags & 4))
        temp[6] = "remaining "
    
    return format(text, len, "spk ^"vox/%s%s%s%s%s%s%s^"", temp[0], temp[1], temp[2], temp[3], temp[4], temp[5], temp[6])
}

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.85, 0, 0.0, 1.1, 0.1, 0.5, -1)
                    else
                        set_hudmessage(255, 255, 255, -1.0, 0.85, 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 ChatColor(const id, const input[], any:...)
{
    new count = 1, players[32]
    static msg[191]
    vformat(msg, 190, input, 3)

    replace_all(msg, 190, "!g", "^4") // Green Color
    replace_all(msg, 190, "!y", "^1") // Default Color
    replace_all(msg, 190, "!t", "^3") // Team Color

    if (id) players[0] = id; else get_players(players, count, "ch")
    {
        for (new i = 0; i < count; i++)
        {
            if (is_user_connected(players[i]))
            {
                message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
                write_byte(players[i]);
                write_string(msg);
                message_end();
            }
        }
    }
}
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
Поблагодарили 1 раз
   + Цитировать сообщение
Статус пользователя Nikita1811
сообщение 27.2.2014, 21:34
Сообщение #19
Стаж: 15 лет

Сообщений: 49
Благодарностей: 1
Полезность: 18

Цитата(TarikYuzkiv @ 27.2.2014, 22:23) *
Скрытый текст
Код
/* AMX Mod X
*   TimeLeft Plugin
*
* by the AMX Mod X Development Team
*  originally developed by OLO
*
* This file is part of AMX Mod X.
*
*
*  This program is free software; you can redistribute it and/or modify it
*  under the terms of the GNU General Public License as published by the
*  Free Software Foundation; either version 2 of the License, or (at
*  your option) any later version.
*
*  This program is distributed in the hope that it will be useful, but
*  WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
*  General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software Foundation,
*  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*  In addition, as a special exception, the author gives permission to
*  link the code of this program with the Half-Life Game Engine ("HL
*  Engine") and Modified Game Libraries ("MODs") developed by Valve,
*  L.L.C ("Valve"). You must obey the GNU General Public License in all
*  respects for all of the code used other than the HL Engine and MODs
*  from Valve. If you modify this file, you may extend this exception
*  to your version of the file, but you are not obligated to do so. If
*  you do not wish to do so, delete this exception statement from your
*  version.
*/

#include <amxmodx>

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

public plugin_init()
{
    register_plugin("TimeLeft", AMXX_VERSION_STR, "AMXX Dev Team")
    register_dictionary("timeleft.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 thetime", "sayTheTime", 0, "- displays current time")
    
    set_task(0.8, "timeRemain", 8648458, "", 0, "b")
}

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 "
        
        client_cmd(id, "spk ^"fvox/time_is_now %s_period %s%s^"", whours, wmins, wpm)
    }
    
    new ctime[64]
    
    get_time("%m/%d/%Y - %H:%M:%S", ctime, 63)
    ChatColor(0, "%L:   %s", LANG_PLAYER, "THE_TIME", ctime)
    
    return PLUGIN_CONTINUE
}

public sayTimeLeft(id)
{
    if (get_cvar_float("mp_timelimit"))
    {
        new a = get_timeleft()
        
        if (get_cvar_num("amx_time_voice"))
        {
            new svoice[128]
            setTimeVoice(svoice, 127, 0, a)
            client_cmd(id, "%s", svoice)
        }
        ChatColor(0, "%L:  %d:%02d", LANG_PLAYER, "TIME_LEFT", (a / 60), (a % 60))
    }
    else
        ChatColor(0, "%L", LANG_PLAYER, "NO_T_LIMIT")
    
    return PLUGIN_CONTINUE
}

setTimeText(text[], len, tmlf, id)
{
    new secs = tmlf % 60
    new mins = tmlf / 60
    
    if (secs == 0)
        format(text, len, "%d %L", mins, id, (mins > 1) ? "MINUTES" : "MINUTE")
    else if (mins == 0)
        format(text, len, "%d %L", secs, id, (secs > 1) ? "SECONDS" : "SECOND")
    else
        format(text, len, "%d %L %d %L", mins, id, (mins > 1) ? "MINUTES" : "MINUTE", secs, id, (secs > 1) ? "SECONDS" : "SECOND")
}

setTimeVoice(text[], len, flags, tmlf)
{
    new temp[7][32]
    new secs = tmlf % 60
    new mins = tmlf / 60
    
    for (new a = 0;a < 7;++a)
        temp[a][0] = 0

    if (secs > 0)
    {
        num_to_word(secs, temp[4], 31)
        
        if (!(flags & 8))
            temp[5] = "seconds "    /* there is no "second" in default hl */
    }
    
    if (mins > 59)
    {
        new hours = mins / 60
        
        num_to_word(hours, temp[0], 31)
        
        if (!(flags & 8))
            temp[1] = "hours "
        
        mins = mins % 60
    }
    
    if (mins > 0)
    {
        num_to_word(mins, temp[2], 31)
        
        if (!(flags & 8))
            temp[3] = "minutes "
    }
    
    if (!(flags & 4))
        temp[6] = "remaining "
    
    return format(text, len, "spk ^"vox/%s%s%s%s%s%s%s^"", temp[0], temp[1], temp[2], temp[3], temp[4], temp[5], temp[6])
}

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.85, 0, 0.0, 1.1, 0.1, 0.5, -1)
                    else
                        set_hudmessage(255, 255, 255, -1.0, 0.85, 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 ChatColor(const id, const input[], any:...)
{
    new count = 1, players[32]
    static msg[191]
    vformat(msg, 190, input, 3)

    replace_all(msg, 190, "!g", "^4") // Green Color
    replace_all(msg, 190, "!y", "^1") // Default Color
    replace_all(msg, 190, "!t", "^3") // Team Color

    if (id) players[0] = id; else get_players(players, count, "ch")
    {
        for (new i = 0; i < count; i++)
        {
            if (is_user_connected(players[i]))
            {
                message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
                write_byte(players[i]);
                write_string(msg);
                message_end();
            }
        }
    }
}

Спасибо огромное, тема закрыта!
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
  Ответить в данную темуНачать новую тему
 
0 пользователей и 1 гостей читают эту тему: