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

Bugsy 07-06-2015 16:33

Re: Ban if no return in 5 minutes.
 
Are you trying to compile this with the dev build? If so you will need to comment or remove that line I added for max players.

4ever16 07-06-2015 19:56

Re: Ban if no return in 5 minutes.
 
Yes latest: http://www.amxmodx.org/snapshots.php

Removed the line and i could compile it.
But still in server amx_plugins console prints ban_no_return.amxx bad load

Bugsy 07-06-2015 20:10

Re: Ban if no return in 5 minutes.
 
I don't know

Code:

[ 22] Speed Toggle            0.1        bugsy            speedtoggle.amx  running
 [ 23] Ban If No Return        0.1        bugsy            binr.amxx    running
 [ 24] unknown                unknown    unknown          untitled.amxx    running


4ever16 07-06-2015 20:20

Re: Ban if no return in 5 minutes.
 
Wierd... Really needed this for amxx 1.8.2 cause cant install 1.8.3 on the server.
What amxx version are you using?

I maybe should try to install 1.8.3 on local listen server and try. Will try this see if it helps.

BTW, did i need disconnect_reason.amxx plugin for this to work? Cause i removed it.

Bugsy 07-06-2015 20:25

Re: Ban if no return in 5 minutes.
 
I'm running one of the later dev builds, the latest will be the same.

You do not need disconnect reason, this was only needed when the plugin would react differently based on how they disconnected. client_disconnect() fires when a map is changed so the plugin was needed to differentiate map change disconnects with a player actually clicking disconnect.

4ever16 07-07-2015 08:36

Re: Ban if no return in 5 minutes.
 
Ok, i re-installed amxx 1.8.2 locally. I could compile it now without removing the line.
Uploaded the plugin to plugins folder and now its running.

Need to test it now.

4ever16 07-07-2015 08:47

Re: Ban if no return in 5 minutes.
 
Working good! Amxx 1.8.2

Ok i change the cvars before compile.

"binr_enabled" , "1"
"binr_reconnectmin" , "1"
"binr_banmins" , "2"

But when someone leaves it still says.
PLAYER left - he has 5 minutes to return or he will be banned for 60 minutes.

And btw, where are the bans saved? Cause i dont see any in banned.cfg

Im also wondering, i run automix server, when the match is live, people can still join they cant join the server but for example if i would use your plugin disconnect reason it would show, disconnect: reason: match live, server full.
So i think it is counted as disconnect and they will be banned for a false reason, trying to connect when server is full.

This maybe i should fix by adding a password when server is full so people cant even try to connect.

fysiks 07-07-2015 12:46

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

Originally Posted by 4ever16 (Post 2316623)
Working good! Amxx 1.8.2

Ok i change the cvars before compile.

"binr_enabled" , "1"
"binr_reconnectmin" , "1"
"binr_banmins" , "2"

But when someone leaves it still says.
PLAYER left - he has 5 minutes to return or he will be banned for 60 minutes.

You don't need to change them in the compiled plugin (in fact, that won't work if you don't stop your server first). You need to put those cvars in amxx.cfg and configure them how you want.

4ever16 07-07-2015 20:50

Re: Ban if no return in 5 minutes.
 
Ok, why wouldnt i work?

Ok, then i shall put those cvars in server.cfg and restart.

BTW, plugin maker, i have a problem: https://forums.alliedmods.net/showth...00#post2316900

Even if connected and auto-kicked its caunted as disconnect.
Could you make something else or solve it or should i wait for help in other thread?

I dont know, maybe that the client must be in a team first? But i think its better to wait for the password solution, i even think that if player allmost is connected and press cancel thats also counted as disconnect.

4ever16 07-08-2015 00:37

Re: Ban if no return in 5 minutes.
 
Can this be made so users with FLAG A dont get banned

Bugsy 07-08-2015 07:44

Re: Ban if no return in 5 minutes.
 
Yes, disconnect reason can detect if user was kicked and yes to FLAG A immunity.

Bugsy 07-08-2015 18:27

Re: Ban if no return in 5 minutes.
 
Updated code to obey immunity and added disconnect reason check so it will only react when the client manually disconnected.

4ever16 07-09-2015 06:10

Re: Ban if no return in 5 minutes.
 
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 );
}


4ever16 07-09-2015 21:14

Re: Ban if no return in 5 minutes.
 
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 ) )

Bugsy 07-09-2015 22:42

Re: Ban if no return in 5 minutes.
 
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 (Post 2317813)
And where are the bans stored cause it isnt in banned.cfg

It stores them wherever HLDS stores bans.


Quote:

Originally Posted by 4ever16 (Post 2317813)
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 ) )

4ever16 07-10-2015 01:37

Re: Ban if no return in 5 minutes.
 
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?

Bugsy 07-10-2015 06:56

Re: Ban if no return in 5 minutes.
 
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.

HamletEagle 07-10-2015 07:00

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

Originally Posted by Bugsy (Post 2317955)
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 ?

Mordekay 07-10-2015 09:15

Re: Ban if no return in 5 minutes.
 
Tempbans are only stored in memory iirc, so they will never be shown anywhere if not stored by amxbans or similar plugins.

Bugsy 07-10-2015 09:22

Re: Ban if no return in 5 minutes.
 
Is banid command considered a tempban? Or are you referring to the duration (time value specified vs permanent)?

Mordekay 07-10-2015 09:25

Re: Ban if no return in 5 minutes.
 
banid != 0 = tempban
So ban, banid, banip != 0 is temporary and not stored anywhere but in memory.

Bugsy 07-10-2015 09:27

Re: Ban if no return in 5 minutes.
 
So if you ban someone for 36 hours, server shuts down after 12 and restarted, the ban is lost?

Mordekay 07-10-2015 09:31

Re: Ban if no return in 5 minutes.
 
Iirc yes, that'S why i was running amxbans even if i had one server only

HamletEagle 07-10-2015 09:35

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

Originally Posted by Mordekay (Post 2318013)
Iirc yes, that'S why i was running amxbans even if i had one server only

Yes, you are right, just tested. If you shutdown the server any temporary ban is lost.

4ever16 07-10-2015 10:15

Re: Ban if no return in 5 minutes.
 
Aha good to know! Good to know thanks for the help and info.
Yes if i rcon quit the bans are lost. But thats not a problem.

BTW are u thinking of making A flag immunity without that disconnect reason plugin?

Bugsy 07-10-2015 17:42

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

Originally Posted by 4ever16 (Post 2318030)
Aha good to know! Good to know thanks for the help and info.
Yes if i rcon quit the bans are lost. But thats not a problem.

BTW are u thinking of making A flag immunity without that disconnect reason plugin?

Is that your way of asking for removing the disconnect reason plugin? I can, but I thought you had a problem where players were getting kicked and it was treated as if they disconnected. This is why I re-added it.

4ever16 07-11-2015 05:18

Re: Ban if no return in 5 minutes.
 
Well i have 12 slots server.
The auto mix + customvotes makes the server 2on2, 3on3, 4on4, 5on5. So if someone voted 2on2 max players who can join the server is 4 but still there are 12 slots so people can try to join but are kicked before even joining.
So i solved this problem by setting up ¨sv_visiblemaxplayers 4¨ https://forums.alliedmods.net/showthread.php?t=265946

So thats not a problem anymore.

Anyways i found another problem, yes people get banned when not re-joining in the specific time but, there arnt banned for exact time i set in
binr_banmins 1200
So should i change all ¨
iReconnectMinutes * 60¨ to 1200 ?

Bugsy 07-11-2015 08:53

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

Originally Posted by 4ever16 (Post 2318303)
Well i have 12 slots server.
The auto mix + customvotes makes the server 2on2, 3on3, 4on4, 5on5. So if someone voted 2on2 max players who can join the server is 4 but still there are 12 slots so people can try to join but are kicked before even joining.
So i solved this problem by setting up ¨[COLOR=Red]sv_visiblemaxplayers 4¨ https://forums.alliedmods.net/showthread.php?t=265946
So thats not a problem anymore.


Ok, I will take out the disconnect reason code.
Quote:

Originally Posted by 4ever16 (Post 2318303)
binr_banmins 1200
So should i change all ¨
iReconnectMinutes * 60¨ to 1200 ?

No, since there are not 1200 seconds in an minute; keep this at 60. The reason that is there is because the timing system being used is in seconds (get_system()) so the cvar value (minutes) must be multiplied by 60 to convert it to seconds to do the comparison. Plus, that code has nothing to do with the actual ban, that checks the reconnect minutes value to decide if the person should be banned, which it sounds like it is working.
PHP Code:

( ( get_systime() - pdDataDisconnectTime ] ) > ( iReconnectMinutes 60 ) ) 

The piece of code that actually bans is below, which you can see is simple and is set in compliance with what HLDS says to do:

PHP Code:

public BanPlayer( const szAuthID[] )
{
     
server_cmd"banid %d %s" get_pcvar_numg_pBanMinutes ) , szAuthID );


If you type 'banid' in your server console, it will tell you how to ban someone. The plugin is issuing the ban exactly as HLDS requires so this is no code issue, it's a ban system issue. You may need a new ban system if the native one is not working as you want. Maybe try advanced bans by exolent? https://forums.alliedmods.net/showthread.php?t=80858
Code:

] banid
Usage:  banid <minutes> <uniqueid or #userid> { kick }
Use 0 minutes for permanent


4ever16 07-17-2015 03:20

Re: Ban if no return in 5 minutes.
 
Ok, so i tried this plugin it seemed to be working. But not.
I and others still get a ban if we do not return in 3 minutes. But we dont get banned for 1200 minutes.

Im testing now for how long i have a ban when it should be 1200 minutes thats 20 hours.

Do u have any suggestions?

Maybe try to change last line banid to amx_ban or amx_addban? More info about this here btw the plugin in this link doesnt work: https://forums.alliedmods.net/archiv.../t-105731.html

Bugsy 07-17-2015 08:38

Re: Ban if no return in 5 minutes.
 
If you want to change to another ban system that's fine, just modify the server cmd line that sends the ban command.


All times are GMT -4. The time now is 00:29.

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