IP & PING Retruns me same ping as player which executes the command -
MiGu3X - 29.03.2013
My codes
pawn Code:
CMD:ip(playerid, params[])
{
new target, tName[24], str[128];
new tIp = GetPlayerIp(target, str, sizeof(str));
if(PlayerInfo[playerid][pAdmin] >= 3)
{
if(sscanf(params, "u", target))
return SendClientMessage(playerid, DEEPPINK, "USAGE: /ip <id>");
if (target == INVALID_PLAYER_ID)
return SendClientMessage(playerid, DEEPPINK, "ERROR: Player is not connected.");
{
GetPlayerName(target, tName, sizeof(tName));
format(str, sizeof(str), "{FFFFFF}%s's {00FF66}IP {FFFFFF}is:{00FF66}%s", tName, tIp);
SendClientMessage(playerid, -1, str);
}
}
else return SendClientMessage(playerid, DEEPPINK, "ERROR: You must be level 3 to use that command!");
return 1;
}
pawn Code:
CMD:ping(playerid, params[])
{
new pName[MAX_PLAYER_NAME], id, str[128];
new tPing = GetPlayerPing(id);
if(sscanf(params, "u", id))
return SendClientMessage(playerid, DEEPPINK, "USAGE: /ping <id>");
if(!IsPlayerConnected(id))
return SendClientMessage(playerid, DEEPPINK, "ERROR: Player is not connected");
{
GetPlayerName(id, pName, sizeof (pName));
format(str, sizeof str, "Ping of %s (ID: %d): %i", pName, id, tPing);
SendClientMessage(playerid, BLUE, str);
}
return 1;
}
HELP PLEASE :/&
Re: IP & PING Retruns me same ping as player which executes the command -
MarkoN - 29.03.2013
Try like this
pawn Code:
CMD:ping(playerid, params[])
{
new pName[MAX_PLAYER_NAME], id, str[128];
if(sscanf(params, "u", id)) return SendClientMessage(playerid, DEEPPINK, "USAGE: /ping <id>");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, DEEPPINK, "ERROR: Player is not connected");
GetPlayerName(id, pName, sizeof (pName));
new tPing = GetPlayerPing(id);
format(str, sizeof str, "Ping of %s (ID: %d): %i", pName, id, tPing);
SendClientMessage(playerid, BLUE, str);
return 1;
}
and
pawn Code:
CMD:ip(playerid, params[])
{
new target, tName[24], str[128];
if(PlayerInfo[playerid][pAdmin] >= 3)
{
if(sscanf(params, "u", target)) return SendClientMessage(playerid, DEEPPINK, "USAGE: /ip <id>");
if (target == INVALID_PLAYER_ID) return SendClientMessage(playerid, DEEPPINK, "ERROR: Player is not connected.");
GetPlayerName(target, tName, sizeof(tName));
new tIp = GetPlayerIp(target, str, sizeof(str));
format(str, sizeof(str), "{FFFFFF}%s's {00FF66}IP {FFFFFF}is:{00FF66}%s", tName, tIp);
SendClientMessage(playerid, -1, str);
}
else return SendClientMessage(playerid, DEEPPINK, "ERROR: You must be level 3 to use that command!");
return 1;
}
Re: IP & PING Retruns me same ping as player which executes the command -
zxc1 - 29.03.2013
Shouldn't the GetPlayerIp/GetPlayerPing functions come after you input the player id?
Re: IP & PING Retruns me same ping as player which executes the command -
kamzaf - 30.03.2013
pawn Code:
CMD:ip(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 3)
{
new target;
if(sscanf(params, "u", target)) return SendClientMessage(playerid, COLOR_ORANGE, "[*] Usage: /ip [playerid/name]");
else if(target == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_ORANGE, "[*] Enter a valid player ID/name!");
new ip[16], name[MAX_PLAYER_NAME], string[100];
GetPlayerName(target, name, MAX_PLAYER_NAME);
GetPlayerIP(target, ip, sizeof(ip));
format(string, 100, "|- %s[%d]'s IP: %s -|", name, target, ip);
SendClientMessage(playerid, 0x33AA33AA, string);
}
else return SendClientMessage(playerid, 0xFF0000AA, "You cannot use this command!");
return 1;
}