How to kick all players with the same IP after banning someone?
#1

So I have /ban, /sban, /oban and /banip. All of these work perfectly except for the fact that they don't kick players currently online with the same IP.

How do I do that? I tried to do so but I couldn't manage and I didn't manage to find any topics on this either.
Reply
#2

You could get the IP of the person you've just banned, run a foreach loop through all the players, compare if they have the same IP of the person you've just banned and if so kick them/ban them do whatever.
Reply
#3

Quote:
Originally Posted by Chyakka
Посмотреть сообщение
You could get the IP of the person you've just banned, run a foreach loop through all the players, compare if they have the same IP of the person you've just banned and if so kick them/ban them do whatever.
Better idea same concept.

Код:
// Get InterIP - Slice
stock GetIntegerIP(const input[])
{
    new ip = 0, pos = -1;

    for (new i = 24; i >= 0; i -= 8) {
        ip |= strval(input[++pos]) << i;

        if (i) {
            pos = strfind(input, ".", _, pos);
        }
    }
    return ip;
}
Then just get a players ip when they connect set to 0 when disconnected and store it to an array.

Код:
new LongIP[MAX_PLAYERS];

OnPlayerConnect(playerid)
{
    new plrIP[16];
    GetPlayerIp(playerid, plrIP, sizeof(plrIP));
    LongIP[playerid] = GetIntegerIP(plrIP);
    ...

OnPlayerDisconnect(playerid)
{
     LongIP[playerid] = 0;
...
Now all the dirty work is done instead of using strcmp to check for IP's it is an integer comparison.
Reply
#4

An alternative method is BlockIpAddress function with interval of a few seconds which will timeout those players.
Reply
#5

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
An alternative method is BlockIpAddress function with interval of a few seconds which will timeout those players.
He might want to ban the accounts though.
Reply
#6

Thanks a lot Pottus! And Calisthenics as well. I will use the BlockIpAddress since it's simple, but maybe in the future I will find the other one more necessary/useful.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)