Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <a_http>
- #define COLOR_GREEN 0x33AA33AA
- #define COLOR_BLUE 0x0000BBAA
- forward vicc(index, response_code, data[]);
- forward ViccTimer(playerid);
- public OnGameModeInit()
- {
- SetTimer("ViccTimer", 300000, true);
- return 1;
- }
- public ViccTimer(playerid)
- {
- HTTP(playerid, HTTP_GET, "www.faviccek.hu/randomjokes.php", "", "vicc");
- return 1;
- }
- public vicc(index, response_code, data[])
- {
- new buffer[ 128 ];
- new vonal[128];
- if(response_code == 200)
- {
- strdel(data, strlen(data)-3, strlen(data));
- strdel(data, 0, 95);
- new bool:found = true;
- while(found == true)
- {
- if(strfind(data, "<br />", true) != -1)
- {
- strdel(data,strfind(data, "<br ", true),strfind(data, "<br ", true)+3);
- for(new i=0; i<strlen(data); i++)
- {
- new offset = strfind(data, "/>", true);
- if(offset > -1)
- {
- data[offset] = ' ';
- data[offset+1] = ' ';
- break;
- }
- }
- }
- else
- {
- found = false;
- }
- }
- if(strlen(data) > 380) return HTTP(index, HTTP_GET, "www.faviccek.hu/randomjokes.php", "", "vicc");
- format(vonal, sizeof(vonal), "_________________________________________VICC_________________________________________");
- SendClientMessageToAll(COLOR_BLUE, vonal);
- format(buffer, sizeof(buffer), "%s", data[0]);
- SendClientMessageToAll(COLOR_GREEN, buffer);
- if(strlen(data) > 127)
- {
- format(buffer, sizeof(buffer), "%s", data[127]);
- SendClientMessageToAll(COLOR_GREEN, buffer);
- }
- if(strlen(data) > 254)
- {
- format(buffer, sizeof(buffer), "%s", data[254]);
- SendClientMessageToAll(COLOR_GREEN, buffer);
- }
- }
- else
- {
- format(buffer, sizeof(buffer), "Hiba történt lekérdezéskor! Hibakód:%d", response_code);
- SendClientMessageToAll(0xFFFFFFFF, buffer);
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment