Http function, posting data
#3

Why would you want to use HTTP interactions and not simply connect to the MySQL server? Though, you can if you absolutely need to use the HTTP(pretty easy to find) function.

e.g:
pawn Код:
#include <a_samp>
#include <a_http>
#include <zcmd>
#include <sscanf2>

CMD:searchbans(playerid, params[])
{
    new playerName[MAX_PLAYER_NAME];
    if(sscanf(params, "s[25]", playerName))
        return SendClientMessage(playerid, 0xFF08080FF, "USAGE: /searchbans [playerName]");

    new string[128];
    format(string, sizeof string, "http://yoursite.com/banlog.txt?name=%s", playerName);
    HTTP(playerid, HTTP_GET, string, "", "OnBanLogSearch");
    return 1;
}

forward OnBanLogSearch(index, response_code, data[]);
public OnBanLogSearch(index, response_code, data[])
{
    if(IsPlayerConnected(index))
    {
        if(response_code != 200)
            return SendClientMessage(index, 0xFF08080FF, "A HTTP error occured.");
           
        ShowPlayerDialog(index, 0, DIALOG_STYLE_MSGBOX, "Banlog - search", data, "Close", "");
    }
   
    return 1;
}
Reply


Messages In This Thread
Http function, posting data - by bigboy81 - 20.09.2015, 23:54
Re: Http function, posting data - by rinori - 21.09.2015, 00:35
Re: Http function, posting data - by Abagail - 21.09.2015, 01:34
Re: Http function, posting data - by bigboy81 - 21.09.2015, 02:01
Re: Http function, posting data - by Abagail - 21.09.2015, 02:19

Forum Jump:


Users browsing this thread: 2 Guest(s)