23.08.2010, 13:07
Hi i am editing a script called iTranslate and i am trying to get it to work with the inbuilt HTTP system rather that pwncurl, but i cant seem to get it to work :S
I feel there isnt enough information about the new HTTP system available.
I feel there isnt enough information about the new HTTP system available.
pawn Код:
forward Inter_SendClientMessage(playerid,color,msg[]);
forward translate(playerid,string[],fromplayer);
forward iTranslate_OnPlayerConnect(playerid);
new ppl_ip[MAX_PLAYERS][32],cntryname[MAX_PLAYERS][128],preppp,preppp2,url[255];
new gettranslation[2048];
new sendtranslation[2048];
new rawdata[120000];
public iTranslate_OnPlayerConnect(playerid)
{
GetPlayerIp(playerid,ppl_ip[playerid],32);
GetCountryCode(ppl_ip[playerid], cntryname[playerid], 128);
// printf("ID %d comes from %s",playerid,cntryname[playerid]);
return 1;
}
forward MyHttpResponse(index, response_code, data[]);
public MyHttpResponse(index, response_code, data[])
{
strmid(rawdata,data,0,120000,120000);
/* preppp = strfind(data,"this.style.backgroundColor");
if(preppp == -1)
{
print(" - iTranslate Functional Error1 - ");
fremove("src.txt");
new File:handd = fopen("src.txt");
fwrite(handd,data);
fclose(handd);
return 0;
}
strdel(data,0,preppp);
strdel(data,0,9+76);
preppp2 = strfind(data,"<");
if(preppp2 == -1)
{
print(" - iTranslate Functional Error2 - ");
return 0;
}
strdel(data,preppp2,strlen(data));
//strdel(data,strlen(data)-1,strlen(data));
strpack(gettranslation,data,strlen(data));
printf("%s to %s",sendtranslation,gettranslation);*/
SendClientMessage(index,COLOR_GREEN,data);
new File:handd = fopen("src.txt");
fwrite(handd,data);
fclose(handd);
return 1;
}
public Inter_SendClientMessage(playerid,color,msg[])
{
// if(translate(playerid,msg,-1)) SendClientMessage(playerid,color,gettranslation);
// translate(playerid,msg,-1);
if(strfind(msg," ") != -1)
{
for(new lp_form=0;lp_form<=strlen(msg);lp_form++)
{
preppp = strfind(msg," ");
if(preppp == -1) break;
strdel(msg,preppp,preppp+1);
strins(msg,"+",preppp,strlen(msg));
}
}
// if(IsPlayerConnected(playerid)) format(url, 255, "%s%s%s%s%s%s%s", "http://translate.******.com/translate_t?hl=&ie=UTF-8&text=",msg,"&sl=",cntryname[playerid],"&tl=",cntryname[playerid],"#");
format(url, 255, "%s%s%s%s%s%s%s", "http://translate.******.com/translate_t?hl=&ie=UTF-8&text=",msg,"&sl=","en","&tl=",cntryname[playerid],"#");
HTTP(playerid, HTTP_GET, url, "", "MyHttpResponse");
SendClientMessage(playerid,color,rawdata);
return 1;
}