13.01.2015, 03:40
How can I make an /id command which says the player's PING? like...
/id Bobby
Bobby Fiddlebob (ID:1) - Ping: 51
/id Bobby
Bobby Fiddlebob (ID:1) - Ping: 51
CMD:id(playerid,params[])
{
new TargetID,str1[45],pname[MAX_PLAYER_NAME];
if(sscanf(params,"u",TargetID)) return SendClientMessage(playerid,0xFF0000FF,"USAGE: /id (Nick / ID)");
if(TargetID == INVALID_PLAYER_ID || !IsPlayerConnected(TargetID)) return SendClientMessage(playerid, 0xFF0000FF, "Player Is Not Connected.");
else
{
GetPlayerName(TargetID,pname,sizeof(pname));
format(str1,sizeof(str1),"%s (%d)'s Ping: %d",pname,TargetID,GetPlayerPing(TargetID));
SendClientMessage(playerid,-1,str1);
}
return 1;
}
command(id, playerid, params[])
{
if(sscanf(params, "u", params[0])) return SendClientMessage(playerid, -1, "usage: /id [playerid/name].");
if(IsPlayerConnected(params[0]) && params[0] != INVALID_PLAYER_ID)
{
new string[48], name[24];
GetPlayerName(params[0], name, 24);
format(string, sizeof(string), "%s(%d) ping: %d.", name, params[0], GetPlayerPing(params[0]));
SendClientMessage(playerid, -1, string);
}
else
{
SendClientMessage(playerid, -1, "Player not conected.");
}
return true;
}