AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Solved Ban players if disconnect (https://forums.alliedmods.net/showthread.php?t=265792)

4ever16 07-05-2015 05:24

Ban players if disconnect
 
So im searching for a plugin which bans people for disconnecting but they have 5 minutes to return.
If they return in 5 minutes no ban, if they return after 5 minutes ban!

If mapchange was made within those five minutes, ban!

Simple cvars.

Ban_leavers 1
Ban_time 60
No_ban_return_time 5

It would also be cool if when a player disconnects a message is shown, player 1 left - he got 5 minutes to return of he will be banned for 60 minutes.

wickedd 07-05-2015 12:23

Re: Ban if no return in 5 minutes.
 
Damn! Bugsy was helping you in your other thread, there's no reason to start a new one.

Bugsy 07-05-2015 14:03

Re: Ban if no return in 5 minutes.
 
1 Attachment(s)
Not thoroughly tested. Use the attached CellTravTrie include as the original one has a warning when compiled due to the author not tagging a variable as a bool in TravTrieGetArrayEx().

Edit: Removed disconnect reason code.
PHP Code:

#include <amxmodx>
#include <engine>
#include <celltravtrie>

new const Version[] = "0.3";

const 
Float:EntityTimerInterval 10.0

enum _:PlayerData
{
    
AuthID34 ],
    
DisconnectTime
}

new 
TravTrie:ttTrie g_pdDataMAX_PLAYERS ][ 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" "5" );
    
g_pBanMinutes register_cvar"binr_banmins" "60" );
    
    
g_Entity create_entity"info_target" );
    
entity_set_stringg_Entity EV_SZ_classname "binr_entity" );
    
register_think"binr_entity" "EntityThink" );
    
entity_set_floatg_Entity EV_FL_nextthink , ( get_gametime() + EntityTimerInterval ) );
    
    
ttTrie TravTrieCreate();
}

public 
plugin_end()
{
    
call_thinkg_Entity );
    
TravTrieDestroyttTrie );
}

public 
client_authorizedid )
{
    new 
pdDataPlayerData ] , iTrieKey szKickMessage60 ] , iReconnectMinutes;

    
get_user_authidid g_pdDataid ][ AuthID ] , charsmaxg_pdData[][ AuthID ] ) );

    
iTrieKey str_to_numg_pdDataid ][ AuthID ][ 10 ] );
    
    if ( 
TravTrieGetArrayExttTrie iTrieKey pdData sizeofpdData ) ) && pdDataDisconnectTime ] )
    {
        
iReconnectMinutes get_pcvar_numg_pReconnectMinutes );
        
        if ( 
get_pcvar_numg_pBanLeavers ) && ( ( get_systime() - pdDataDisconnectTime ] ) > ( iReconnectMinutes 60 ) ) )
        {
            
formatexszKickMessage charsmaxszKickMessage ) , "^nYou have been banned for %d minutes for not re-joining within %d minutes" get_pcvar_numg_pBanMinutes ) , iReconnectMinutes );     
            
message_beginMSG_ONE , {0,0,0} , id );     
            
write_stringszKickMessage );     
            
message_end();    
    
            
BanPlayerpdDataAuthID ] );
            
            
TravTrieDeleteKeyExttTrie iTrieKey );
        }
        else
        {
            
pdDataDisconnectTime ] = 0;
            
TravTrieSetArrayExttTrie iTrieKey pdData sizeofpdData ) );
        }
    }
}

public 
client_disconnectid )
{
    new 
szName33 ];
    
    if (!( 
get_user_flagsid ) & ADMIN_IMMUNITY ) )
    {
        
get_user_nameid szName charsmaxszName ) );
        
client_printprint_chat "* %s left - he has %d minutes to return or he will be banned for %d minutes." szName get_pcvar_numg_pReconnectMinutes ) , get_pcvar_numg_pBanMinutes ) );
        
        
g_pdDataid ][ DisconnectTime ] = get_systime();
        
TravTrieSetArrayExttTrie str_to_numg_pdDataid ][ AuthID ][ 10 ] ) , g_pdDataid ] , sizeofg_pdData[] ) );
    }
}

public 
EntityThinkiEntity )
{
    if( ( 
iEntity == g_Entity ) && get_pcvar_numg_pBanLeavers ) ) 
    {
        new 
travTrieIter:ttIterator pdDataPlayerData ] , iTimeLeft iReconnectMinutes iSysTime;
        
        
ttIterator GetTravTrieIteratorttTrie );
        
iTimeLeft get_timeleft();
        
iSysTime get_systime();
        
iReconnectMinutes get_pcvar_numg_pReconnectMinutes );
        
        while ( 
MoreTravTriettIterator ) )
        {
            
ReadTravTrieArrayttIterator pdData sizeofpdData ) );
            
            if ( ( 
iTimeLeft 30 ) || ( iSysTime pdDataDisconnectTime ] ) > ( iReconnectMinutes 60 ) )
            {
                
BanPlayerpdDataAuthID ] );
                
TravTrieDeleteKeyExttTrie str_to_numpdDataAuthID ][ 10 ] ) );
            }
        }
        
        
DestroyTravTrieIteratorttIterator );
        
        
entity_set_floatg_Entity EV_FL_nextthink , ( get_gametime() + EntityTimerInterval ) );
    }
}
 
public 
BanPlayer( const szAuthID[] )
{
     
server_cmd"banid %d %s" get_pcvar_numg_pBanMinutes ) , szAuthID );



4ever16 07-05-2015 21:31

Re: Ban if no return in 5 minutes.
 
Looks grate, want to test it but cant compile. Yes i downloaded celltravtrie.inc and placed it in include folder.

Quote:

Error: 017 undifiend symbol ´MAX PLAYERS´

Bugsy 07-06-2015 08:26

Re: Ban if no return in 5 minutes.
 
You're not using the latest AMX-X dev build. Add this:
PHP Code:

const MAX_PLAYERS 32


fysiks 07-06-2015 08:46

Re: Ban if no return in 5 minutes.
 
Quote:

Originally Posted by Bugsy (Post 2316178)
You're not using the latest AMX-X build. Add this:
PHP Code:

const MAX_PLAYERS 32


You mean he is not using the beta AMX Mod X build.

Bugsy 07-06-2015 08:56

Re: Ban if no return in 5 minutes.
 
Quote:

Originally Posted by fysiks (Post 2316186)
You mean he is not using the beta AMX Mod X build.

You mean he is not using the latest beta AMX Mod X build.

4ever16 07-06-2015 13:00

Re: Ban if no return in 5 minutes.
 
Well i downloaded lastest beta AMXX the compile went good.
But i cant install latest beta on the server. Using 1.8.2 now.

When i write in commands amx_plugins ban_leave.amxx it ses error bad load, is it cause the server doesnt have latest beta amxx?

Will this help me to run the plugin on amxx 1.8.2?

Quote:

const MAX_PLAYERS = 32;
If yes where do i put this line?

Bugsy 07-06-2015 13:05

Re: Ban if no return in 5 minutes.
 
I added the line to the above code, try it.

4ever16 07-06-2015 16:15

Re: Ban if no return in 5 minutes.
 
Error, now i cant even compile when u added those lines.

http://s15.************/9ro4we8bt/2222.png


All times are GMT -4. The time now is 10:02.

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