OBan Aint WOrking [SQL]
#1

FIxed..
Reply
#2

pawn Код:
mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `Banned`='1', `Reason`='%s', `BannedBy`='%s' WHERE `Username` = '%e'", reason, PlayerName(playerid), name);
Reply
#3

Quote:
Originally Posted by BlackBomb
Посмотреть сообщение
pawn Код:
CMD:oban(playerid, params[])
{
    new name[25], reason[50];
    if(!Logged[playerid]) return SendClientMessage(playerid, COLOR_RED, "You need to be logged in, to use this command");
    if(IsSpawn[playerid] == 0) return SendClientMessage(playerid, COLOR_RED, "You need to be spawned, to use this command");
    if(sscanf(params, "s[25]s[50]", name, reason)) return SendClientMessage(playerid, COLOR_GREY, "Syntax: /oban [Name] [Reason]");
    if(PlayerInfo[playerid][pAdminLevel] >= 5)
    {
       new query[128], string[128], time[10], date[10], h, m, s, y, mon, day;
       mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET Banned='1', Reason='%s', BannedBy='%s', WHERE Username = '%e'", reason, PlayerName(playerid), name);
       mysql_tquery(mysql, query, "", "");
       gettime(h, m, s);
       getdate(y, mon, day);
       format(time, sizeof(time), "%d:%d:%d", h, m, s);
       format(date, sizeof(date), "%d/%d/%d", day, mon, y);
       mysql_format(mysql, query, sizeof(query), "INSERT INTO `baninfo` (user_banned, user_banner, reason, ban_date, ban_time) VALUES ('%e', '%e', '%e', '%s', '%s')", name, PlayerName(playerid), reason, date, time);
       mysql_tquery(mysql, query, "", "");
       format(string, sizeof(string), "%s %s has offline banned %s [Reason: %s]",AdminLevelName(playerid),PlayerName(playerid),name,reason);
       SendClientMessageToAll(COLOR_BLUE,string);
    }
    else SendClientMessage(playerid, COLOR_RED, "You are not authorized to use that command!");
    return 1;
}
You didn't explain the problem, this code seems to work.
Does it ban, doesn't ban at all, or the player can get in after being banned, also show to part where it bans the player if he tried to join.

Also try to take a look at mysql_log at the server folder for any errors.
Reply
#4

FIxed..
Reply
#5

Quote:
Originally Posted by xVIP3Rx
Посмотреть сообщение
You didn't explain the problem, this code seems to work.
Does it ban, doesn't ban at all, or the player can get in after being banned, also show to part where it bans the player if he tried to join.

Also try to take a look at mysql_log at the server folder for any errors.
He put a coma ( , ) after BannedBy='%s' which will cause " error #1064: You have an error in your SQL syntax; "

OFFT: I'm not the person you're think, sorry.
Reply
#6

This isn't the actual problem, but nevertheless - you're escaping the player names which are already escaped by SA-MP, but not the ban reason.
Reply
#7

FIxed..
Reply
#8

Quote:
Originally Posted by BlackBomb
Посмотреть сообщение
Код:
[12:46:51] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[12:47:32] [DEBUG] mysql_format - connection: 1, len: 128, format: "UPDATE `players` SET Banned='1', Reason='%s', BannedBy='%s', WHERE `Username` = '%e'"
[12:47:32] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `players` SET Banned='1', Reason='', BannedBy='AYUB_KHAN'", callback: "(null)", format: "(null)"
[12:47:32] [DEBUG] mysql_format - connection: 1, len: 128, format: "INSERT INTO `baninfo` (user_banned, user_banner, reason, ban_date) VALUES ('%e', '%e', '%e', '%e')"
[12:47:32] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO `baninfo` (user_banned, user_banner, reason, ban_dat", callback: "(null)", format: "(null)"
[12:47:32] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[12:47:32] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `Username` = '[CVT]ReD_HunTeR'' at line 1
[12:47:32] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError
[12:47:32] [DEBUG] CMySQLQuery::Execute[] - starting query execution
Why are you giving a coma after BannedBy? as i said above it is considered as an error.
Reply
#9

Check out IronBoy's reply, it has fixed your code.
Reply
#10

k thanx.. ill test it in 10 mins
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)