Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- author: bluescreen
- license: http://creativecommons.org/licenses/by-nc-sa/3.0/
- */
- #include <a_samp>
- #include <a_http>
- forward OnGetWeatherInfo(index, response_code, data[]);
- forward Weather();
- new WeatherTimer;
- public OnFilterScriptInit()
- {
- WeatherTimer = SetTimer("Weather", 59693*10, true);//update weather every 10 minutes
- print("\n--------------------------------------");
- print(" Realtime weather system by Bluescreen v0.1");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- KillTimer(WeatherTimer);
- return 1;
- }
- public OnGetWeatherInfo(index, response_code, data[])
- {
- new Description[128], WeatherID[128], weatherid;
- if(response_code == 200)
- {
- format(Description, sizeof(Description), "%s", data);
- strdel(Description, 0, strfind(Description, ":")+1);
- strdel(Description, strfind(Description, "<"), sizeof(Description));
- format(Description, 30, "%s", Description);
- format(WeatherID, sizeof(WeatherID), "%s", data);
- strdel(WeatherID, 0, strfind(WeatherID, "ID:")+3);
- weatherid = strval(WeatherID);
- format(Description, 128, "Current weather is: %s", Description);
- SendClientMessageToAll(-1, Description);
- }
- else
- {
- printf("change weather failed, code: %d", response_code);
- weatherid = 10;
- }
- SetWeather(weatherid);
- return 1;
- }
- public Weather()
- {
- HTTP(-1, HTTP_GET, "files.bluescreen.cz/samp/weather/index.php", "", "OnGetWeatherInfo");
- return 1;
- }
- main() {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement