Raised This Month: $51 Target: $400
 12% 

Solved Ban players if disconnect


Post New Thread Reply   
 
Thread Tools Display Modes
4ever16
Veteran Member
Join Date: Apr 2015
Old 11-19-2015 , 02:21   Re: Ban if no return in 5 minutes.
Reply With Quote #61

It was only a sugestion.
The thing is i know some server which has this function ban if no return but they dont wanan share the .sma or .amxx
So there is a way to do it.

Last edited by 4ever16; 11-19-2015 at 02:28.
4ever16 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-19-2015 , 10:14   Re: Ban if no return in 5 minutes.
Reply With Quote #62

If a player has a temp ban for say 2 hours and the server crashes and restarts one hour into his ban, he is then no longer banned?
__________________
Bugsy is online now
4ever16
Veteran Member
Join Date: Apr 2015
Old 11-19-2015 , 16:35   Re: Ban if no return in 5 minutes.
Reply With Quote #63

Correct but it doesnt matter cause server never goes down.
4ever16 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-19-2015 , 20:20   Re: Ban if no return in 5 minutes.
Reply With Quote #64

Quote:
Originally Posted by Bugsy View Post
If a player has a temp ban for say 2 hours and the server crashes and restarts one hour into his ban, he is then no longer banned?
Yes. All things in memory are lost when the server crashes or shuts down. That is why I had to write a plugin to persist temporary bans since we have our server stopped/started daily.
__________________

Last edited by fysiks; 11-19-2015 at 20:21.
fysiks is offline
4ever16
Veteran Member
Join Date: Apr 2015
Old 11-25-2015 , 10:12   Re: Ban if no return in 5 minutes.
Reply With Quote #65

Any solutions mr Bugsy or someone else?

Quote:
Originally Posted by Bugsy View Post
If a player has a temp ban for say 2 hours and the server crashes and restarts one hour into his ban, he is then no longer banned?
Read some posts behind i wrote all info how the bans work.
https://forums.alliedmods.net/showpo...8&postcount=53

Last edited by 4ever16; 11-25-2015 at 10:13.
4ever16 is offline
4ever16
Veteran Member
Join Date: Apr 2015
Old 11-29-2015 , 15:40   Re: Ban if no return in 5 minutes.
Reply With Quote #66

Really doesnt anyone got any idea how to make this plugin?
This thread is most viewed past months.

There is a solution i know it cause i know some server running this.
This plugin is made for pugs mixes only not for public play.
If u wanna play a match play a match u know.
4ever16 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-29-2015 , 16:31   Re: Ban if no return in 5 minutes.
Reply With Quote #67

Can you refresh my memory on what the exact issue is with the plugin?
__________________
Bugsy is online now
4ever16
Veteran Member
Join Date: Apr 2015
Old 11-29-2015 , 17:38   Re: Ban if no return in 5 minutes.
Reply With Quote #68

Bans player permanantly.
Quote:
server_cmd( "banid %d %s" , get_pcvar_num( g_pBanMinutes ) , szAuthID );
Bans player right amount of time but the ban is removed when mapchange is done.
Quote:
server_cmd( "banid %d %s %L" , get_pcvar_num( g_pBanMinutes ) , szAuthID );
I have tried to put other server_cmd commands like amx_addban amx_ban etc but it doesnt work.
I dont know not to be rude or so cause im very thanful for people helping me in this forum but do you coders just write code and not test stuff?

Well hope u got some idea of making it. You can search ban leave, disconnect ban here on the forum but they dont work but it might help you get some idea.

What im thinking is that the bans needs to be saved in a file or something with amxxbans maybe and removed after the right amoun of time i dont know im not a coder.
4ever16 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-29-2015 , 17:38   Re: Ban if no return in 5 minutes.
Reply With Quote #69

Ok disregard, sorry I am lazy. I just read that one post where you advised of the issues. So the only real issue is the ban not working for non-permanent bans since they do not exist after a map change. I will make the plugin itself handle these bans, and only use the amx_ban command for permanent bans. I'll probably use nvault to store these bans. Does this sound ok?
__________________

Last edited by Bugsy; 11-29-2015 at 18:36.
Bugsy is online now
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-29-2015 , 18:26   Re: Ban if no return in 5 minutes.
Reply With Quote #70

This uses nvault to store all bans. The value/data of the vault entry is a timestamp of when the player was banned and the actual vault entry timestamp is when their ban expires. The vault is pruned on map change to delete all bans that have expired. Entries with a 0 timestamp never get pruned since they are considered permanent entries by nvault. Doing it this way allows you to determine when a player was banned, and when his ban will expire--it also allows for easy maintenance of the vault since it can be pruned to clear out expired bans. These bans are accurate to the second. I have not tested this at all, let me know if it works.

You can use nvault editor (see sig) to see any bans that exist in the vault. At this website you can convert a timestamp to time to see that it is setting the ban correctly: http://www.unixtimestamp.com/
PHP Code:

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

new const Version[] = "0.5c";

#define MAX_PLAYERS 32

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 g_Vault g_IgnorePlayers g_HasAuthorized;

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();
    
    
g_Vault nvault_open"BINR" );
}

public 
plugin_cfg()
{
    
nvault_pruneg_Vault get_systime() );
}

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

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

    
g_IgnorePlayers |= ( is_user_botid ) || is_user_hltvid ) ? ) << ( id 31 );
    
g_HasAuthorized |= ( << ( id 31 ) );
    
    if ( !( 
g_IgnorePlayers & ( << ( id 31 ) ) ) )
    {
        
get_user_authidid g_pdDataid ][ AuthID ] , charsmaxg_pdData[][ AuthID ] ) );
    
        if ( 
nvault_lookupg_Vault g_pdDataid ][ AuthID ] , szBanTime charsmaxszBanTime ) , iTS ) )
        {
            if ( !
iTS || ( get_systime() < iTS ) )
            {
                
message_beginMSG_ONE , {0,0,0} , id );     
                
write_string"You are banned." );     
                
message_end();        
            }
            else
            {
                
nvault_removeg_Vault ,  g_pdDataid ][ AuthID ] );
            }
        }
        else
        {
            
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 ( ( 
g_HasAuthorized & ( << ( id 31 ) ) ) && !( get_user_flagsid ) & ADMIN_IMMUNITY ) && !( g_IgnorePlayers & ( << ( id 31 ) ) ) )
    {
        
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[] ) );
    }
    
    
g_IgnorePlayers &= ~( << ( id 31 ) );
    
g_HasAuthorized &= ~( << ( id 31 ) );
}

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[] )
{
    new 
szBanTime11 ] , iBanMinutes;
    
    
iBanMinutes get_pcvar_numg_pBanMinutes  );
    
num_to_strget_systime() , szBanTime charsmaxszBanTime ) );
    
    
nvault_setg_Vault szAuthID szBanTime );
    
nvault_touchg_Vault szAuthID iBanMinutes get_systime() + ( iBanMinutes 60 ) : );

__________________

Last edited by Bugsy; 12-01-2015 at 23:17.
Bugsy is online now
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 11:31.


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