всем здрасти как лучше найти нужное нам дату в условии
как такое реализовать напр дд.мм.гг сравнить с текущей
или все переводить в дни часы и как учитывать количество
дней в месяцы.
Shadows In Rain писал(а): Сейчас "рынок" плагинов напоминает какой-то нелегальный подвальный клуб, куда приходит непонятно кто, заказывает непонятно что, а за косяки приезжает разбираться с братвой на уазиках.
Модераторы: Subb98, liFe iS GoOD
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
register_clcmd("say test", "check_Time")
}
public check_Time()
{
static minutes[10], length, unban_time[32], dday[32], mmonth[32], yyear[32];
length = str_to_num(minutes);
Get_Time(length, dday, sizeof(dday)- 1, mmonth, sizeof(mmonth)- 1, yyear, sizeof(yyear)- 1);
client_print(0, print_chat, "Time: %s.%s.%s", dday, mmonth, yyear)
}
Get_Time(const bantime, dday[], len1, mmonth[], len2, yyear[], len3) // code "Exolent" fix "Egor1496"
{
static _hours[5], _minutes[5], _seconds[5], _month[5], _day[5], _year[7];
format_time(_hours, sizeof(_hours) - 1, "%H");
format_time(_minutes, sizeof(_minutes) - 1, "%M");
format_time(_seconds, sizeof(_seconds) - 1, "%S");
format_time(_month, sizeof(_month) - 1, "%m");
format_time(_day, sizeof(_day) - 1, "%d");
format_time(_year, sizeof(_year) - 1, "%Y");
new hours = str_to_num(_hours);
new minutes = str_to_num(_minutes);
new seconds = str_to_num(_seconds);
new month = str_to_num(_month);
new day = str_to_num(_day);
new year = str_to_num(_year);
minutes += minutes;
// while( minutes >= 60 )
// {
// minutes -= 60;
// hours++;
// }
hours += minutes / 60
minutes = minutes % 60
// while( hours >= 24 )
// {
// hours -= 24;
// day++;
//}
day += hours / 24
hours = hours % 24
new max_days = GetDaysInMonth(month, year);
// while( day > max_days )
// {
// day -= max_days;
// month++;
// }
month += day / max_days
day = day % max_days
// while( month > 12 )
// {
// month -= 12;
// year++;
// }
year += month / 12
month = month % 12
formatex(dday, len1, "%i", day);
formatex(mmonth, len2, "%i", month);
formatex(yyear, len3, "%i", year);
}
GetDaysInMonth(month, year=0)
{
switch( month )
{
case 1: return 31; // january
case 2: return ((year % 4) == 0) ? 29 : 28; // february
case 3: return 31; // march
case 4: return 30; // april
case 5: return 31; // may
case 6: return 30; // june
case 7: return 31; // july
case 8: return 31; // august
case 9: return 30; // september
case 10: return 31; // october
case 11: return 30; // november
case 12: return 31; // december
}
return 30;
}
public check_Time()
{
static minutes[10], length, unban_time[32], dday[32], mmonth[32], yyear[32];
length = str_to_num(minutes);
Get_Time(length, dday, sizeof(dday)- 1, mmonth, sizeof(mmonth)- 1, yyear, sizeof(yyear)- 1);
new arrm_month[] = {31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}
new day_to_hourse = (str_to_num(dday) * 24)
new month_to_hourse = (arrm_month[str_to_num(mmonth) - 1] * 24)
new year_to_hourse = (str_to_num(yyear) * 365 * 24)
client_print(0, print_chat, "Time: %i-%i-%i", dday, mmonth, yyear)
client_print(0, print_chat, "Time: %i", day_to_hourse + month_to_hourse + year_to_hourse)
}
Get_Time(const bantime, dday[], len1, mmonth[], len2, yyear[], len3) // cod "Exolent"
{
static _hours[5], _minutes[5], _seconds[5], _month[5], _day[5], _year[7];
format_time(_hours, sizeof(_hours) - 1, "%H");
format_time(_minutes, sizeof(_minutes) - 1, "%M");
format_time(_seconds, sizeof(_seconds) - 1, "%S");
format_time(_month, sizeof(_month) - 1, "%m");
format_time(_day, sizeof(_day) - 1, "%d");
format_time(_year, sizeof(_year) - 1, "%Y");
new hours = str_to_num(_hours);
new minutes = str_to_num(_minutes);
new seconds = str_to_num(_seconds);
new month = str_to_num(_month);
new day = str_to_num(_day);
new year = str_to_num(_year);
minutes += minutes;
// while( minutes >= 60 )
// {
// minutes -= 60;
// hours++;
// }
hours += minutes / 60
minutes = minutes % 60
// while( hours >= 24 )
// {
// hours -= 24;
// day++;
//}
day += hours / 24
hours = hours % 24
new max_days = GetDaysInMonth(month, year);
// while( day > max_days )
// {
// day -= max_days;
// month++;
// }
month += day / max_days
day = day % max_days
// while( month > 12 )
// {
// month -= 12;
// year++;
// }
year += month / 12
month = month % 12
formatex(dday, len1, "%i", day);
formatex(mmonth, len2, "%i", month);
formatex(yyear, len3, "%i", year);
//formatex(unban_time, len, "%i:%02i:%02i %i/%i/%i", hours, minutes, seconds, month, day, year);
//formatex(unban_time, len, "%i.%i.%i", day, month, year);
}
GetDaysInMonth(month, year=0)
{
switch( month )
{
case 1: return 31; // january
case 2: return ((year % 4) == 0) ? 29 : 28; // february
case 3: return 31; // march
case 4: return 30; // april
case 5: return 31; // may
case 6: return 30; // june
case 7: return 31; // july
case 8: return 31; // august
case 9: return 30; // september
case 10: return 31; // october
case 11: return 30; // november
case 12: return 31; // december
}
return 30;
}
new CurrentTime[64];
get_time("%H:%M:%S %m:%d:%Y",CurrentTime,charsmax(CurrentTime));
g_CurrTimeStamp = parse_time(CurrentTime, "%H:%M:%S %m:%d:%Y");
new g_FinTimeStamp;
g_FinTimeStamp = parse_time(g_FinTime, "%H:%M:%S %m:%d:%Y");
if(g_CurrTimeStamp < g_FinTimeStamp || equal(g_FinTime, "-1")){
//set_user_flags(id, read_flags("abcdefghijklmnopqrstu"))
}
так а в чём проблема, записывай всё в UNIX после точки с запятой, а проверку делать когда игрок заходит на сервер
RSO_ писал(а):так а в чём проблема, записывай всё в UNIX после точки с запятой, а проверку делать когда игрок заходит на сервер
а есть рабочий пример
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 18