getting a players IP.
#1

Код:
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:
Reply
#2

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);
Reply
#3

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);
Reply
#4

Thank you.
Reply
#5

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)