Command that detects player's same IP?
#1

Hello. How to make a command that detects players who connect from same IP (tell the name of the accounts who connect from the same IP)?
Reply
#2

just put a for loop into onplayerconnect and check all players ips and compare them to the ones that just connected, i wont give u the code, you should try yourself, you could even ****** ^^
Reply
#3

If you mean a list of the players with the current IP address that are currently connected you can loop through players, compare their IP and handle it accordingly. If you mean account-wise, I'd recommend the usage of MySQL for your accounts so you can simply perform a query(considering you have an "IP" column storing the IP address of the account).

For the first:
pawn Код:
CMD:ip(playerid, params[])
{
    if(IsPlayerAdmin(playerid))
    {
        if(isnull(params))
            return SendClientMessage(playerid, -1, "USAGE: /ip [IP]");
           
        new pIP[32], playerIP[32], string[32];
        for(new i; i < MAX_PLAYERS; i++)
        {
            if(!IsPlayerConnected(i)) continue;
           
            GetPlayerIp(playerid, playerIP, sizeof playerIP);
            if(!strcmp(pIP, playerIP))
            {
                format(string, sizeof string, "%s, %d", string, playerid);
            }
        }
       
        SendClientMessage(playerid, -1, string);
    }

    return 1;
}
Reply
#4

create an enum with 2 variables, ip and players name.

When a player connects, get his/her ip address.

Now loop through the enum for that ip address, if it not found then loop through the enum for an empty slot, then set that empty slot with the players name and ip.

Simple and easy.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)