Check field in MySQL
#2

I just made this:
pawn Код:
COMMAND:test(playerid, params[])
{
    new query[128], user, ip_s[16];
    if(sscanf(params,"d",user)) return 1;
    GetPlayerIp(user,ip_s,16);
    format(query, 128, "SELECT * FROM ips WHERE ip=INET_ATON('%s') LIMIT 1",ip_s);
    mysql_query(query), mysql_store_result();
    if(mysql_num_rows())
    {
        Ban(user);
    } else SendClientMessage(playerid,-1,"The IP of this player wasn't found in the database.");
    mysql_free_result();
    return 1;
}
It should be something as that, I think.

I used two IPs for testing, one of them was my IP. I inserted them in the DB with INET_ATON format. If you want to extract them you can use INET_NTOA to 'decrypt' them.
Reply


Messages In This Thread
Check field in MySQL - by DBan - 02.07.2012, 07:01
Respuesta: Check field in MySQL - by [DOG]irinel1996 - 02.07.2012, 09:54

Forum Jump:


Users browsing this thread: 1 Guest(s)