Advertisement
Papadopolis

Untitled

Jan 8th, 2014
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.26 KB | None | 0 0
  1. #include <a_samp>
  2. #include <a_http>
  3.  
  4. #define APP_ID "6635D742380CF583FEE16FF83E80BC8238F166E3"
  5.  
  6. forward traduzirTexto(de[], para[], texto[]);
  7. forward textoTraduzidoAction(index, response_code, data[]);
  8.  
  9. public traduzirTexto(de[], para[], texto[]) {
  10.     new url[128];
  11.    
  12.     format(url, sizeof(url), "api.microsofttranslator.com/V2/Ajax.svc/Translate?appId=%s&from=%s&to=%s&text=%s", APP_ID, de, para, texto);
  13.     HTTP(-1, HTTP_GET, url, "", "textoTraduzidoAction");
  14. }
  15.  
  16. public textoTraduzidoAction(index, response_code, data[])
  17. {
  18.     new formataSaida[4][1024];
  19.    
  20.     explode(formataSaida, data, "\""); // Retirar aspas
  21.  
  22.     SendClientMessageToAll(0xFF000000, formataSaida[1]);
  23. }
  24.  
  25. stock explode(aExplode[][], const sSource[], const sDelimiter[] = " ", iVertices = sizeof aExplode, iLength = sizeof aExplode[])
  26. {
  27.     new
  28.         iNode,
  29.         iPointer,
  30.         iPrevious = -1,
  31.         iDelimiter = strlen(sDelimiter);
  32.  
  33.     while(iNode < iVertices)
  34.     {
  35.         iPointer = strfind(sSource, sDelimiter, false, iPointer);
  36.  
  37.         if(iPointer == -1)
  38.         {
  39.             strmid(aExplode[iNode], sSource, iPrevious, strlen(sSource), iLength);
  40.             break;
  41.         }
  42.         else
  43.         {
  44.             strmid(aExplode[iNode], sSource, iPrevious, iPointer, iLength);
  45.         }
  46.  
  47.         iPrevious = (iPointer += iDelimiter);
  48.         ++iNode;
  49.     }
  50.  
  51.     return iPrevious;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement