SA-MP Forums Archive
Getting a Players IP? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Getting a Players IP? (/showthread.php?tid=205252)



Getting a Players IP? - Luis- - 31.12.2010

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



Re: Getting a Players IP? - FreshDoubleX - 31.12.2010

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.


Re: Getting a Players IP? - Luis- - 31.12.2010

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


Re: Getting a Players IP? - Retardedwolf - 31.12.2010

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 }


Re: Getting a Players IP? - Luis- - 31.12.2010

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.


Re: Getting a Players IP? - [L3th4l] - 31.12.2010

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



Re: Getting a Players IP? - FreshDoubleX - 31.12.2010

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


Re: Getting a Players IP? - Luis- - 31.12.2010

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


Re: Getting a Players IP? - [L3th4l] - 31.12.2010

Works for me. Same code.


Re: Getting a Players IP? - Luis- - 31.12.2010

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");