SA-MP Forums Archive
getting a players IP. - 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: getting a players IP. (/showthread.php?tid=554736)



getting a players IP. - Th3UnKnOwN - 04.01.2015

Код:
CMD:getip(playerid, params[])
{
	new IP[50];
	new targetid;
	new string[200];
	new Name[MAX_PLAYER_NAME];
	if(sscanf(params, "ui", targetid)) return SendClientMessage(playerid, COLOR_RED, "Usage: /getip <id>");
	GetPlayerName(playerid, Name, sizeof(Name));
	GetPlayerIp(targetid, IP, sizeof(IP));
	format(string, sizeof(string), "%s(%i)'s IP is: %d", Name, targetid, IP);
	SendClientMessage(playerid, COLOR_LIME, string);
	return 1;
}
In samp-server.exe sscanf says:
sscanf warning: Format specifier does not match parameter count.

Picture of my issue:



AW: getting a players IP. - Sascha - 04.01.2015

either
pawn Код:
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_RED, "Usage: /getip <id>"
or
pawn Код:
if(sscanf(params, "i", targetid)) return SendClientMessage(playerid, COLOR_RED, "Usage: /getip <id>"
and
pawn Код:
format(string, sizeof(string), "%s(%i)'s IP is: %s", Name, targetid, IP);



Re: getting a players IP. - Schneider - 04.01.2015

That's not causing the problem, the problem is in the format you use the %d specifier (integer), but the IP is a string, so he should use %s

pawn Код:
format(string, sizeof(string), "%s(%i)'s IP is: %s", Name, targetid, IP);



Re: getting a players IP. - Th3UnKnOwN - 04.01.2015

Thank you.


Re: getting a players IP. - dominik523 - 04.01.2015

You don't need two specifiers in your sscanf. You need only one, player's ID.
Код:
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_RED, "Usage: /getip <id>");
EDIT: didn't see all those posts up there. This is full command I guess:
pawn Код:
CMD:getip(playerid, params[])
{
    new IP[16];
    new targetid;
    new string[200];
    new Name[MAX_PLAYER_NAME];
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_RED, "Usage: /getip <id>");
    GetPlayerName(playerid, Name, sizeof(Name));
    GetPlayerIp(targetid, IP, sizeof(IP));
    format(string, sizeof(string), "%s(%i)'s IP is: %s", Name, targetid, IP);
    SendClientMessage(playerid, COLOR_LIME, string);
    return 1;
}