Basing a boolean function on MySQL data
#1

Hello! A few days ago I've decided to start off my own project of creating a gamemode.

I managed to create a login and register system with MySQL and I also wrote a database for the players.

Currently, I'm working on bans and I made a function that checks an IP and returns if the IP is banned or not

So my IP table contains only 'IP' data and inside it there's an IP address.

My problem is that I couldn't figure out how to return 1 or 0 with MySQL.

Refer to this code:

pawn Код:
stock CheckBan(ip[]) // TO DO: SOLVE THIS
{
    new
            szIp2[MAX_PLAYER_NAME],
            szQuery[128];

    mysql_real_escape_string(ip, szIp2, gMySQLConnection);
   
    format(szQuery, sizeof(szQuery), "SELECT COUNT(*) FROM bans WHERE IP = '%s'", ip);
    mysql_query(szQuery, THREAD_BAN_CHECK, -1, gMySQLConnection);
    return ???;
}
How do I check if the IP is banned and return 1 or 0 at the end.

It doesn't help if I check it through the resultid since evetually the function itself needs to return a value.

Anyone got any idea?
Reply


Messages In This Thread
Basing a boolean function on MySQL data - by Partner - 30.10.2014, 22:07
Re: Basing a boolean function on MySQL data - by Djole1337 - 30.10.2014, 22:13
Re: Basing a boolean function on MySQL data - by GWMPT - 30.10.2014, 22:21
Re: Basing a boolean function on MySQL data - by Partner - 31.10.2014, 08:02
Re: Basing a boolean function on MySQL data - by Partner - 31.10.2014, 09:09
Re: Basing a boolean function on MySQL data - by GWMPT - 31.10.2014, 11:02
Re: Basing a boolean function on MySQL data - by Vince - 31.10.2014, 11:10
Re: Basing a boolean function on MySQL data - by Partner - 31.10.2014, 11:17
Re: Basing a boolean function on MySQL data - by GWMPT - 31.10.2014, 11:19

Forum Jump:


Users browsing this thread: 5 Guest(s)