19.03.2013, 14:42
I am trying to create function to send players translated messages. This is the code:
It works so: When the function is called, it sends an http request and gets the translation. For example, if I use:
it will form a link:
and send an HTTP request. The data must be:
So player must see it. But I get a response code 6, which means HTTP_ERROR_MALFORMED_RESPONSE. What's the problem?
pawn Код:
SendTranslatedMessage(playerid,message[])
{
new buf[1024];
format(buf,sizeof(buf),"translate.yandex.net/tr.json/translate?lang=en-ru&text=%s",message);
HTTP(playerid, HTTP_GET, buf, "", "MyHttpResponse");
}
forward MyHttpResponse(index, response_code, data[]);
public MyHttpResponse(index, response_code, data[])
{
if(response_code == 200) SendClientMessage(index,0xFFFFFFFF,data);
}
Код:
SendTranslatedMesage(playerid,"Hello, world!")
Код:
translate.yandex.net/tr.json/translate?lang=en-ru&text=Hello, World!
Код:
"Здравствуй, Мир!"