Ban check wont work -
Type-R - 28.08.2014
Hey guys well im updating my server to R39 MySQL, and ban check is refusing to work. I put myself into bans in MySQL database, and the mysql seems to find me in there, but nothing happens. Heres my script:
pawn Код:
stock CheckBans(playerid)
{
// Create variables
new
banned_pname[24],
MySQLQuery[255],
Year,
Month,
Day,
Hour,
Min,
Sec,
query[200];
new rows, fields;
getdate(Year, Month, Day);
gettime(Hour,Min,Sec);
GetPlayerName(playerid,banned_pname,sizeof(banned_pname));
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `banai` WHERE `Player` = '%s' OR `IP` = '%s'", banned_pname, IP[playerid]);
mysql_tquery(mysql, query);
cache_get_data(rows, fields, mysql);//let's get the rows and fields from the database.
if(rows)
{
format(TempStr, sizeof(TempStr), "{FF0000}» {CC6600}Jums yra {FF0000}draudziama {CC6600}zaisti siame serveryje!\n{FF0000}» {CC6600}Noredami vel zaisti musu serveryje, siuskite SMS zinute uz {FF0000}5 LT / 1.45 Ђ\n{FF0000}» {CC6600}Tekstas: {FF0000}unbanfz %s\n{FF0000}» {CC6600}Numeris: {FF0000}1398\n{FF0000}» {CC6600}Varda zaidime reikia nurodyti, su kuriuo buvote uzblokuotas.", banned_pname);
ShowPlayerDialog(playerid,678,DIALOG_STYLE_MSGBOX,"{FF0000}Jus esate uzblokuotas!",TempStr,"Iseiti","");
PlayerPlaySound(playerid, 1057,0.0,0.0,0.0);
// Send message to all players on server
format(TempStr, sizeof (TempStr), "[FunZoneLT]>> Zaidejas %s(%d) buvo automatiskai ismestas, kadangi jis yra uzblokuotas.", banned_pname, playerid);
SendClientMessageToAll(raudona, TempStr);
// Kick player
SetTimerEx("IsmestiZaideja",300,false,"d",playerid);
}
return 1;
}
this is the MySQL log:
Код:
[21:53:23] [DEBUG] cache_get_data - connection: 1
[21:53:23] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[21:53:40] [DEBUG] mysql_format - connection: 1, len: 200, format: "SELECT * FROM `banai` WHERE `Player` = '%s' OR `IP` = '%s'"
[21:53:40] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM `banai` WHERE `Player` = 'TypeR' OR `IP` = 'РH„Аь", callback: "(null)", format: "(null)"
[21:53:40] [DEBUG] cache_get_data - connection: 1
[21:53:40] [WARNING] cache_get_data - no active cache
I have no idea why the IP appears like that though. Cause i get it onplayerconnect, and save it into a string instantly that works all over the script. Anyone know why the script wouldnt get be as banned?
Re: Ban check wont work -
Dotayuri - 28.08.2014
You do need to use my sql_tquery();
Re: Ban check wont work -
Type-R - 28.08.2014
ok, it works now. My question is though why would tquery not work? And do i need to somehow now free the results? Thank you.
Re: Ban check wont work -
Type-R - 28.08.2014
I was looking up sql_tquery and i cannot seem to find it for SA-MP?
Re: Ban check wont work -
FUNExtreme - 28.08.2014
mysql_tquery doesn't work because tquery is threaded. The results of queries done by tquery and pquery are sent to a callback that you can specifiy.
The way you coded it is non-threaded, which will work with mysql_query
https://sampwiki.blast.hk/wiki/MySQL/R33
That's some newer documentation, read it.
Re: Ban check wont work -
Type-R - 28.08.2014
I just did says that: callback[] The query you want to process (optional).
format[] The format specifier string (optional).
{Float,_}:... Indefinite number of arguments (optional). In my uderstanding their optional??
Re: Ban check wont work -
FUNExtreme - 28.08.2014
They are optional because the results of queries like UPDATE and DELETE don't return any data that you need (in some cases you do, but only rarely). So you can just leave the callback and following parameters empty and it'll ignore the results. If this wasn't possible you'd have to make callbacks without any code in them, which is useless.
Re: Ban check wont work -
Tisot - 28.08.2014
i have the code but not mysqlR39
Re: Ban check wont work -
Type-R - 29.08.2014
ok, soa threaded would be more efficient, if i basically did a TQuery onplayerconnect, that linked to stock CheckBans(playerid)? And one more question. How do i free the results of the regular queries? Can someone just give me a small example? Thank you.
Re: Ban check wont work -
Type-R - 30.08.2014
Hey guys why is this happening when loading IP from databse?
pawn Код:
[21:53:40] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM `banai` WHERE `Player` = 'TypeR' OR `IP` = 'РH„Аь", callback: "(null)", format: "(null)"
I dont understand why it does this when it saves this before, i set it as a string.
Heres the lines that put the BAN on player:
pawn Код:
mysql_format(mysql, query, sizeof(query), "INSERT INTO `banai` ( `Admin`, `Player`, `Reason`, `IP`) VALUES ('%s', '%s', '%s', '%s')", Admin, banned_pname, Reason, IP);
mysql_tquery(mysql, query);
How i get the IP onplayerconnect:
pawn Код:
GetPlayerIp(playerid, IP[playerid], 16);
At the top of the script:
pawn Код:
static
mysql, //This variable will be used to manage our database
Name[MAX_PLAYERS][24], //We will use this variable to store player's name.
IP[MAX_PLAYERS][16] //We will use this variable to store player's ip.
;
What could be the issue?