//the command
IRCCMD:checkip(botid, channel[], user[], host[], params[])
{
if(!IsEchoChannel(channel)) return iNotice( user, IRC_WRONG_CHANNEL);
new query[128],temp_ip[40];
if(sscanf(params, "s", temp_ip)) return iEchoUse("!checkip [ IP ADRESS ]");
format(query,sizeof(query),"SELECT * FROM user WHERE regip ='%s'",temp_ip);
mysql_function_query(dbhandle,query,true,"CheckIp","s",temp_ip);
return 1;
}
//the public
forward CheckIp(temp_ip[]);
public CheckIp(temp_ip[])
{
new num_rows,num_fields;
cache_get_data(num_rows,num_fields,dbhandle);
if(num_rows==0)
{
return iEchoUse("That ip adress isn't found in our database!");
}
else
{
new string[128],temp_username[35];
cache_get_field_content(0, "username", temp_username);
format(string,sizeof(string),"%s",temp_username);
iEcho(string);
return true;
}
}
for (new i; i != num_rows; i++)
{
cache_get_row(i, 0, temp_username); // only 1 field so no need to let it search for the fieldid
iEcho(temp_username);
}
mysql_format(dbhandle,query,sizeof(query),"SELECT username FROM user WHERE regip ='%e'",temp_ip);
That's because you get the data from the row 0 only. You should use a loop for that:
pawn Код:
|