AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Checking ip same. (https://forums.alliedmods.net/showthread.php?t=217430)

yoni279 06-02-2013 15:40

Checking ip same.
 
listen if you can try to do if i type in chat : ipcheck
if someone with same ip like my ip are playing in my server its say "2 computers connected"
if not its say "only one computer connected.

^SmileY 06-02-2013 16:26

Re: Checking ip same.
 
PHP Code:

#include <amxmodx>

public plugin_cfg() register_plugin("Kick same Client IP",AMXX_VERSION_STR,"SmileY");

public 
client_putinserver(id)
{
    new 
iPlayers[32],iNum,Players;
    
get_players(iPlayers,iNum,"ch"); // Do not Kick BOTs or HLTVs
    
    
new szIP[33][17];
    
get_user_ip(id,szIP[id],charsmax(szIP[]),1// Get Users IP without port
    
    
for(new i;iNum;i++)  // Get all users IPs in server, and check if it is equal another address what is already in use
    
{
        
Players iPlayers[i];

        if(
Players == id) continue; // Removes self from LOOP to not check the same IP
        
        
get_user_ip(Players,szIP[i],charsmax(szIP[]),1); // Get IP of all players
        
        
if(equali(szIP[i],szIP[id])) server_cmd("kick #%d ^"Sorrythis IP address is already in use in server^"",get_user_userid(id));
    }


I suggest to test with care

yoni279 06-02-2013 17:25

Re: Checking ip same.
 
doesn't work

TheDS1337 06-02-2013 17:39

Re: Checking ip same.
 
Try ...
Code:

#include < amxmodx >

public client_putinserver( Client )
{
        for( new Index = 1; Index <= get_maxplayers( ); Index++ )
        {
                static AddressIP[ 32 ][ 2 ];
                get_user_ip( Client, AddressIP[ 0 ], charsmax( AddressIP[ ] ) );
                get_user_ip( Index, AddressIP[ 1 ], charsmax( AddressIP[ ] ) );
               
                if( equal( AddressIP[ 0 ], AddressIP[ 1 ] ) )               
                        server_cmd( "amx_kick ^"%s^"", AddressIP[ 0 ] );                       
               
        }
}


yoni279 06-02-2013 18:01

Re: Checking ip same.
 
listen if you can try to do if i type in chat : ipcheck
if someone with same ip like my ip are playing in my server its say "2 computers connected"
if not its say "only one computer connected.
what you give me not work

TheDS1337 06-02-2013 18:10

Re: Checking ip same.
 
Code:

#include < amxmodx >

new g_Computers;
public plugin_init( )
        register_clcmd( "say ipcheck", "ClientCommand_IPCheck" );
       
public client_putinserver( Client )
{
        for( new Index = 1; Index <= get_maxplayers( ); Index++ )
        {
                static AddressIP[ 32 ], AddressIP2[ 32 ];
                get_user_ip( Client, AddressIP, charsmax( AddressIP ) );
                get_user_ip( Index, AddressIP2, charsmax( AddressIP2 ) );
               
                if( equal( AddressIP, AddressIP2 ) )
                        g_Computers++;
        }
}

public ClientCommand_IPCheck( Client )
        client_print( Client, print_chat, g_Computers > 0 ? "%d Cumputers Connected!" : "Only One Cumputer Connected", g_Computers );


yoni279 06-02-2013 18:18

Re: Checking ip same.
 
Quote:

Originally Posted by DeagLe.Studio (Post 1963330)
Code:

#include < amxmodx >

new g_Computers;
public plugin_init( )
    register_clcmd( "say ipcheck", "ClientCommand_IPCheck" );
   
public client_putinserver( Client )
{
    for( new Index = 1; Index <= get_maxplayers( ); Index++ )
    {
        static AddressIP[ 32 ], AddressIP2[ 32 ];
        get_user_ip( Client, AddressIP, charsmax( AddressIP ) );
        get_user_ip( Index, AddressIP2, charsmax( AddressIP2 ) );
       
        if( equal( AddressIP, AddressIP2 ) )
            g_Computers++;
    }
}

public ClientCommand_IPCheck( Client )
    client_print( Client, print_chat, g_Computers > 0 ? "%d Cumputers Connected!" : "Only One Cumputer Connected", g_Computers );


isn't count only same ip is count all ip's try to fix it please.

TheDS1337 06-02-2013 18:20

Re: Checking ip same.
 
Quote:

Originally Posted by yoni279 (Post 1963334)
isn't count only same ip is count all ip's try to fix it please.

I don't understand what you need

yoni279 06-02-2013 18:26

Re: Checking ip same.
 
Quote:

Originally Posted by DeagLe.Studio (Post 1963336)
I don't understand what you need

i need plugin check if 2 coumpters with same ip like this for example:
people with this ip:212.150.176.32
connected and if some people with same ip "212.150.176.32" arleady in server is give connected people kick.

TheDS1337 06-02-2013 18:28

Re: Checking ip same.
 
Code:

#include < amxmodx >

public client_putinserver( Client )
{
        for( new Index = 1; Index <= get_maxplayers( ); Index++ )
        {
                static AddressIP[ 32 ], AddressIP2[ 32 ];
                get_user_ip( Client, AddressIP, charsmax( AddressIP ) );
                get_user_ip( Index, AddressIP2, charsmax( AddressIP2 ) );
               
                if( equali( AddressIP, AddressIP2 ) )       
                {
                        static Name[ 32 ];
                        get_user_name( Client, Name, charsmax( Name ) );
                        server_cmd( "amx_kick ^"%s^"", Name );       
                }
        }
}

Try this again :)


All times are GMT -4. The time now is 16:14.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.