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