1. #include <a_samp>
  2. #include <a_http>
  3. //-----------------------------------------//
  4. /* DON'T CHANGE THIS: */
  5. forward UpdateWeatherStatus();
  6. new RSW_Weather;
  7. forward GetRealWeather(index,response_code, data[]);
  8. // The Acutal code MXJO0043 is from Guadalajara, Jalisco, Mexico.
  9. #define COUNTRY_CODE "MXJO0043"
  10. #define MAX_STRING 255
  11. /* - HOW TO GET CUSTOM COUNTRY CODE -
  12. 1.- Enter to: http://www.weather.com/weather/extended/
  13. 2.- Enter Your Country / City in te search bar. (Image: )
  14. 3.- Click In "SEARCH"
  15. 4.- Copy the country code from the website URL. (Image: )
  16. 5.- Paste in define COUNTRY_CODE "YOUR CODE HERE".
  17. 6.- End.
  18. */
  19. //-----------------------------------------//
  20. public OnFilterScriptInit()
  21. {
  22. printf("\n-------------->");
  23. printf("\n - Real SA-MP Weather By xDarkuzSx: Loaded.");
  24. printf("\n-------------->");
  25. UpdateWeatherStatus(); // Update Weather for initializing..
  26. SetTimer("UpdateWeatherStatus", 300000, false);//5 minutes to RE-update weather.
  27. return 1;
  28. }
  29. public OnFilterScriptExit()
  30. {
  31. printf("\n * -------------->");
  32. printf("\n - Real SA-MP Weather By xDarkuzSx: UnLoaded.");
  33. printf("\n * -------------->");
  34. return 1;
  35. }
  36. public UpdateWeatherStatus()
  37. {
  38. /* Send Request to the Website */
  39. new strRequest[256];
  40. format(strRequest,sizeof(strRequest),"www.Real-SAMP-Weather.Tk/RSW_GET.php?code=%s",COUNTRY_CODE);
  41. HTTP(0,HTTP_GET,strRequest,"","GetRealWeather");
  42. return 1;
  43. }
  44. stock WeatherSuccess()
  45. {
  46. switch (RSW_Weather)
  47. {
  48. case 0, 1, 2, 3, 4, 17, 35, 37, 38, 47, 48: {SetWeather(8); RSW_Weather = 8;}
  49. case 5, 6, 7, 8, 9, 10, 11, 12, 18, 39, 40, 45: {SetWeather(16); RSW_Weather = 16;}
  50. case 13, 14, 15, 16, 41, 42, 43, 46: {SetWeather(16); RSW_Weather = 16;}
  51. case 19, 21, 22, 23: {SetWeather(2); RSW_Weather = 2;}
  52. case 26: {SetWeather(36); RSW_Weather = 36;}
  53. case 27, 28, 29, 30, 36: {SetWeather(33); RSW_Weather = 33;}
  54. case 31, 32, 33, 34: {SetWeather(46); RSW_Weather = 46;}
  55. }
  56. SetAllWeather(RSW_Weather);
  57. SetTimer("UpdateWeatherStatus", 300000, false);//5 Minutes
  58. }
  59. public GetRealWeather(index,response_code, data[])
  60. {
  61. new RSW_Response[256];
  62. if(response_code == 200)
  63. {
  64. format(RSW_Response, sizeof(RSW_Response), "%s",data);
  65. RSW_Weather = strval(data);
  66. WeatherSuccess();
  67. }
  68. else
  69. {
  70. format(RSW_Response, sizeof(RSW_Response), " I Can't Get Real Weather, ERROR CODE: %d", response_code);
  71. print(RSW_Response);
  72. }
  73. }
  74. stock SetAllWeather(id)
  75. {
  76. for(new x = 0; x < MAX_PLAYERS; x++){if(IsPlayerConnected(x)){ SetPlayerWeather(x, id);}}
  77. }

RSW FOR SA-MP