SA-MP Forums Archive
MAX IPS. - 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: MAX IPS. (/showthread.php?tid=421858)



MAX IPS. - audriuxxx - 11.03.2013

Hi,

I use mysql. And i want to do, you can only have max 3 users on the same ip. How i can to do that?


Re: MAX IPS. - gabyk - 11.03.2013

pawn Код:
new ip [ 16 ];
GetPlayerIp ( playerid, ip, 16 );
for ( new i; i < MAX_PLAYERS; i++ )
{
    new max_ips;
    new i_ip [ 16 ];
    GetPlayerIp ( playerid, i_ip, 16 );
    if ( strcmp ( ip, i_ip, true ) == 0 )
    {
        max_ips++;
    }
    if ( max_ips >= 3 ) { Kick ( playerid ); }
}



Re: MAX IPS. - B-Matt - 11.03.2013

pawn Код:
#define MAX_IPS         3 //defining MAX_IPS for check is there 3 same IPs

public OnPlayerConnect(playerid)
{
    new pIP[16], oIP[16], //player IP and others IP
        max_ips;
    GetPlayerIp(playerid, pIP, sizeof(pIP)); //gets player IP
    foreach (new i : Player) // Faster loop then for loop (for players)
    {
        if(IsPlayerConnected(i)) //if player is connected continue
        {
            GetPlayerIp(i, oIP, sizeof(oIP)); //Gets IP from other player
            if(strcmp(pIP, oIP, true) == 0) //If that oIP is same like pIP continue
            {
                max_ips++; //incrementing max_ips var
                if(max_ips >= MAX_IPS) return Kick(playerid); //if max_ips lager or equal than MAX_IPS (3) kick playerid
            }
        }
    }
    return 1;
}
This should work.


Re: MAX IPS. - audriuxxx - 12.03.2013

I want take information from mysql, not just for connected players.