Raised This Month: $32 Target: $400
 8% 

Solved Ban players if disconnect


Post New Thread Reply   
 
Thread Tools Display Modes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-08-2015 , 07:44   Re: Ban if no return in 5 minutes.
Reply With Quote #21

Yes, disconnect reason can detect if user was kicked and yes to FLAG A immunity.
__________________
Bugsy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-08-2015 , 18:27   Re: Ban if no return in 5 minutes.
Reply With Quote #22

Updated code to obey immunity and added disconnect reason check so it will only react when the client manually disconnected.
__________________
Bugsy is offline
4ever16
Veteran Member
Join Date: Apr 2015
Old 07-09-2015 , 06:10   Re: Ban if no return in 5 minutes.
Reply With Quote #23

Good that i saved the last code u posted.
I really dont want to many plugins on the server and specielly those with alot of messages.

So i solved my problem here: https://forums.alliedmods.net/showthread.php?t=265946

But still i would like flag a immunity in the last code u wrote.
This one.

Code:
#include <amxmodx>
#include <engine>
#include <celltravtrie>

new const Version[] = "0.1";

const Float:EntityTimerInterval = 10.0; 
const MAX_PLAYERS = 32;

enum _:PlayerData
{
    AuthID[ 34 ],
    DisconnectTime
}

new TravTrie:ttTrie , g_pdData[ MAX_PLAYERS + 1 ][ PlayerData ];
new g_Entity , g_pBanLeavers , g_pReconnectMinutes , g_pBanMinutes;

public plugin_init() 
{
    register_plugin( "Ban If No Return" , Version , "bugsy" );
    
    g_pBanLeavers = register_cvar( "binr_enabled" , "1" );
    g_pReconnectMinutes = register_cvar( "binr_reconnectmin" , "10" );
    g_pBanMinutes = register_cvar( "binr_banmins" , "1200" );
    
    g_Entity = create_entity( "info_target" );
    entity_set_string( g_Entity , EV_SZ_classname , "binr_entity" );
    register_think( "binr_entity" , "EntityThink" );
    entity_set_float( g_Entity , EV_FL_nextthink , ( get_gametime() + EntityTimerInterval ) );
    
    ttTrie = TravTrieCreate();
}

public plugin_end()
{
    call_think( g_Entity );
    TravTrieDestroy( ttTrie );
}

public client_authorized( id )
{
    new pdData[ PlayerData ] , iTrieKey , szKickMessage[ 60 ] , iReconnectMinutes;

    get_user_authid( id , g_pdData[ id ][ AuthID ] , charsmax( g_pdData[][ AuthID ] ) );

    iTrieKey = str_to_num( g_pdData[ id ][ AuthID ][ 10 ] );
    
    if ( TravTrieGetArrayEx( ttTrie , iTrieKey , pdData , sizeof( pdData ) ) && pdData[ DisconnectTime ] )
    {
        iReconnectMinutes = get_pcvar_num( g_pReconnectMinutes );
        
        if ( get_pcvar_num( g_pBanLeavers ) && ( ( get_systime() - pdData[ DisconnectTime ] ) > ( iReconnectMinutes * 60 ) ) )
        {
            formatex( szKickMessage , charsmax( szKickMessage ) , "^nYou have been banned for %d minutes for not re-joining within %d minutes" , get_pcvar_num( g_pBanMinutes ) , iReconnectMinutes );     
            message_begin( MSG_ONE , 2 , {0,0,0} , id );     
            write_string( szKickMessage );     
            message_end();    
    
            BanPlayer( pdData[ AuthID ] );
            
            TravTrieDeleteKeyEx( ttTrie , iTrieKey );
        }
        else
        {
            pdData[ DisconnectTime ] = 0;
            TravTrieSetArrayEx( ttTrie , iTrieKey , pdData , sizeof( pdData ) );
        }
    }
}

public client_disconnect( id )
{
    new szName[ 33 ];
    get_user_name( id , szName , charsmax( szName ) );
    client_print( 0 , print_chat , "* %s left - he has 10 minutes to return or banned gets for 20 hours." , szName , get_pcvar_num( g_pReconnectMinutes ) , get_pcvar_num( g_pBanMinutes ) );
    
    g_pdData[ id ][ DisconnectTime ] = get_systime();
    TravTrieSetArrayEx( ttTrie , str_to_num( g_pdData[ id ][ AuthID ][ 10 ] ) , g_pdData[ id ] , sizeof( g_pdData[] ) );
}

