Advertisement
Julian90

Tiempo Automatico

Aug 3rd, 2011
630
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.55 KB | None | 0 0
  1. /*
  2.     - Sistema de Clima -
  3.     - Autor: [J]ulian ( Script Base: http://forum.sa-mp.com/showthread.php?t=273751 ).
  4.     - Para: sa-mp.com
  5. */
  6. #include <a_samp>
  7.  
  8. new TiempoTimer, rand;
  9.  
  10. #define TIEMPO_MIN 3 // Tiempo mínimo.
  11. #define MAX_RANDOM 6 // Random porque cual se multiplicará nuestro tiempo ( 3, 6, 9, 12, 15 minutos... )
  12.  
  13. public OnGameModeInit()
  14. {
  15.     TiempoActualizar();
  16.     rand = random(MAX_RANDOM);
  17.     return 1;
  18. }
  19.  
  20. public OnPlayerCommandText(playerid, cmdtext[])
  21. {
  22.     if(!strcmp("/tiempo", cmdtext, true))
  23.     {
  24.         SendClientMessage(playerid, -1, "* Has actualizado a un nuevo tiempo.");
  25.         TiempoActualizar();
  26.     }
  27.     return 1;
  28. }
  29.  
  30. forward TiempoActualizar();
  31. public TiempoActualizar()
  32. {
  33.     new
  34.         tiempo[2];
  35.     gettime(tiempo[0], tiempo[1]);
  36.     SetWorldTime(tiempo[0]);
  37.     if(7 < tiempo[0] && tiempo[0] < 17)
  38.     {
  39.         new WeatherDia[] = { 2, 4, 7, 8, 9, 12, 15, 19, 21, 25, 27 };
  40.         rand = random(10);
  41.         SetWeather(random(WeatherDia[rand]));
  42.         SendClientMessageToAll(-1, "* El tiempo de día fue cambiado automáticamente.");
  43.         printf("Weather Dia: \"%i\".", rand);
  44.     }
  45.     else
  46.     {
  47.         new WeatherNoche[7] = { 16, 32, 38, 42, 43, 50 };
  48.         rand = random(6);
  49.         SetWeather(random(WeatherNoche[rand]));
  50.         SendClientMessageToAll(-1, "* El tiempo de noche fue cambiado automáticamente.");
  51.         printf("Weather Noche: \"%i\".", rand);
  52.     }
  53.     KillTimer(TiempoTimer);
  54.     rand = random(MAX_RANDOM);
  55.     TiempoTimer = SetTimer("TiempoActualizar", ( TIEMPO_MIN * 60000 ) * rand, true);
  56.     printf("Nuevo tiempo en: \"%i\" minutos.", TIEMPO_MIN * rand );
  57.     return 1;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement