[Help - MySQL] Offline Ban not working
#6

You have to enclose a string with single or double quote in sql query.
Код:
WHERE `Name` = '%e'
And also, you can just execute update query without need to check if player name is exists in database. You can use cache_affected_rows() in the "OffBan" callback to check if player is already banned or doesn't exists.
Here's an example:
Код:
// In your oban cmd
mysql_format(g_Sql, query, sizeof(query), "UPDATE `accounts` SET `isBanned` = 1 WHERE `Name` =  '%e'", PlayerName); 
mysql_tquery(g_Sql, query, "OffBan", "is", playerid, PlayerName); 

public OffBan(playerid, Banned[]) 
{ 
	if(cache_affected_rows()) // It returns total of affected rows
	{
		new fmt[128];
		format(fmt, 128, "[BS] {AFAFAF}You have offline banned %s", Banned);
		SendClientMessage(playerid, COLOR_DARKCORAL, "[BS] {AFAFAF}Offline ban executed!");
		return 1;
	} 
	else
	{ 
		SendClientMessage(playerid, COLOR_DARKCORAL, "[BS] {AFAFAF}That player doesn't exist or already banned!"); 
		return 1; 
	} 
	return 1; 
}
Reply


Messages In This Thread
[SOLVED by X337] Offline Ban not working - by Sibuscus - 21.03.2017, 18:26
Re: [Help - MySQL] Offline Ban not working - by verlaj - 21.03.2017, 18:50
Re: [Help - MySQL] Offline Ban not working - by AndySedeyn - 21.03.2017, 18:53
Re: [Help - MySQL] Offline Ban not working - by Vince - 21.03.2017, 19:15
Re: [Help - MySQL] Offline Ban not working - by Sibuscus - 22.03.2017, 12:46
Re: [Help - MySQL] Offline Ban not working - by X337 - 22.03.2017, 13:04
Re: [Help - MySQL] Offline Ban not working - by Sibuscus - 22.03.2017, 13:16
Re: [Help - MySQL] Offline Ban not working - by X337 - 22.03.2017, 13:23
Re: [Help - MySQL] Offline Ban not working - by Sibuscus - 22.03.2017, 18:35

Forum Jump:


Users browsing this thread: 1 Guest(s)