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