MAX IPS.
#1

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?
Reply
#2

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 ); }
}
Reply
#3

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.
Reply
#4

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


Forum Jump:


Users browsing this thread: 1 Guest(s)