Checking if an IP exists in a table - 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: Checking if an IP exists in a table (
/showthread.php?tid=544528)
Checking if an IP exists in a table -
Partner - 02.11.2014
If coded this function:
pawn Код:
stock CheckBan(ip[])
{
new
szIp2[MAX_PLAYER_NAME],
szQuery[128];
mysql_real_escape_string(ip, szIp2, gMySQLConnection);
format(szQuery, sizeof(szQuery), "SELECT `IP` FROM `bans` WHERE `IP` = '%s'", ip);
mysql_query(gMySQLConnection, szQuery);
if(cache_get_row_count(gMySQLConnection) > 0) return 1;
return 0;
}
It returns 1, although 127.0.0.1 doesn't show up on the 'bans' table.
Here is the state of the 'bans' table:
Why would it return 1 and not 0?
Re: Checking if an IP exists in a table -
Partner - 02.11.2014
Nevermind, I've solved it.
I decided to let the script detect if the IP being checked exists in another method and it worked!