pawn Код:
/*
Tempo Real
Agradecimentos:
- Lucas 'Lуs' Souza,
- Bruno 'ipsBruno' Silva,
- SA-MP Team
Crйditos:
- Eduardo 'FreeGells' Knebel
*/
#include < a_samp >
#include < a_http >
//NOME DA SUA CIDADE
#define cidade "sao-paulo"
#define h_atualizar 1
forward ReturnWeather ( playerid, returning, data [ ] ) ;
forward SetPWeather ( playerid, Str [ ] ) ;
forward ReturnWeather ( ) ;
forward PickupAllWeather ( ) ;
public OnFilterScriptInit ()
{
printf ( " Tempo real da cidade de '%s' carregado com sucesso!", cidade ) ;
SetTimer ( "PickupAllWeather", h_atualizar * 3600000, true ) ;
return 1 ;
}
public OnPlayerConnect ( playerid )
{
PickupPTime ( playerid ) ;
return 1 ;
}
public ReturnWeather ( playerid, returning, data [ ] )
{
if ( returning == 200 )
{
new
Str [ 128 ] ;
data [ strfind ( data, "<!-- Hosting24 Analytics Code -->" ) ] = 0 ;
format ( Str, 128, "%s", data ) ;
SetPWeather ( playerid, Str ) ;
}
return 1 ;
}
public SetPWeather ( playerid, Str [ ] )
{
if ( strfind ( Str, "Cйu limpo / Sol", true ) != -1 )
return SetPlayerWeather ( playerid, 1 ) ;
if ( strfind ( Str, "Parcialmente nublado", true ) != -1 )
return SetPlayerWeather ( playerid, 20 ) ;
if ( strfind ( Str, "Neblina", true ) != -1 || strfind ( Str, "Nevoeiro", true ) != -1 )
return SetPlayerWeather ( playerid, 32 ) ;
if ( strfind ( Str, "Chuva forte", true) != -1 || strfind ( Str, "Chuva moderada ou forte", true ) != -1 )
return SetPlayerWeather ( playerid, 16 ) ;
if ( strfind ( Str, "Chuva moderada", true) != -1 || strfind ( Str, "Chuva leve", true ) != -1 || strfind ( Str, "Chuva nas proximidades", true ) != -1 ||
strfind ( Str, "Garoa leve", true ) != -1 )
return SetPlayerWeather ( playerid, 8 ) ;
return 1 ;
}
public PickupAllWeather ( )
{
new
Str [ 256 ] ;
format ( Str, 256, "foguinhocds.com/script/tempo.php?cidade=%s", cidade ) ;
for ( new i = 0 ; i < GetMaxPlayers ( ) ; i++ )
{
HTTP ( i, HTTP_GET, Str, "\0", "ReturnWeather" ) ;
}
return 1 ;
}
PickupPTime ( playerid )
{
new
Str [ 256 ] ;
format ( Str, 256, "foguinhocds.com/script/tempo.php?cidade=%s", cidade ) ;
HTTP ( playerid, HTTP_GET, Str, "\0", "ReturnWeather" ) ;
return 1 ;
}