Advertisement
Guest User

[FilterScript] Tempo Real - by: FreeGells

a guest
Jan 5th, 2013
1,608
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.24 KB | None | 0 0
  1. /*
  2.                 Tempo Real
  3.  
  4.     Agradecimentos:
  5.         - Lucas 'Lós' Souza,
  6.         - Bruno 'ipsBruno' Silva,
  7.         - SA-MP Team
  8.     Créditos:
  9.         - Eduardo 'FreeGells' Knebel
  10. */
  11.  
  12. #include < a_samp >
  13. #include < a_http >
  14.  
  15. #define cidade "sao-paulo"
  16. #define h_atualizar 1
  17.  
  18. forward ReturnWeather ( playerid, returning, data [ ] ) ;
  19. forward SetPWeather ( playerid, Str [ ] ) ;
  20. forward ReturnWeather ( ) ;
  21. forward PickupAllWeather ( ) ;
  22.  
  23. public OnFilterScriptInit ()
  24. {
  25.     printf ( "  Tempo real da cidade de '%s' carregado com sucesso!",  cidade ) ;
  26.     SetTimer ( "PickupAllWeather", h_atualizar * 3600000, true ) ;
  27.     return 1 ;
  28. }
  29.  
  30. public OnPlayerConnect ( playerid )
  31. {
  32.     PickupPTime ( playerid ) ;
  33.     return 1 ;
  34. }
  35.  
  36. public ReturnWeather ( playerid, returning, data [ ] )
  37. {
  38.     if ( returning == 200 )
  39.     {
  40.         new
  41.             Str [ 128 ] ;
  42.  
  43.         data [ strfind ( data, "<!-- Hosting24 Analytics Code -->" ) ] = 0 ;
  44.         format ( Str, 128, "%s", data ) ;
  45.         SetPWeather ( playerid, Str ) ;
  46.     }
  47.     return 1 ;
  48. }
  49.  
  50. public SetPWeather ( playerid, Str [ ] )
  51. {
  52.     if ( strfind ( Str, "Céu limpo / Sol", true ) != -1 )
  53.         return SetPlayerWeather ( playerid, 1 ) ;
  54.  
  55.     if ( strfind ( Str, "Parcialmente nublado", true ) != -1 )
  56.         return SetPlayerWeather ( playerid, 20 ) ;
  57.  
  58.     if ( strfind ( Str, "Neblina", true ) != -1 || strfind ( Str, "Nevoeiro", true ) != -1 )
  59.         return SetPlayerWeather ( playerid, 32 ) ;
  60.  
  61.     if ( strfind ( Str, "Chuva forte", true) != -1 || strfind ( Str, "Chuva moderada ou forte", true ) != -1 )
  62.             return SetPlayerWeather ( playerid, 16 ) ;
  63.  
  64.     if ( strfind ( Str, "Chuva moderada", true) != -1 || strfind ( Str, "Chuva leve", true ) != -1 || strfind ( Str, "Chuva nas proximidades", true ) != -1 ||
  65.             strfind ( Str, "Garoa leve", true ) != -1 )
  66.                 return SetPlayerWeather ( playerid, 8 ) ;
  67.     return 1 ;
  68. }
  69.  
  70. public PickupAllWeather ( )
  71. {
  72.     new
  73.         Str [ 256 ] ;
  74.  
  75.     format ( Str, 256, "freegellsh.host22.com/weather.php?cidade=%s", cidade ) ;
  76.     for ( new i = 0 ; i < GetMaxPlayers ( ) ; i++ )
  77.     {
  78.         HTTP ( i, HTTP_GET, Str, "\0", "ReturnWeather" ) ;
  79.     }
  80.     return 1 ;
  81.  
  82. }
  83.  
  84. PickupPTime ( playerid )
  85. {
  86.     new
  87.         Str [ 256 ] ;
  88.  
  89.     format ( Str, 256, "freegellsh.host22.com/weather.php?cidade=%s", cidade ) ;
  90.     HTTP ( playerid, HTTP_GET, Str, "\0", "ReturnWeather" ) ;
  91.     return 1 ;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement