SA-MP Forums Archive
MySQL Offline Ban - 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: MySQL Offline Ban (/showthread.php?tid=657244)



MySQL Offline Ban - Aerotactics - 03.08.2018

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.");	
	}



Re: MySQL Offline Ban - DBZdabIt3Bro7 - 03.08.2018

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


Re: MySQL Offline Ban - Calisthenics - 03.08.2018

No active cache. Execute the code inside OnAccountExist callback.


Re: MySQL Offline Ban - Aerotactics - 04.08.2018

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


Re: MySQL Offline Ban - silvan - 04.08.2018

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


Re: MySQL Offline Ban - Banditul18 - 04.08.2018

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


Re: MySQL Offline Ban - GTLS - 05.08.2018

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


Re: MySQL Offline Ban - Kane - 05.08.2018

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