#include <a_samp>
#include <a_mysql>
#include <a_http>
#include <sscanf2>
#include <zcmd>
#define GAMEMODE_TEST ""
#define MYSQL_HOST ""
#define MYSQL_USER ""
#define MYSQL_DATA ""
#define MYSQL_PASS ""
#define URL_CHECK_WALLET "localhost/http_walletcheck.php"
//***************************************************************************************************
forward HttpResponse_WalletCheck(index, response_code, data[]);
//***************************************************************************************************
main()
{
}
public OnGameModeInit()
{
print("test");
}
public HttpResponse_WalletCheck(index, response_code, data[])
{
new playerid = index;
if(response_code == 200)
{
if(strcmp(data,"true",true) == 0)
{
SendClientMessage(playerid, -1, "we completed your transaction...");
} else {
SendClientMessage(playerid, -1, "we could not complete your transaction, please try again.");
}
} else {
new str[1048];
format(str,sizeof(str), "An error occured when processing your transaction. (RESPONSE: %d)", response_code);
SendClientMessage(playerid, -1, str);
}
}
COMMAND:checkwallet(playerid, params[])
{
new str[500];
format(str,sizeof(str),"userid=%dwalletbalance=%d",1,1);
HTTP(playerid, HTTP_POST, URL_CHECK_WALLET, str, "HttpResponse_WalletCheck");
return 1;
}
it keeps returning an error code (6) wich doesn't exist as far as i know.
|
subdomain.example.domain/example_folder/example_file.php?variable1=string1&variable2=string2
#include <a_samp>
#include <a_mysql>
#include <a_http>
#include <sscanf2>
#include <zcmd>
#define GAMEMODE_TEST ""
#define MYSQL_HOST ""
#define MYSQL_USER ""
#define MYSQL_DATA ""
#define MYSQL_PASS ""
//***************************************************************************************************
forward HttpResponse_WalletCheck(index, response_code, data[]);
//***************************************************************************************************
main()
{
}
public OnGameModeInit()
{
print("test");
}
public HttpResponse_WalletCheck(index, response_code, data[])
{
new playerid = index;
if(response_code == 200)
{
if(strcmp(data,"true",true) == 0)
{
SendClientMessage(playerid, -1, "we completed your transaction...");
} else {
SendClientMessage(playerid, -1, "we could not complete your transaction, please try again.");
}
} else {
new str[1048];
format(str,sizeof(str), "An error occured when processing your transaction. (RESPONSE: %s)", ResponseCodeString(response_code));
SendClientMessage(playerid, -1, str);
}
}
COMMAND:checkwallet(playerid, params[])
{
new str[500];
format(str,sizeof(str),"ID=%i&Wallet=%i",1,1);
HTTP(playerid, HTTP_POST, "127.0.0.1/http/http_walletcheck.php", str, "HttpResponse_WalletCheck");
return 1;
}
stock strreplace(string[], find, replace)
{
for(new i=0; string[i]; i++)
{
if(string[i] == find)
{
string[i] = replace;
}
}
return true;
}
stock ResponseCodeString(code)
{
new rtstring[175];
switch(code)
{
case 100: { rtstring = "Continue"; }
case 101: { rtstring = "Switching Protocols"; }
case 102: { rtstring = "Processing"; }
case 200: { rtstring = "Successful"; }
case 201: { rtstring = "Created"; }
case 202: { rtstring = "Accepted"; }
case 203: { rtstring = "Non-Authoritative Information"; }
case 204: { rtstring = "No Conten"; }
case 205: { rtstring = "Reset Content"; }
case 206: { rtstring = "Partial Content"; }
case 207: { rtstring = "Multi-Status"; }
case 208: { rtstring = "Already Reported"; }
case 226: { rtstring = "IM Used"; }
case 300: { rtstring = "Multiple Choices"; }
case 301: { rtstring = "Moved Permanently"; }
case 302: { rtstring = "Found"; }
case 303: { rtstring = "See Other"; }
case 304: { rtstring = "Not Modified"; }
case 305: { rtstring = "Use Proxy"; }
case 306: { rtstring = "Switch Proxy"; }
case 307: { rtstring = "Temporary Redirect"; }
case 308: { rtstring = "Permanent Redirect"; }
case 400: { rtstring = "Bad Request"; }
case 401: { rtstring = "Unauthorized"; }
case 402: { rtstring = "Payment Required"; }
case 403: { rtstring = "Forbidden"; }
case 404: { rtstring = "Not Found"; }
case 405: { rtstring = "Method Not Allowed"; }
case 406: { rtstring = "Not Acceptable"; }
case 407: { rtstring = "Proxy Authentication Required"; }
default: { rtstring = "Unkown Code Response"; }
}
return rtstring;
}