Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include a_samp
- // ===========================================================================
- #if !defined HTTP_ERROR_BAD_HOST
- #include a_http
- #endif
- #define function::%0(%1) forward %0(%1); public %0(%1)
- // ===========================================================================
- public OnFilterScriptInit() {
- printf("ED BOT em Pawn Carregado !!");
- return true;
- }
- public OnPlayerSpawn(playerid) {
- SendClientMessage(playerid, -1, "[Info] Para conversar com um robo use /bot [frase] ..");
- return true;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!strcmp(cmdtext, "/bot", true, 4))
- {
- if( !cmdtext[4] ) {
- return SendClientMessage(playerid, -1, "[Erro] Use corretamente: /bot [frase]");
- }
- RobotCheck(playerid, cmdtext[5]);
- return true;
- }
- return false;
- }
- // ===========================================================================
- function::RobotCheck(playerid, texto[]) {
- new link[1024];
- format(link, 1024, "www.inbot.com.br/cgi-bin/bot_gateway.cgi?server=bot.insite.com.br:8085&charset=text&pure=1&js=1&admi=&msg=%s", urlencode(texto));
- HTTP(playerid, HTTP_GET, link, "\0", "RobotResponse");
- return true;
- }
- function::RobotResponse(playerid, c, data[]) {
- if ( c == 200 ) {
- removeLine(data);
- new mensagem[256];
- format(mensagem, 256, "{FF0000}Robo:{FFFFFF} %s", data);
- SendClientMessage(playerid, -1, mensagem);
- print(data);
- }
- return true;
- }
- //
- // Url encodes a specific string
- // @param string string
- // @author DracoBlue
- //
- urlencode(string[]) {
- new ret[1024];
- ret[0] = 0;
- new i = 0;
- new p = 0;
- new s = 0;
- while (string[i] != 0) {
- if (
- (string[i] >= 'A' && string[i] <='Z')
- || (string[i] >= 'a' && string[i] <='z')
- || (string[i] >= '0' && string[i] <='9')
- || (string[i] == '-')
- || (string[i] == '_')
- || (string[i] == '.')
- ) {
- ret[p] = string[i];
- } else {
- //
- ret[p] = '%';
- p++;
- s = (string[i] % 16); //
- ret[p+1] = (s>9) ? (55+s) : (48+s); // 64 - 9 = 55
- s = floatround((string[i] - s)/16);
- ret[p] = (s>9) ? (55+s) : (48+s); // 64 - 9 = 55
- p++;
- }
- p++;
- i++;
- }
- return ret;
- }
- function::removeLine(texto[]) {
- for(new i, c; texto[i]; i++) {
- if(texto[i] == '\n') {
- texto[i] = ' ';
- }
- if(texto[i] == '<') {
- c = i;
- while(texto[++i]) {
- if(texto[i] == '>') {
- strdel(texto, c, i+1);
- break;
- }
- }
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement