MySQL problem
#1

Hey, So. I have a ban command which updates the database when it's called. I've set it so it checks if someone is banned before they can connect. This works if the player is banned, If you're not banned. It's doesn't actually do anything. It just does nothing.

pawn Код:
mysql_format(SQL, query, sizeof(query), "SELECT * FROM `players` WHERE `username` = '%e' LIMIT 1", Player[playerid][Name]);
    mysql_tquery(SQL, query, "OnBanCheck", "d", playerid);
I have that, which leads to this.

pawn Код:
forward OnBanCheck(playerid);
public OnBanCheck(playerid)
{
    new rows, fields;
    cache_get_data(rows, fields, SQL);
    if(rows)
    {
        cache_get_field_content(0, "bannedby", Player[playerid][BannedBy], SQL, 24);
        cache_get_field_content(0, "reason", Player[playerid][BanReason], SQL, 20);
        Player[playerid][Banned] = cache_get_field_content_int(0, "banned");
       
        CheckBans(playerid);
    }
    return 1;
}
Then to this,

pawn Код:
stock CheckBans(playerid)
{
    if(Player[playerid][Banned] == 1)
    {
        new msg[24];
        SendClientMessage(playerid, -1, "SERVER: You're still banned!");
        format(msg, 24, "| Ban Reason: %s | Banned By: %s |", Player[playerid][BanReason],Player[playerid][BannedBy]);
        SendClientMessage(playerid, -1, msg);
        DelayedKick(playerid);
    }
    else if(Player[playerid][Banned] == 0)
    {
        new query[200];
        mysql_format(SQL, query, sizeof(query), "SELECT * FROM `players` WHERE `username` = '%e' LIMIT 1", Player[playerid][Name]);
        mysql_tquery(SQL, query,"OnPlayerDataLoaded", "dd", playerid, MysqlRaceCheck[playerid]);
    }
    return 1;
}
I think it's the query in the last part of the CheckBans stock. Anyone know the issue? It's like it doesn't call the OnPlayerDataLoaded callback.
Reply
#2

What version of the plugin are you using? %e seems broken before R8 so try update or use %s
Reply
#3

I'm using R34. I've tried your '%s' instead of '%e' and it didn't work. Thanks for the input though.
Reply
#4

MySql Debug give out any error?
Reply
#5

You mean the MySQL log?

Reply
#6

Yeah, maybe im blind or didn't see what is the problem.. try to debug that in your console using a print just like that.. see if banned == 0 get called

pawn Код:
stock CheckBans(playerid)
{
    if(Player[playerid][Banned] == 1)
    {
        new msg[24];
        SendClientMessage(playerid, -1, "SERVER: You're still banned!");
        format(msg, 24, "| Ban Reason: %s | Banned By: %s |", Player[playerid][BanReason],Player[playerid][BannedBy]);
        SendClientMessage(playerid, -1, msg);
        DelayedKick(playerid);
    }
    else if(Player[playerid][Banned] == 0)
    {
        print("Debug: Passed");
        new query[200];
        mysql_format(SQL, query, sizeof(query), "SELECT * FROM `players` WHERE `username` = '%e' LIMIT 1", Player[playerid][Name]);
        mysql_tquery(SQL, query,"OnPlayerDataLoaded", "dd", playerid, MysqlRaceCheck[playerid]);
    }
    return 1;
}
Reply
#7

I tried adding the Print debugs and they do not show. So, I don't know the issue.
Reply
#8

try to not use the stock edit : i mean use the code in the stock in the function
Reply
#9

Fixed it, Thanks.
Reply
#10

that was the problem ?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)