HTTP() & ****** Translator
#10

I'm sorry for the late reply.
What jlalt said was very helpful.

This is only a testing code, so you'll have to change the HTTP index if you want multiple people to use this.

Also, the "langout=fr" at the end of the URL is the language the website will translate the string to.
I've only tried it with french, but I think it'll cause problems once it starts to show the none english characters. (For example й and shit like that)

Signs like # will fuck it up so I think you should limit the input text to A-Z only.
You can always find a fix for that, but I'm not that good with URLs, and I'm a bit lazy.
Код:
forward HTTP_TranslateResponse(index, response_code, data[])

public OnGameModeInit()
{
	new str[128];
	strcat(str, "Hello, my name is James. How are you?");
	for (new i; i < 82; i++)
	{
	    if (str[i] == ' ')
	    {
	        str[i] = '+';
	    }
	}
	format(str, sizeof (str), "udcs-tss.com/******/?msg=%s&langin=en&langout=fr", str);
	HTTP(0, HTTP_GET, str, "", "HTTP_TranslateResponse");
	return 1;
}

public HTTP_TranslateResponse(index, response_code, data[])
{
    if(response_code == 200)
    {
        if (strfind(data, "\n") != -1)
        {
            strdel(data, 0, strfind(data, "\n")+1);
            strdel(data, strlen(data)-6, strlen(data));
        }
        print(data);
    }
    else
    {
        printf("Error ID: %i", response_code);
    }
}
Reply


Messages In This Thread
HTTP() & ****** Translator - by Luis- - 17.04.2016, 16:19
Re: HTTP() & ****** Translator - by Crystallize - 17.04.2016, 16:24
Re: HTTP() & ****** Translator - by Luis- - 17.04.2016, 16:26
Re: HTTP() & ****** Translator - by jlalt - 17.04.2016, 16:49
Re: HTTP() & ****** Translator - by Stuntff - 17.04.2016, 17:22
Re: HTTP() & ****** Translator - by Crayder - 17.04.2016, 17:39
Re: HTTP() & ****** Translator - by J0sh... - 17.04.2016, 18:10
Re: HTTP() & ****** Translator - by Luis- - 18.04.2016, 16:07
Re: HTTP() & ****** Translator - by Karan007 - 18.04.2016, 16:19
Re: HTTP() & ****** Translator - by Stinged - 28.04.2016, 18:04

Forum Jump:


Users browsing this thread: 1 Guest(s)