30.10.2014, 22:07
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:
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?
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 ???;
}
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?