Код
#include <amxmodx>
#define NEW_YEAR_TIME 1514764800 // date UNIX format // Время нового года в формате UNIX-Time
new const color_hud[3] = { 200, 200, 200 } // Можете задать цвет информера
new const Float:the_x = -1.0
new const Float:the_y = 0.05
// - - - - - - - - - - - - - - - - - - - - - - - -
#define ONEYEAR 31536000
#define ONEMONTH 2592000
#define ONEDAY 86400
#define ONEHOUR 3600
#define TASK_HUD 100
new const nyName[] = "До Нового Года:";
new sDateString[48];
new dateStrFormat[4][3][] = {
{ "год", "года", "лет" }, { "месяц", "месяца", "месяцев" }, { "день", "дня", "дней" }, { "час", "часа", "часов" }
}
public plugin_init() {
register_plugin("2018 timer","1.0","Leo_[BH] & Re.Act!ve");
if(NEW_YEAR_TIME+86400>get_systime())
set_task(4.0, "UpdateHudTask",TASK_HUD,_,_,"b");
else
log_amx("Новый год уже наступил. Плагин отключен.")
}
public UpdateHudTask()
{
date_to_string_format(sDateString, charsmax(sDateString));
if(get_systime() > NEW_YEAR_TIME)
{
set_hudmessage(random_num(0, 255), random_num(0, 255), random_num(0, 255), the_x, the_y, 0, 0.0, 4.1, 0.0, 0.4, -1);
show_hudmessage(0, "С НОВЫМ ГОДОМ!!!");
}
else
{
set_hudmessage(color_hud[0], color_hud[1], color_hud[2], the_x, the_y, 0, 0.0, 4.1, 0.0, 0.4, -1);
show_hudmessage(0, "%s^n%s", nyName, sDateString);
}
}
public date_to_string_format(string[], len)
{
new dType[4], Float:ny_time = float(NEW_YEAR_TIME-get_systime());
new newString[96], safeString[32];
dType[0] = floatround(ny_time/ONEYEAR, floatround_floor); ny_time-= dType[0]*ONEYEAR // years
dType[1] = floatround(ny_time/ONEMONTH, floatround_floor); ny_time-= dType[1]*ONEMONTH // mounths
dType[2] = floatround(ny_time/ONEDAY, floatround_floor); ny_time-= dType[2]*ONEDAY // days
dType[3] = floatround(ny_time/ONEHOUR, floatround_floor); ny_time-= dType[2]*ONEHOUR // hours and residuum minutes..
for(new i=0;i<4;i++) {
if(dType[i]==0) continue;
if(date_type_counts(dType[i], dateStrFormat[i][0], dateStrFormat[i][1], dateStrFormat[i][2], safeString, charsmax(safeString))==0) safeString="";
else format(newString,charsmax(newString), "%s%s",newString, safeString);
}
return copy(string, len, newString);
}
public date_type_counts(count, eds[], edno[], many[], str_output[], len) {
new strcount[3][32]; copy(strcount[0], 31, eds); copy(strcount[1], 31, edno); copy(strcount[2], 31, many);
new cases[] = {2, 0, 1, 1, 1, 2};
new wType = (count%100>4 && count%100<20) ? 2 : cases[min(count%10, 5)];
formatex(str_output, len, "%d %s ", count, strcount[wType]);
return wType;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Особая благодарность: Re.Act!ve
// Автор плагина: Leo_[BH] - http://vk.com/id64427766
// Написание плагинов на заказ: http://vk.com/cs_rain
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -