AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Load ban.cfg (https://forums.alliedmods.net/showthread.php?t=263492)

Snitch 05-26-2015 18:18

Load ban.cfg
 
Can someone make me,
Code that will load a file called: ban.cfg

If it detects ip's in Config, he just will it ban
Code:

amx_addban IP "0"
EDIT;
If it detects IP 0.0.0.0
Or something else that will not bring

nnajko 05-26-2015 19:25

Re: Load ban.cfg
 
PHP Code:

#include <amxmodx>

new ban_file[] = "ban.cfg";

public 
plugin_init() 
{
    
register_plugin("IP Ban""1.0""dnk.");
    
    if( !
file_exists(ban_file) )    
    {
        
write_file(ban_file"");
    }
}

public 
client_authorized(id)
{
    if( 
<= id <= 32 )
    {
        new 
ip[64];
        
get_user_ip(idipcharsmax(ip), true);
        
check_ip(ip);
    }
}

public 
check_ip(ip[64])
{
    if( !
file_exists(ban_file) )
        return;
        
    new 
line 0data[128], length;
    while( 
read_file(ban_filelinedatacharsmax(data), length) != 0)
    {
        if( 
equal(ipdata) )
        {
            
server_cmd("amx_addban %s 0"ip);
            break;
        }
        
        
line++;
        }


Edit this to your liking.
PHP Code:

server_cmd("amx_addban %s 0"ip); 


fysiks 05-26-2015 19:42

Re: Load ban.cfg
 
Just use the standard banning system. It already does this all for you. You should have "exec listip.cfg" in your server.cfg.

Also, as usual, banning by IP is unnecessary.

Snitch 09-12-2015 07:28

Re: Load ban.cfg
 
Quote:

Originally Posted by nnajko (Post 2301391)
PHP Code:

#include <amxmodx>

new ban_file[] = "ban.cfg";

public 
plugin_init() 
{
    
register_plugin("IP Ban""1.0""dnk.");
    
    if( !
file_exists(ban_file) )    
    {
        
write_file(ban_file"");
    }
}

public 
client_authorized(id)
{
    if( 
<= id <= 32 )
    {
        new 
ip[64];
        
get_user_ip(idipcharsmax(ip), true);
        
check_ip(ip);
    }
}

public 
check_ip(ip[64])
{
    if( !
file_exists(ban_file) )
        return;
        
    new 
line 0data[128], length;
    while( 
read_file(ban_filelinedatacharsmax(data), length) != 0)
    {
        if( 
equal(ipdata) )
        {
            
server_cmd("amx_addban %s 0"ip);
            break;
        }
        
        
line++;
        }


Edit this to your liking.
PHP Code:

server_cmd("amx_addban %s 0"ip); 


Thank :), i use Advanced bans, and sometimes player get ban from server (flood) so this code will show they ip on ban.cfg?


All times are GMT -4. The time now is 20:17.

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