How to kick all players with the same IP after banning someone?
#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


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)