Getting a Players IP?
#1

I made a code that only returns the players IP who typed the Command in, But I need it to return all of the players on the Server's IP's

Here is the code
pawn Код:
if (strcmp("/getip", cmdtext, true, 10) == 0)
    {
        new str[128], name[MAX_PLAYER_NAME], IP[16];
        GetPlayerName(playerid, name, sizeof(name));
        GetPlayerIp(playerid, IP, sizeof(IP));
        format(str, sizeof(str), "Name: %s  IP: %s.%s.%s.%s", name, IP);
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Player's IP", str, "Exit", "");
        return 1;
    }
Reply
#2

pawn Код:
if (strcmp("/getip", cmdtext, true, 10) == 0)
    {
        new str[128], name[MAX_PLAYER_NAME], IP[16];
        GetPlayerName(playerid, name, sizeof(name));
        GetPlayerIp(playerid, IP, sizeof(IP));
        format(str, sizeof(str), "Name: %s  IP: %s", name, IP);
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Player's IP", str, "Exit", "");
        return 1;
    }
EDIT: It shows your IP, not some other guy. And it's better to use Zcmd.
Reply
#3

You did not read it correct.., I need it to return all of the players in the server's IP's..
Reply
#4

Luis no offense you can't explain for shit. What you meant is to ENTER in a IP and return all of the playerids that are with those IP.

Example : /ip 127.0.0.1 { It will return people in the server who has 127.0.0.1 }
Reply
#5

Quote:
Originally Posted by Retardedwolf
Посмотреть сообщение
Luis no offense you can't explain for shit. What you meant is to ENTER in a IP and return all of the playerids that are with those IP.

Example : /ip 127.0.0.1 { It will return people in the server who has 127.0.0.1 }
I actually explained it correct.
Reply
#6

pawn Код:
new
        Array[512],
        PIP[17];
    format(Array, sizeof(Array), "Player:\t\tIP:\n");
    foreach(Player, i)
    {
        new
            IP = GetPlayerIp(i, PIP, sizeof(PIP));
        format(Array, sizeof(Array), "%s\n%s(%d)\t\t%s\n", Array, pName(i), i, IP);
    }
    ShowPlayerDialog(playerid, DIALOGID, DIALOG_STYLE_MSGBOX, "IPs", Array, "Ok", "Close");
Might also need this:
pawn Код:
stock pName(playerid)
{
    new
        Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    return Name;
}
Reply
#7

Well, I just fixed your current code. %s.%s.%s.%s and only one PIP isn't correct.
And L3th4l has correct code
Reply
#8

Lethal for some reason it does not show any IP's.. Or do I need to add that myself?
Reply
#9

Works for me. Same code.
Reply
#10

Hmm, Weird, I'll test it again.

EDIT: Was I meant to add this code under OnPlayerCommandText or OnDialogResponse?

pawn Код:
new
        Array[512],
        PIP[17];
    format(Array, sizeof(Array), "Player:\t\tIP:\n");
    foreach(Player, i)
    {
        new
            IP = GetPlayerIp(i, PIP, sizeof(PIP));
        format(Array, sizeof(Array), "%s\n%s(%d)\t\t%s\n", Array, pName(i), i, IP);
    }
    ShowPlayerDialog(playerid, DIALOGID, DIALOG_STYLE_MSGBOX, "IPs", Array, "Ok", "Close");
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)