Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <ZCMD>
- static Text:BOX[2];
- static Text:IMG[2];
- static Text:Date[2];
- static Text:Days;
- static Text:NumberDate[7];
- static Text:MiniCalendary[2];
- static SyncTimer;
- static const DayName[][] = {"Lunes", "Martes", "Miercoles", "Jueves", "Jueves", "Viernes", "Sabado", "Domingo"};
- static const MonthName[][] = {"Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"};
- public OnFilterScriptInit()
- {
- print("\n*************************************");
- print("* Sistema de calendario - por EnzoMetlc *");
- print("*************************************\n");
- /* Imagen del calendario */
- BOX[0] = TextDrawCreate(230.000000, 129.000000, "_");
- TextDrawBackgroundColor(BOX[0], 255);
- TextDrawFont(BOX[0], 1);
- TextDrawLetterSize(BOX[0], 1.301000, 17.100000);
- TextDrawColor(BOX[0], -1);
- TextDrawSetOutline(BOX[0], 0);
- TextDrawSetProportional(BOX[0], 1);
- TextDrawSetShadow(BOX[0], 1);
- TextDrawUseBox(BOX[0], 1);
- TextDrawBoxColor(BOX[0], 100);
- TextDrawTextSize(BOX[0], 31.000000, 0.000000);
- BOX[1] = TextDrawCreate(230.000000, 174.000000, "_");
- TextDrawBackgroundColor(BOX[1], 255);
- TextDrawFont(BOX[1], 1);
- TextDrawLetterSize(BOX[1], 0.500000, -0.900000);
- TextDrawColor(BOX[1], -1);
- TextDrawSetOutline(BOX[1], 0);
- TextDrawSetProportional(BOX[1], 1);
- TextDrawSetShadow(BOX[1], 1);
- TextDrawUseBox(BOX[1], 1);
- TextDrawBoxColor(BOX[1], -10092374);
- TextDrawTextSize(BOX[1], 31.000000, 0.000000);
- IMG[0] = TextDrawCreate(25.000000, 121.000000, "-");
- TextDrawBackgroundColor(IMG[0], 255);
- TextDrawFont(IMG[0], 1);
- TextDrawLetterSize(IMG[0], 14.890000, 1.000000);
- TextDrawColor(IMG[0], -1);
- TextDrawSetOutline(IMG[0], 1);
- TextDrawSetProportional(IMG[0], 1);
- IMG[1] = TextDrawCreate(39.000000, 116.000000, "c c c c c c c c c c c c c c c");
- TextDrawBackgroundColor(IMG[1], 255);
- TextDrawFont(IMG[1], 1);
- TextDrawLetterSize(IMG[1], 0.401000, 1.800000);
- TextDrawColor(IMG[1], -1);
- TextDrawSetOutline(IMG[1], 1);
- TextDrawSetProportional(IMG[1], 1);
- /* Fecha y hora */
- Date[0] = TextDrawCreate(133.000000, 129.000000, "_");
- TextDrawAlignment(Date[0], 2);
- TextDrawBackgroundColor(Date[0], 255);
- TextDrawFont(Date[0], 2);
- TextDrawLetterSize(Date[0], 0.930000, 2.700000);
- TextDrawColor(Date[0], -1);
- TextDrawSetOutline(Date[0], 1);
- TextDrawSetProportional(Date[0], 1);
- Date[1] = TextDrawCreate(133.000000, 152.000000, "_");
- TextDrawAlignment(Date[1], 2);
- TextDrawBackgroundColor(Date[1], 255);
- TextDrawFont(Date[1], 1);
- TextDrawLetterSize(Date[1], 0.390000, 1.400000);
- TextDrawColor(Date[1], -1);
- TextDrawSetOutline(Date[1], 1);
- TextDrawSetProportional(Date[1], 1);
- /* Días */
- Days = TextDrawCreate(131.000000, 171.000000, "L M M J V ~r~~h~S D");
- TextDrawAlignment(Days, 2);
- TextDrawBackgroundColor(Days, 255);
- TextDrawFont(Days, 2);
- TextDrawLetterSize(Days, 0.469999, 1.799998);
- TextDrawColor(Days, -1);
- TextDrawSetOutline(Days, 1);
- TextDrawSetProportional(Days, 0);
- /* Número del día de la semana */
- NumberDate[0] = TextDrawCreate(50.000000, 195.000000, "_");
- TextDrawAlignment(NumberDate[0], 2);
- TextDrawBackgroundColor(NumberDate[0], 255);
- TextDrawFont(NumberDate[0], 1);
- TextDrawLetterSize(NumberDate[0], 0.309998, 1.600000);
- TextDrawColor(NumberDate[0], -1);
- TextDrawSetOutline(NumberDate[0], 1);
- TextDrawSetProportional(NumberDate[0], 1);
- NumberDate[1] = TextDrawCreate(78.000000, 195.000000, "_");
- TextDrawAlignment(NumberDate[1], 2);
- TextDrawBackgroundColor(NumberDate[1], 255);
- TextDrawFont(NumberDate[1], 1);
- TextDrawLetterSize(NumberDate[1], 0.309998, 1.600000);
- TextDrawColor(NumberDate[1], -1);
- TextDrawSetOutline(NumberDate[1], 1);
- TextDrawSetProportional(NumberDate[1], 1);
- NumberDate[2] = TextDrawCreate(105.000000, 195.000000, "_");
- TextDrawAlignment(NumberDate[2], 2);
- TextDrawBackgroundColor(NumberDate[2], 255);
- TextDrawFont(NumberDate[2], 1);
- TextDrawLetterSize(NumberDate[2], 0.309998, 1.600000);
- TextDrawColor(NumberDate[2], -1);
- TextDrawSetOutline(NumberDate[2], 1);
- TextDrawSetProportional(NumberDate[2], 1);
- NumberDate[3] = TextDrawCreate(130.000000, 195.000000, "_");
- TextDrawAlignment(NumberDate[3], 2);
- TextDrawBackgroundColor(NumberDate[3], 255);
- TextDrawFont(NumberDate[3], 1);
- TextDrawLetterSize(NumberDate[3], 0.309998, 1.600000);
- TextDrawColor(NumberDate[3], -1);
- TextDrawSetOutline(NumberDate[3], 1);
- TextDrawSetProportional(NumberDate[3], 1);
- NumberDate[4] = TextDrawCreate(157.000000, 195.000000, "_");
- TextDrawAlignment(NumberDate[4], 2);
- TextDrawBackgroundColor(NumberDate[4], 255);
- TextDrawFont(NumberDate[4], 1);
- TextDrawLetterSize(NumberDate[4], 0.309998, 1.600000);
- TextDrawColor(NumberDate[4], -1);
- TextDrawSetOutline(NumberDate[4], 1);
- TextDrawSetProportional(NumberDate[4], 1);
- NumberDate[5] = TextDrawCreate(183.000000, 195.000000, "_");
- TextDrawAlignment(NumberDate[5], 2);
- TextDrawBackgroundColor(NumberDate[5], 255);
- TextDrawFont(NumberDate[5], 1);
- TextDrawLetterSize(NumberDate[5], 0.309998, 1.600000);
- TextDrawColor(NumberDate[5], -1);
- TextDrawSetOutline(NumberDate[5], 1);
- TextDrawSetProportional(NumberDate[5], 1);
- NumberDate[6] = TextDrawCreate(209.000000, 195.000000, "_");
- TextDrawAlignment(NumberDate[6], 2);
- TextDrawBackgroundColor(NumberDate[6], 255);
- TextDrawFont(NumberDate[6], 1);
- TextDrawLetterSize(NumberDate[6], 0.309998, 1.600000);
- TextDrawColor(NumberDate[6], -1);
- TextDrawSetOutline(NumberDate[6], 1);
- TextDrawSetProportional(NumberDate[6], 1);
- /* Mini-calendario */
- MiniCalendary[0] = TextDrawCreate(163.000000, 132.000000, "_");
- TextDrawBackgroundColor(MiniCalendary[0], 255);
- TextDrawFont(MiniCalendary[0], 1);
- TextDrawLetterSize(MiniCalendary[0], -0.300000, 3.400000);
- TextDrawColor(MiniCalendary[0], -1);
- TextDrawSetOutline(MiniCalendary[0], 0);
- TextDrawSetProportional(MiniCalendary[0], 1);
- TextDrawSetShadow(MiniCalendary[0], 1);
- TextDrawUseBox(MiniCalendary[0], 1);
- TextDrawBoxColor(MiniCalendary[0], 25700);
- TextDrawTextSize(MiniCalendary[0], 32.000000, 0.000000);
- MiniCalendary[1] = TextDrawCreate(98.000000, 130.000000, "_");
- TextDrawAlignment(MiniCalendary[1], 2);
- TextDrawBackgroundColor(MiniCalendary[1], 255);
- TextDrawFont(MiniCalendary[1], 2);
- TextDrawLetterSize(MiniCalendary[1], 0.280000, 1.800000);
- TextDrawColor(MiniCalendary[1], -1);
- TextDrawSetOutline(MiniCalendary[1], 1);
- TextDrawSetProportional(MiniCalendary[1], 1);
- new sec, year, month, day, str[25];
- gettime(sec, sec, sec);
- SyncTimer = SetTimer("UpdateCalendary", (60 - sec) * 1000, true);
- getdate(year, month, day);
- format(str, sizeof(str), "%s, %i de %s", DayName[GetDayOfWeek(day, month, year) - 1], day, MonthName[month - 1]);
- TextDrawSetString(Date[1], str);
- UpdateDate();
- return 1;
- }
- CMD:calendario(playerid)
- {
- TextDrawHideForPlayer(playerid, MiniCalendary[0]);
- TextDrawHideForPlayer(playerid, MiniCalendary[1]);
- TextDrawShowForPlayer(playerid, BOX[0]);
- TextDrawShowForPlayer(playerid, BOX[1]);
- TextDrawShowForPlayer(playerid, IMG[0]);
- TextDrawShowForPlayer(playerid, IMG[1]);
- TextDrawShowForPlayer(playerid, Date[0]);
- TextDrawShowForPlayer(playerid, Date[1]);
- TextDrawShowForPlayer(playerid, Days);
- for(new i = 0; i < 7; i++) TextDrawShowForPlayer(playerid, NumberDate[i]);
- return 1;
- }
- CMD:mini(playerid)
- {
- TextDrawHideForPlayer(playerid, BOX[0]);
- TextDrawHideForPlayer(playerid, BOX[1]);
- TextDrawHideForPlayer(playerid, IMG[0]);
- TextDrawHideForPlayer(playerid, IMG[1]);
- TextDrawHideForPlayer(playerid, Date[0]);
- TextDrawHideForPlayer(playerid, Date[1]);
- TextDrawHideForPlayer(playerid, Days);
- for(new i = 0; i < 7; i++) TextDrawHideForPlayer(playerid, NumberDate[i]);
- TextDrawShowForPlayer(playerid, MiniCalendary[0]);
- TextDrawShowForPlayer(playerid, MiniCalendary[1]);
- return 1;
- }
- /* Funciones */
- stock UpdateDate()
- {
- new st, month, year, day, max_days[2], str[128], temp[3][10];
- getdate(year, month, day);
- st = GetDayOfWeek(1, month, year) - 1; // Primer día del mes.
- max_days[0] = ((month - 1) != 0) ? (GetMaxDaysOfMonth(year, month - 1)) : (GetMaxDaysOfMonth(year, 12));
- max_days[1] = GetMaxDaysOfMonth(year, month);
- for(new i = 1; i <= 7; i++)
- {
- new const week1 = (i <= st) ? (max_days[0] - st + i) : (i - st);
- new const week2 = (week1 <= 7) ? (week1 + 7) : ((week1 + 7) - max_days[0]);
- new const week5 = ((week2 + 21) <= max_days[1]) ? (week2 + 21) : ((week2 + 21) - max_days[1]);
- new const week6 = ((week5 + 7) <= max_days[1]) ? (week5 + 7) : ((week5 + 7) - max_days[1]);
- if(week1 >= 25) format(temp[0], 10, "~b~~h~%i", week1);
- else format(temp[0], 3, "%i", week1);
- if(week5 <= 15) format(temp[1], 10, "~b~~h~%i", week5);
- else format(temp[1], 3, "%i", week5);
- if(week6 <= 15) format(temp[2], 10, "~b~~h~%i", week6);
- else format(temp[2], 3, "%i", week6);
- format(str, sizeof(str), "%s~w~~n~%i~n~%i~n~%i~n~%s~n~%s", temp[0], week2, week2 + 7, week2 + 14, temp[1], temp[2]);
- TextDrawSetString(NumberDate[i - 1], str);
- }
- return 1;
- }
- stock GetMaxDaysOfMonth(year, month)
- {
- if(month == 2) return ((year % 4) == 0) ? (29) : (28);
- new const MaxDayOfMonth[12] = {31, -1, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
- return MaxDayOfMonth[month - 1];
- }
- /* GetDayOfWeek (zTime.inc - by _Zume, editado por mí) */
- stock GetDayOfWeek(day, month, year)
- {
- new d_[4];
- d_[0] = (14 - month) / 12;
- d_[2] = year - d_[0];
- d_[1] = month + (12 * d_[0]) - 2;
- d_[3] = (day + d_[2] + (d_[2] / 4) - (d_[2] / 100) + (d_[2] / 400) + (31 * d_[1]) / 12) % 7;
- if(d_[3] == 0) d_[3] = 7;
- return d_[3];
- }
- //-------
- forward UpdateCalendary();
- public UpdateCalendary()
- {
- new hour, minute, second, string[35];
- new year, month, day;
- getdate(year, month, day);
- gettime(hour, minute, second);
- format(string, 8, "%i:%02i", hour, minute);
- TextDrawSetString(Date[0], string);
- /* Actualizar mini-calendario */
- new dayname[4];
- format(dayname, 4, "%s", DayName[GetDayOfWeek(day, month, year) - 1]);
- format(string, sizeof(string), "~r~%i:%i~n~~w~%02i/%02i/%i - %s", hour, minute, day, month, year, dayname);
- TextDrawSetString(MiniCalendary[1], string);
- if(second != 0) // Sincronizar el temporizador
- {
- KillTimer(SyncTimer);
- SyncTimer = SetTimer("UpdateCalendary", (60 - second) * 1000, true);
- }
- if(hour == 0) // Actualizar la fecha
- {
- new str[25];
- format(str, sizeof(str), "%s, %i de %s", DayName[GetDayOfWeek(day, month, year) - 1], day, MonthName[month - 1]);
- TextDrawSetString(Date[1], str);
- }
- if(day == 0) UpdateDate(); // Actualizar el calendario
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement