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