SA-MP Forums Archive
HTTP and localhost - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: HTTP and localhost (/showthread.php?tid=471181)



HTTP and localhost - ATomas - 21.10.2013

Hello,
I have a problem with http and localhost. I need to make it work on my localhost for testing.
I have this script, please advise me where create a file "test.txt" to be read.

Код:
#include <a_samp>
#include <a_http>

public OnPlayerCommandText(playerid,cmdtext[])
{
    if(strcmp("/http",cmdtext,true) == 0)
    {
        HTTP(playerid,HTTP_GET,"localhost/test.txt","","MyHttpResponse");
        return 1;
    }
	return 0;
}

forward MyHttpResponse(index,response_code,data[]);
public MyHttpResponse(index,response_code,data[])
{
	new s[128];
	format(s,128,"index = %d",index);
	SendClientMessageToAll(-1,s);
	format(s,128,"response_code = %d",response_code);
	SendClientMessageToAll(-1,s);
	format(s,128,"data = %s",data);
	SendClientMessageToAll(-1,s);
    return 1;
}
now response_code is 3