SA-MP Forums Archive
How to kick all players with the same IP after banning someone? - 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)
+--- Thread: How to kick all players with the same IP after banning someone? (/showthread.php?tid=662823)



How to kick all players with the same IP after banning someone? - Stefhan - 12.01.2019

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.


Re: How to kick all players with the same IP after banning someone? - Chyakka - 12.01.2019

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.


Re: How to kick all players with the same IP after banning someone? - Pottus - 12.01.2019

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.


Re: How to kick all players with the same IP after banning someone? - Calisthenics - 12.01.2019

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


Re: How to kick all players with the same IP after banning someone? - Pottus - 12.01.2019

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.


Re: How to kick all players with the same IP after banning someone? - Stefhan - 12.01.2019

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.