CMD ip!
#1

hello im trying to make a cmd for get the player ip but didnt work!

Код:
CMD:ip(playerid,params[])
{
  new targetid;
  if(sscanf(params,"u", targetid)) return SCM(playerid, RED, "Getting ip of a player:/ip <playerid>");
  if(!IsPlayerConnected(targetid)) return SCM(playerid, RED, "Player is not connected");
  if(!IsPlayerAdmin(playerid)) return SCM(playerid, RED, "UnKnown Command! Type /help");

  new ip[25], ip_msg[30];
  GetPlayerIp(playerid, ip,sizeof (ip));
  format(ip_msg,sizeof (ip_msg),"(%i)",ip);
  ShowPlayerDialog(playerid, DIALOG_MSG, DIALOG_STYLE_MSGBOX, "IP", ip_msg, "Close", "");
  return 1;
}
Reply
#2

GetPlayerIp(playerid, ip,sizeof (ip));
format(ip_msg,sizeof (ip_msg),"(%i)",ip);
to
GetPlayerIp(targetid, ip,sizeof (ip));
format(ip_msg,sizeof (ip_msg),"(%s)",ip);

GetPlayerIP returns a string, not an integer.
Reply
#3

You can improve it a bit by not using format for parenteses and removing one of the arrays.

pawn Код:
CMD:ip(playerid,params[])
{
    if(!IsPlayerAdmin(playerid)) return SCM(playerid, RED, "UnKnown Command! Type /help");
    new targetid;
    if(sscanf(params,"u", targetid)) return SCM(playerid, RED, "Getting ip of a player:/ip <playerid>");
    if(!IsPlayerConnected(targetid)) return SCM(playerid, RED, "Player is not connected");
    new ip[16];
    GetPlayerIp(playerid, ip,sizeof (ip));
    ShowPlayerDialog(playerid, DIALOG_MSG, DIALOG_STYLE_MSGBOX, "IP", ip, "Close", "");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)