Pedrosa52

[FS]Vicc

Aug 12th, 2011
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <a_samp>
  2. #include <a_http>
  3.  
  4. #define COLOR_GREEN 0x33AA33AA
  5. #define COLOR_BLUE 0x0000BBAA
  6.  
  7. forward vicc(index, response_code, data[]);
  8. forward ViccTimer(playerid);
  9.  
  10. public OnGameModeInit()
  11. {
  12.     SetTimer("ViccTimer", 300000, true);
  13.     return 1;
  14. }
  15.  
  16. public ViccTimer(playerid)
  17. {
  18.     HTTP(playerid, HTTP_GET, "www.faviccek.hu/randomjokes.php", "", "vicc");
  19.     return 1;
  20. }
  21.  
  22. public vicc(index, response_code, data[])
  23. {
  24.     new buffer[ 128 ];
  25.     new vonal[128];
  26.     if(response_code == 200)
  27.     {
  28.         strdel(data, strlen(data)-3, strlen(data));
  29.  
  30.         strdel(data, 0, 95);
  31.  
  32.         new bool:found = true;
  33.         while(found == true)
  34.         {
  35.             if(strfind(data, "<br />", true) != -1)
  36.             {
  37.                     strdel(data,strfind(data, "<br ", true),strfind(data, "<br ", true)+3);
  38.                     for(new i=0; i<strlen(data); i++)
  39.                     {
  40.                             new offset = strfind(data, "/>", true);
  41.                             if(offset > -1)
  42.                             {
  43.                                             data[offset] = ' ';
  44.                                             data[offset+1] = ' ';
  45.                                             break;
  46.                             }
  47.                     }
  48.  
  49.             }
  50.             else
  51.             {
  52.                     found = false;
  53.             }
  54.         }
  55.         if(strlen(data) > 380) return HTTP(index, HTTP_GET, "www.faviccek.hu/randomjokes.php", "", "vicc");
  56.         format(vonal, sizeof(vonal), "_________________________________________VICC_________________________________________");
  57.         SendClientMessageToAll(COLOR_BLUE, vonal);
  58.         format(buffer, sizeof(buffer), "%s", data[0]);
  59.         SendClientMessageToAll(COLOR_GREEN, buffer);
  60.         if(strlen(data) > 127)
  61.         {
  62.             format(buffer, sizeof(buffer), "%s", data[127]);
  63.             SendClientMessageToAll(COLOR_GREEN, buffer);
  64.  
  65.         }
  66.         if(strlen(data) > 254)
  67.         {
  68.             format(buffer, sizeof(buffer), "%s", data[254]);
  69.             SendClientMessageToAll(COLOR_GREEN, buffer);
  70.         }
  71.     }
  72.     else
  73.     {
  74.         format(buffer, sizeof(buffer), "Hiba történt lekérdezéskor! Hibakód:%d", response_code);
  75.         SendClientMessageToAll(0xFFFFFFFF, buffer);
  76.     }
  77.     return 1;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment