Originally Posted by The_Scope
He creado lo siguiente:
pawn Код:
public OngameModeInit() { SetTimer("Clock", 1000, 1); // Reloj actualizado cada 1 segundo
Textdraw99 = TextDrawCreate(450.000000,5.000000, "--"); Textdraw88 = TextDrawCreate(551.000000,23.000000,"--"); TextDrawAlignment(Textdraw99,0); TextDrawAlignment(Textdraw88,0); TextDrawBackgroundColor(Textdraw99,0x00000066); TextDrawBackgroundColor(Textdraw88,0x00000066); TextDrawFont(Textdraw99,2); TextDrawLetterSize(Textdraw99,0.499999,1.500000); TextDrawFont(Textdraw88,2); TextDrawLetterSize(Textdraw88,0.399999,2.000000); TextDrawColor(Textdraw99,0x00ffffff); TextDrawColor(Textdraw88,0x00ffffff); TextDrawSetOutline(Textdraw99,1); TextDrawSetOutline(Textdraw88,1); TextDrawSetProportional(Textdraw99,1); TextDrawSetProportional(Textdraw88,1); TextDrawSetShadow(Textdraw99,1); TextDrawSetShadow(Textdraw88,1); } public Clock(playerid) { new string[256]; new string2[256]; new year, month, day; new hour, minute, second; getdate(year, month, day); gettime(hour,minute,second); new mtext[20]; getdate(year, month, day); if(month == 1) { mtext = "Enero"; } else if(month == 2) { mtext = "Febrero"; } else if(month == 3) { mtext = "Marzo"; } else if(month == 4) { mtext = "Abril"; } else if(month == 5) { mtext = "Mayo"; } else if(month == 6) { mtext = "Junio"; } else if(month == 7) { mtext = "Julio"; } else if(month == 8) { mtext = "Augosto"; } else if(month == 9) { mtext = "Septiembre"; } else if(month == 10) { mtext = "Octubre"; } else if(month == 11) { mtext = "Noviembre"; } else if(month == 12) { mtext = "Diciembre"; } format(string, sizeof(string), "%d %s, %d", day, mtext, year); TextDrawSetString(Text:Textdraw99, string); format(string2, sizeof(string2), "%d:%d:%d", hour, minute, second); TextDrawSetString(Text:Textdraw88, string2); if(hour == 6 && minute == 00 && hour == 7 && minute == 00) { SetWeather(1); } // 6:00 y 7:00 Horas if(hour == 8 && minute == 00) { SetWorldTime(8); SetWeather(1); SendClientMessageToAll(COLOR_YELLOW,"SERVER: ЎEl gallo canta! Una nueva jornada comienza!. ЎQue tengas un buen dнa!"); }//8:00 Horas if(hour == 9 && minute == 00 && hour == 10 && minute == 00) { SetWeather(2); } // 9:00 y 10:00 Horas if(hour == 11 && minute == 00 && hour == 12 && minute == 00) { SetWeather(3); } // 11:00 y 12:00 Horas if(hour == 13 && minute == 00) { SetWeather(4); } // 13:00 Horas if(hour == 14 && minute == 00) { SetWorldTime(14); SetWeather(4); SendClientMessageToAll(COLOR_YELLOW,"SERVER: ЎUuuy! que Hambre... es un buen momento para ir a comer algo."); }// 14:00 Horas if(hour == 15 && minute == 00 && hour == 16 && minute == 00) { SetWeather(7); }// 15:00 y 16:00 Horas if(hour == 17 && minute == 00 && hour == 18 && minute == 00) { SetWeather(15); }// 17:00 y 18:00 Horas if(hour == 19 && minute == 00) { SetWeather(17); }// 19:00 Horas if(hour == 20 && minute == 45) { SetWorldTime(23); SetWeather(33); SendClientMessageToAll(COLOR_YELLOW,"SERVER: La jornada del dia termina, reunete con tu familia y disfruta una rica cena"); }// 20:45 Horas if(hour == 21 && minute == 00) { SetWeather(35); }// 21:00 Horas if(hour == 22 && minute == 00) { SetWorldTime(0); SetWeather(35); SendClientMessageToAll(COLOR_YELLOW,"SERVER: Ya es tarde, ve a descanzar. Recuerda que andar solo por la noche es peligroso."); }// 22:00 Horas if(hour == 23 && minute == 00 && hour == 0 && minute == 00 && hour == 1 && minute == 00 && hour == 2 && minute == 00 && hour == 3 && minute == 00 && hour == 4 && minute == 00 && hour == 5 && minute == 00) { SendRconCommand("weather 38"); }
}
En donde empieza esto:
pawn Код:
if(hour == 20 && minute == 45) { SetWorldTime(23); SetWeather(33); SendClientMessageToAll(COLOR_YELLOW,"SERVER: La jornada del dia termina, reunete con tu familia y disfruta una rica cena"); }// 20:45 Horas
Creo que a las 20 horas y 45 minutos el Clima se cambie al id 33, y el Tiempo (WorldTime) al id 23, y le envie un mensaje a todos los jugadores diciendo: "SERVER: La jornada del dia termina, reunete con tu familia y disfruta una rica cena".
La funcion funciona perfecto, pero el problema es que el el reloj se va actualizando cada 1 segundo para que funcione el "second" de "format(string2, sizeof(string2), "%d:%d:%d", hour, minute, second)" y esto proboca que el mensaje se repita cada 1 segundo cambiando el clima cada 1 segundo y el tiempo cada 1 segundo, probocando un flood que solo se para cuando se cambia de hora el server, volviendo a empezar de nuevo...
|