MySQL Offline Ban
#1

ISSUE: The command sends successfully, but the target in question does not get banned. How can I fix this, and why does this not work?

I am new to MySQL in sa-mp.

Код:
new query[65], tempip[16];

	mysql_format(gSQL, query, sizeof query, "SELECT * FROM `Users` WHERE `Name` = '%e'", target);
	if(mysql_tquery(gSQL, query, "OnAccountExist", "i", playerid))
	{
		cache_get_value_name(0, "LastIP", tempip, 16);
		new str[144], expiretime = (gettime() + (((time * 24) * 60) * 60));
		if(time > 0) format(str, sizeof str, "* %s %s has offline banned %s for \"%s\" till %s.", gStaff[pInfo[playerid][AdminLvl]], pName[playerid], target, reason, ReturnDate(expiretime));
		else format(str, sizeof str, "* %s %s has permanently offline banned %s for \"%s\".", gStaff[pInfo[playerid][AdminLvl]], pName[playerid], target, reason);
		SendClientMessageToAll(COLOR_PINK, str);
		mysql_format(gSQL, query, sizeof query, "INSERT INTO `Bans` (`ExpireDate`, `IP`, `Name`, `Reason`, `BanBy`) VALUES (%d, '%e', '%e', '%e', '%e')", expiretime, tempip, target, reason, pName[playerid]);
		mysql_tquery(gSQL, query);
	}
	else
	{
		SendClientMessage(playerid, COLOR_RED, "ERROR: "COL_GREY"That account doesn't exist.");	
	}
Reply
#2

Check your MySQL logs in your server files, show us the database table structure.
Reply
#3

No active cache. Execute the code inside OnAccountExist callback.
Reply
#4

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
No active cache. Execute the code inside OnAccountExist callback.
I'll try that.
Reply
#5

i think the SQL is %q not %e in your select statement
Reply
#6

Quote:
Originally Posted by silvan
Посмотреть сообщение
i think the SQL is %q not %e in your select statement
Thats for SQLite which is package inside sa-mp. He use MySQL plugin
Reply
#7

Dont ban people from Names. Ban them from DB ID. It makes it way easier. Try it and tell if it works.
Reply
#8

mysql_tquery returns 1 if the query was executed. That does not mean a row exists.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)