1. #include <a_samp>
  2. #include <a_mysql>
  3. #define MYSQL_SERVER "HOST"
  4. #define MYSQL_USER "USUARIO"
  5. #define MYSQL_PASSWORD "CONTRASEÑA"
  6. #define MYSQL_DB "BASE DE DATOS"
  7. forward ActualizarClima();
  8. new NumeroClima[2];
  9. public OnFilterScriptInit()
  10. {
  11. print("\n--------------------------------------");
  12. print("Sistema de Clima Real por The Scope");
  13. print("--------------------------------------\n");
  14. mysql_connect(#MYSQL_SERVER,#MYSQL_USER,#MYSQL_USER,#MYSQL_PASSWORD);
  15. ActualizarClima();
  16. return 1;
  17. }
  18. public OnFilterScriptExit()
  19. {
  20. mysql_close();
  21. return 1;
  22. }
  23. public ActualizarClima()
  24. {
  25. new query[300], savingstring[20];
  26. format(query, sizeof(query), "SELECT * FROM ClimaRealista");
  27. mysql_query(query);
  28. mysql_store_result();
  29. while(mysql_fetch_row_format(query,"|"))
  30. {
  31. mysql_fetch_field_row(savingstring, "NumeroClima"); NumeroClima[0] = strval(savingstring);
  32. mysql_fetch_field_row(savingstring, "DiaNoche"); NumeroClima[1] = strval(savingstring);
  33. }
  34. mysql_free_result();
  35. switch (NumeroClima[1])
  36. {
  37. case 0: SetWorldTime(12); // Noche
  38. case 1: SetWorldTime(0); // Día
  39. }
  40. switch (NumeroClima[0])
  41. {
  42. case 0, 1, 2, 3, 4, 17, 35, 37, 38, 47, 48: SetWeather(8); // Tormenta
  43. case 5, 6, 7, 8, 9, 10, 11, 12, 18, 39, 40, 45: SetWeather(16); // Lluvia
  44. case 13, 14, 15, 16, 41, 42, 43, 46: SetWeather(16); // Nieve
  45. case 19, 21, 22, 23: SetWeather(2); // Nievla Soleado
  46. case 26: SetWeather(36); // Nubleado
  47. case 27, 28, 29, 30, 36: SetWeather(33); // Nubleado Soleado
  48. case 31, 32, 33, 34: SetWeather(46); // Soleado
  49. }
  50. SetTimer("ActualizarClima", 300000, false);//5 Minutos
  51. }