Advertisement
ipsBruno

(Pawn) Anuncios via Facebook

Dec 3rd, 2012
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.33 KB | None | 0 0
  1. #include a_samp
  2.  
  3. // ===========================================================================
  4.  
  5. // Mude APENAS essas duas definições !!
  6. #define FACEBOOK    "" // Mude aqui para seu facebook. Caso não tiver usuário, pode colocar id!
  7. #define KEYACCESS   "" // Mude aqui para sua access_key
  8.  
  9.  
  10. // Como o host do Joao Paulo tinha algumas propagandas, usei esta defina
  11. // Caso ela estiver no código, ela retira a parte "Hosting24 Analytics Code"
  12.  
  13. #define PROPAGANDA
  14.  
  15.  
  16. // ===========================================================================
  17.  
  18.  
  19.  
  20. #if !defined HTTP_ERROR_BAD_HOST
  21.  
  22.         #include a_http
  23.  
  24. #endif
  25.  
  26. #define FacebookAnn:: FacebookAnn_
  27. #define FacebookAnn_function%0(%1) forward %0(%1); public %0(%1)
  28.  
  29.  
  30.  
  31. /* ---------------------------------------------------
  32.  
  33.     Ao iniciar filterscript, começar as requisições
  34.  
  35.  -----------------------------------------------------*/
  36.  
  37.  
  38. public OnFilterScriptInit() {
  39.  
  40.     printf("Sistema de Facebook Carregado");
  41.  
  42.     FacebookCheck();
  43.  
  44.     return true;
  45. }
  46.  
  47.  
  48.  
  49. /* ---------------------------------------------------
  50.  
  51.     Função responsável por fazer a requisição HTTP
  52.    Não mude a URL, ela foi configurada corretamente para isto
  53.  
  54.  -----------------------------------------------------*/
  55.  
  56. FacebookAnn::function FacebookCheck() {
  57.  
  58.     // AGRADEÇAM João Pedro por hospedar o código PHP responsável pelo processamento com Facebook!
  59.     HTTP(0, HTTP_GET, "joaopedroalves.tk/pawn/news-system/?user_name="FACEBOOK"&acess_token="KEYACCESS"", "\0", "FacebookResponse");
  60.  
  61.     return SetTimer("FacebookCheck", 13000, false );
  62. }
  63.  
  64.  
  65.  
  66.  
  67.  
  68. /* -------------------------------------------------------------
  69.  
  70.     Função responsável por fazer o processamento da requisicao
  71.       Nessa parte é processado o link que o meu site retornou
  72.         e também é enviado a mensagem aos jogadores!!
  73.  
  74.  -----------------------------------------------------*/
  75.  
  76. new lastpost[141];
  77.  
  78. FacebookAnn::function FacebookResponse(index, c, data[]) {
  79.  
  80.     if ( c ==  200  ) {
  81.  
  82.  
  83.         #if defined PROPAGANDA
  84.        
  85.         if((c=strfind(data, "<!-- Hosting24 Analytics Code -->")) != (-1)) {
  86.             data[c] = EOS;
  87.         }
  88.  
  89.         #endif
  90.        
  91.         if(strlen(lastpost) < 5 || strcmp(data, lastpost, true) == -1) {
  92.  
  93.             new string [167];
  94.             format(string, 167, data);
  95.  
  96.             html_entities(string, string);
  97.             format( string, 167, " Facebook: ("FACEBOOK"): %s", string);
  98.  
  99.  
  100.             // --- Enviar mensagem para todos jogadores
  101.             SendClientMessageToAll(-1, string);
  102.             print(string);
  103.  
  104.             format(lastpost, 141, data);
  105.         }
  106.     }
  107.  
  108.     return true;
  109.  
  110. }
  111.  
  112.  
  113.  
  114.  
  115. /* -------------------------------------------------------------
  116.  
  117.     Função "html_entities" usada para fazer entities de alguns acentos
  118.            Assim fixando o texto recebido via html !!
  119.  
  120.  -----------------------------------------------------*/
  121.  
  122.  
  123. html_entities(dest[], html[], len = sizeof html, destl = sizeof dest) {
  124.  
  125.     static entitie[4], i, c;
  126.    
  127.     for( i = 0 ; html[i+3] ; i++) {
  128.  
  129.         if( html[i] == '&' && html[i+1] == '#') {
  130.  
  131.             if(-1 != (c=strfind(html, ";", false, i + 2))) {
  132.                
  133.                 strmid(entitie, html, i+2, c);
  134.                
  135.                 strdel(html, i, c+1);
  136.                
  137.                 c = i;
  138.                 i += 3 + strlen(entitie);
  139.                
  140.                 format(entitie, 4, "%c", strval(entitie));
  141.                
  142.                 strins(html, entitie, c, len);
  143.             }
  144.         }
  145.     }
  146.  
  147.     return format(dest, destl, html);
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement