SA-MP Forums Archive
Users Get Kicked Whether Banned Or Not - 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: Users Get Kicked Whether Banned Or Not (/showthread.php?tid=415399)



Users Get Kicked Whether Banned Or Not - Camacorn - 13.02.2013

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.


Re: Users Get Kicked Whether Banned Or Not - FUNExtreme - 13.02.2013

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