Search Accounts from IP
#1

Hey,

i have a command for searching accounts trough database when I enter the IP, but its always saying "no matches found" (german clientmessage).

For example my Ip is :

46.**.***.**

And then i type /searchdb 46 (only 46), i want all accounts which had the last ip with beginning "46".

Its not working actually, can somebody help :

Код:
ocmd:searchip(playerid, params[])
{
    if(!IsAdmin(playerid, 1))return noaccess
    if(sscanf(params,"s", iptofind))return SendClientMessage(playerid, WEIЯ, "Verwendung: /searchip (IP)");
	new iptofind[16];
	new query[256];
	format(query, sizeof(query), "SELECT last_ip, name FROM spieler WHERE(last_ip LIKE '%s')", iptofind);
	mysql_query(query);
	new rows = mysql_num_rows();
	new tmp[2][128], str[256];
	new count=0;
	for(new i=0; i<rows; i++)
	{
		mysql_retrieve_row();
		mysql_fetch_field_row(tmp[0], "last_ip");
		mysql_fetch_field_row(tmp[1], "name");
		format(str, sizeof(str),"[IP-SUCHE] Es wurde eine Ьbereinstimmung mit %s (%s) gefunden.", tmp[0],tmp[1]);
		SendClientMessage(playerid, ROT, str);
		count++;
	}
	mysql_free_result();
	if(count==0)
	{
		SendClientMessage(playerid, GRAU, "[IP-SUCHE] Es wurden keine Ьbereinstmmungen gefunden.");
	}
	return 1;
}
Reply
#2

You should define the IP variable before making the sscanf check with it, Also you have to enter the size in the sscanf check;

PHP код:
new iptofind[16];
if(
sscanf(params,"s[16]"iptofind)) return SendClientMessage(playeridWEIЯ"Verwendung: /searchip (IP)"); 
Reply
#3

Not working :/
Reply
#4

Try this;
Код:
format(query, sizeof(query), "SELECT last_ip, name FROM spieler WHERE last_ip LIKE %%s%, iptofind);
Reply
#5

IM getting these errors on line of format :

C:\Users\Safa B\Desktop\Server\gamemodes\gamemode.pwn(3372) : error 037: invalid string (possibly non-terminated string)
C:\Users\Safa B\Desktop\Server\gamemodes\gamemode.pwn(3372) : error 017: undefined symbol "SELECT"
C:\Users\Safa B\Desktop\Server\gamemodes\gamemode.pwn(3372) : error 017: undefined symbol "last_ip"
C:\Users\Safa B\Desktop\Server\gamemodes\gamemode.pwn(3372) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#6

Код:
format(query, sizeof(query), "SELECT last_ip, name FROM spieler WHERE last_ip LIKE %%s%", iptofind);
You should really check codes before putting them into your script.
Reply
#7

Still saying that no matches found,
Reply
#8

You'd also need to escape percent sign. Escape the strings as well.

For format function -> "... LIKE '%q%%'"
For mysql_format function -> "... 'LIKE %e%%'"

You don't use mysql_store_result() function which will results in errors/warnings in mysql logs.
Consider updating to latest versions of the mysql plugin (threaded queries) eventually.
Reply
#9

Damn, i dont understand this, can someone do it for me please, i would be very happy, because this is not my code , and somebody done it for me.
Reply
#10

Somebody? :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)