Users Get Kicked Whether Banned Or Not
#1

Hello,

I am scripting a MySQL ban system for my server, and I am having an issue. It bans them properly, but upon logging in, it's supposed to check whether or not their name or IP is banned. If their ip or name is banned, they get kicked, if not, they are allowed to login.

My issue is that it is kicking players whether mysql_num_rows returns 0 or 1, so nobody is allowed to login.

pawn Код:
stock CheckIPBan(playerip[])
{
    new string[50];
    format(string,sizeof(string) ,"SELECT * FROM `Bans` WHERE `IP` = '%s'",playerip);
    mysql_function_query(MySQL, string, false, "SendQuery", "");
    if(mysql_num_rows ( ) != 0)
    {
        return 0;
    }
    else return 1;
}

stock CheckNameBan(playername[])
{
    new string[50], escape[MAX_PLAYER_NAME];
    mysql_real_escape_string(playername, escape);
    format(string, sizeof(string), "SELECT * FROM `Bans` WHERE `Username` = '%s'",escape);
    mysql_function_query(MySQL, string, false, "SendQuery", "");
    if(mysql_num_rows ( ) != 0)
    {
        return 0;
    }
    else return 1;
}

stock CheckBan(playerid)
{
    if(CheckNameBan(GetPName(playerid)) || CheckIPBan(PlayerIP[playerid]))
    {
        Kick(playerid);
    }
}
Thank you for having a look.
Reply
#2

Your query is threaded but your're not using them as such. I advise you to read AndreT his tutorial on caching, it shows how threading works in the examples. Sorry for such a short answer but I'm on the phone
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)