public EntityThink( iEntity )
{
    if( ( iEntity == g_Entity ) && get_pcvar_num( g_pBanLeavers ) ) 
    {
        new travTrieIter:ttIterator , pdData[ PlayerData ] , iTimeLeft , iReconnectMinutes , iSysTime;
        
        ttIterator = GetTravTrieIterator( ttTrie );
        iTimeLeft = get_timeleft();
        iSysTime = get_systime();
        iReconnectMinutes = get_pcvar_num( g_pReconnectMinutes );
        
        while ( MoreTravTrie( ttIterator ) )
        {
            ReadTravTrieArray( ttIterator , pdData , sizeof( pdData ) );
            
            if ( ( iTimeLeft < 30 ) || ( iSysTime - pdData[ DisconnectTime ] ) > ( iReconnectMinutes * 60 ) )
            {
                BanPlayer( pdData[ AuthID ] );
                TravTrieDeleteKeyEx( ttTrie , str_to_num( pdData[ AuthID ][ 10 ] ) );
            }
        }
        
        DestroyTravTrieIterator( ttIterator );
        
        entity_set_float( g_Entity , EV_FL_nextthink , ( get_gametime() + EntityTimerInterval ) );
    }
}
 
public BanPlayer( const szAuthID[] )
{
     server_cmd( "banid %d %s" , get_pcvar_num( g_pBanMinutes ) , szAuthID );
}

Last edited by 4ever16; 07-09-2015 at 06:12.
4ever16 is offline
4ever16
Veteran Member
Join Date: Apr 2015
Old 07-09-2015 , 21:14   Re: Ban if no return in 5 minutes.
Reply With Quote #24

Im wondering how this plugin works.

So we say that plugin is enabled. When i disconnect the plugin counts we say 3 minutes. After 3 minutes it adds a ban on the disconnected steam id right?
But if a map was changed for example and that map doesnt have the plugin enabled the plugin just couldnt count up ti 3 minutes so it didnt ban the player right?

And if plugin was enabled and banned one player.
Mapchange, plugin disabled the player can join again because the plugin is checking all leavers?

And where are the bans stored cause it isnt in banned.cfg

So i ran some tests.
I enabled plugin, disconnected, tried to join again in 4 minutes. Yes i couldnt join cause of the ban.
Change removed the plugin, changed the map thru rcon, tried to join. Yes i couldnt join so everything seems to work.
But still, if i leave the server like 2 minutes before the plugin is disabled (reconnect time is 3 minutes) and tried to join it again i could, cause the plugin didnt count to 3 minutes and banned me yet? Right?

In your code is it importet to change these lines and what those those lines mean?
Quote:
if ( ( iTimeLeft < 30 ) || ( iSysTime - pdData[ DisconnectTime ] ) > ( iReconnectMinutes * 60 ) )

Last edited by 4ever16; 07-09-2015 at 21:29.
4ever16 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-09-2015 , 22:42   Re: Ban if no return in 5 minutes.
Reply With Quote #25

When the plugin is disabled, it will not do anything. I thought this was common knowledge. Or am I misinterpreting your questions.

Quote:
Originally Posted by 4ever16 View Post
And where are the bans stored cause it isnt in banned.cfg
It stores them wherever HLDS stores bans.


Quote:
Originally Posted by 4ever16 View Post
In your code is it importet to change these lines and what those those lines mean?
This is to make bans happen if a map change is approaching.
( iTimeLeft < 30 )

This is if the user did not reconnect within the set time.
( iSysTime - pdData[ DisconnectTime ] ) > ( iReconnectMinutes * 60 ) )
__________________
Bugsy is offline
4ever16
Veteran Member
Join Date: Apr 2015
Old 07-10-2015 , 01:37   Re: Ban if no return in 5 minutes.
Reply With Quote #26

To get it right i need to change like this. I want a ban of 20 hours thats 1200 minutes.
So what values do i need to change if i want no return in 3 minutes and ban 1200 minutes?

Last edited by 4ever16; 07-10-2015 at 01:42.
4ever16 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-10-2015 , 06:56   Re: Ban if no return in 5 minutes.
Reply With Quote #27

binr_reconnectmin 3
binr_banmins 1200

And I'm not sure why bans are not showing in the cfg, I noticed this as well during testing. Maybe search the net for this issue.
__________________

Last edited by Bugsy; 07-10-2015 at 06:57.
Bugsy is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-10-2015 , 07:00   Re: Ban if no return in 5 minutes.
Reply With Quote #28

Quote:
Originally Posted by Bugsy View Post
binr_reconnectmin 3
binr_banmins 1200

And I'm not sure why bans are not showing in the cfg, I noticed this as well during testing. Maybe search the net for this issue.
AFAIK it doesn't show until you close and restart the server. Maybe because the file is open and never closed during run time ?
__________________
HamletEagle is offline
Mordekay
Squirrel of Fortune
Join Date: Apr 2006
Location: Germany
Old 07-10-2015 , 09:15   Re: Ban if no return in 5 minutes.
Reply With Quote #29

Tempbans are only stored in memory iirc, so they will never be shown anywhere if not stored by amxbans or similar plugins.
__________________

Mordekay is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-10-2015 , 09:22   Re: Ban if no return in 5 minutes.
Reply With Quote #30

Is banid command considered a tempban? Or are you referring to the duration (time value specified vs permanent)?
__________________
Bugsy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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