Доброго времени суток.
Не могли бы поделиться командой /time на процессоре ZCMD.
Чтобы было дата: (день/месяц/год)
Время: (час/минуты/секунды)
Вид для печати
Доброго времени суток.
Не могли бы поделиться командой /time на процессоре ZCMD.
Чтобы было дата: (день/месяц/год)
Время: (час/минуты/секунды)
Тебе нужно чтоб было в диалоге?
Да забыл упомянуть, в диалоге
PHP код:
CMD:time(playerid, params[])
{
new mtext[20];
new year, month,day;
getdate(year, month, day);
if(month == 1) { mtext = "January"; }
else if(month == 2) { mtext = "February"; }
else if(month == 3) { mtext = "March"; }
else if(month == 4) { mtext = "April"; }
else if(month == 5) { mtext = "May"; }
else if(month == 6) { mtext = "June"; }
else if(month == 7) { mtext = "Juli"; }
else if(month == 8) { mtext = "August"; }
else if(month == 9) { mtext = "September"; }
else if(month == 10) { mtext = "October"; }
else if(month == 11) { mtext = "November"; }
else if(month == 12) { mtext = "December"; }
new hour,minuite,second,string[84];
gettime(hour,minuite,second);
format(string, sizeof(string), "Время: %d часа %d минут %d секунд\nСегодня: %d %s %d год",hour,minuite,second,day,mtext,year);
ShowPlayerDialog(playerid,id диалога,DIALOG_STYLE_MSGBOX,"Время",string,"Закрыть","");
ApplyAnimation(playerid,"COP_AMBIENT","Coplook_watch",4.1,0,0,0,0,0,1);
return true;
}
Вот стильная, модная и молодёжная версия кода от меня
Надеюсь меня простятPHP код:
CMD:time(playerid, params[])
{
new string[84];
new year,
month,
day;
getdate(year, month, day);
switch(month)
{
case 1: string = "January";
case 2: string = "February";
case 3: string = "March";
case 4: string = "April";
case 5: string = "May";
case 6: string = "June";
case 7: string = "Juli";
case 8: string = "August";
case 9: string = "September";
case 10: string = "October";
case 11: string = "November";
case 12: string = "December";
}
new hour, minuite, second;
gettime(hour,minuite,second);
format(string, sizeof(string), "Время: %d часа %d минут %d секунд\nСегодня: %d %s %d год", hour, minuite, second, day, string, year);
ShowPlayerDialog(playerid, /*id диалога*/, DIALOG_STYLE_MSGBOX, "Время", string, "Закрыть", "");
ApplyAnimation(playerid, "COP_AMBIENT", "Coplook_watch", 4.1, 0, 0, 0, 0, 0, 1);
return true;
}
Зачем каждый раз создавать переменную и записывать в нее значения каждого месяца?Цитата:
switch(month)
{
case 1: string = "January";
case 2: string = "February";
case 3: string = "March";
case 4: string = "April";
case 5: string = "May";
case 6: string = "June";
case 7: string = "Juli";
case 8: string = "August";
case 9: string = "September";
case 10: string = "October";
case 11: string = "November";
case 12: string = "December";
}
PHP код:
static months[][ 10 ] = {
"January",
"February",
"March",
"April",
"May",
"June",
"Juli",
"August",
"September",
"October",
"November",
"December"
};
CMD:time(playerid, params[])
{
new string[84];
new year,
month,
day;
getdate(year, month, day);
new hour, minuite, second;
gettime(hour,minuite,second);
format(string, sizeof(string), "Время: %d часа %d минут %d секунд\nСегодня: %d %s %d год", hour, minuite, second, day, months[ month - 1 ] , year);
ShowPlayerDialog(playerid, /*id диалога*/, DIALOG_STYLE_MSGBOX, "Время", string, "Закрыть", "");
ApplyAnimation(playerid, "COP_AMBIENT", "Coplook_watch", 4.1, 0, 0, 0, 0, 0, 1);
return true;
}