Advertisement
_Bluescreen_

weather system (filterscript)

Feb 18th, 2016
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.55 KB | None | 0 0
  1. /*
  2.     author: bluescreen
  3.     license: http://creativecommons.org/licenses/by-nc-sa/3.0/
  4. */
  5.  
  6. #include <a_samp>
  7. #include <a_http>
  8.  
  9. forward OnGetWeatherInfo(index, response_code, data[]);
  10. forward Weather();
  11.  
  12. new WeatherTimer;
  13.  
  14. public OnFilterScriptInit()
  15. {
  16.     WeatherTimer = SetTimer("Weather", 59693*10, true);//update weather every 10 minutes
  17.     print("\n--------------------------------------");
  18.     print(" Realtime weather system by Bluescreen v0.1");
  19.     print("--------------------------------------\n");
  20.     return 1;
  21. }
  22.  
  23. public OnFilterScriptExit()
  24. {
  25.     KillTimer(WeatherTimer);
  26.     return 1;
  27. }
  28.  
  29. public OnGetWeatherInfo(index, response_code, data[])
  30. {
  31.     new Description[128], WeatherID[128], weatherid;
  32.     if(response_code == 200)
  33.     {
  34.         format(Description, sizeof(Description), "%s", data);
  35.         strdel(Description, 0, strfind(Description, ":")+1);
  36.         strdel(Description, strfind(Description, "<"), sizeof(Description));
  37.         format(Description, 30, "%s", Description);
  38.         format(WeatherID, sizeof(WeatherID), "%s", data);
  39.         strdel(WeatherID, 0, strfind(WeatherID, "ID:")+3);
  40.         weatherid = strval(WeatherID);
  41.         format(Description, 128, "Current weather is: %s", Description);
  42.         SendClientMessageToAll(-1, Description);
  43.     }
  44.     else
  45.     {
  46.         printf("change weather failed, code: %d", response_code);
  47.         weatherid = 10;
  48.     }
  49.     SetWeather(weatherid);
  50.     return 1;
  51. }
  52.  
  53. public Weather()
  54. {
  55.     HTTP(-1, HTTP_GET, "files.bluescreen.cz/samp/weather/index.php", "", "OnGetWeatherInfo");
  56.     return 1;
  57. }
  58.  
  59. main() {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement