Raised This Month: $ Target: $400
 0% 

Solved Remove all bans on the server by month


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 02-13-2016 , 01:23   Remove all bans on the server by month
Reply With Quote #1

Quote:
Hi guys

For some time I have wanted to do something like this to remove all prohibitions without turning off the server... I would like this process to be done every months automatically, I think it would be a nice plugin
I got my solution, "ConnorMcLeod" had already done long ago what I wanted to do but I've added a tool designed to run this command on the exact date through a "cvar" and also to activate...

PHP Code:
#include <amxmodx>

#define PLUGIN "Bans Reset"
#define VERSION "0.0.4"
#define AUTHOR "ConnorMcLeod & mlibre"

#define ADMIN_FLAG ADMIN_RCON

new g_pCvarBannedCfgFileg_cvarActiveg_cvarMonthg_pCvarListipCfgFile

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_concmd("amx_reset_bans""ConCmd_ResetBans")        // removes all bans
    
    
g_cvarActive register_cvar("amx_reset_bans_active""1")    // 1 = on / 0 = off
    
g_cvarMonth register_cvar("amx_reset_bans_month""31/12")    // run every December 31
    
    
g_pCvarBannedCfgFile get_cvar_pointer("bannedcfgfile")
    
g_pCvarListipCfgFile get_cvar_pointer("listipcfgfile")
}

public 
plugin_cfg()
{
    if(
get_pcvar_num(g_cvarActive))
    {
        new 
getString[11], getTime[11]
        
        
get_pcvar_string(g_cvarMonthgetStringcharsmax(getString))
        
        
get_time("%d/%m"getTimecharsmax(getTime))
        
        if(
equal(getTimegetString))
        {
            
ConCmd_ResetBans(0)
        }
    }
}

public 
ConCmd_ResetBans(id)
{
    if( !(
get_user_flags(id) & ADMIN_FLAG) ) 
    {
        
engclient_print(idengprint_console"[AMXX] access denied (only admins)")
        
        return
    }
    
    static 
szGetCfgFile[260]
    
    
get_pcvar_string(g_pCvarBannedCfgFileszGetCfgFilecharsmax(szGetCfgFile))
    
    
server_cmd("writeid;writeip")
    
server_exec()
    
    new 
buffer[64], szSteamIdOrIp[32], crap[2]
    
    new 
fp fopen(szGetCfgFile"rt")
    
    if(
fp)
    {
        while(
fgets(fpbuffercharsmax(buffer)))
        {
            
trim(buffer)
            
            if(
parse(buffercrap1crap1szSteamIdOrIpcharsmax(szSteamIdOrIp)) == 3)
            {
                
server_cmd("removeid %s"szSteamIdOrIp)
            }
        }
        
server_exec()
            
        
fclose(fp)
        
        
fp 0
            
        server_cmd
("writeid")
        
server_exec()
    }
    
    
get_pcvar_string(g_pCvarListipCfgFileszGetCfgFilecharsmax(szGetCfgFile))
    
    
fp fopen(szGetCfgFile"rt")
    
    if(
fp)
    {
        while(
fgets(fpbuffercharsmax(buffer)))
        {
            
trim(buffer)
            
            if(
parse(buffercrap1crap1szSteamIdOrIpcharsmax(szSteamIdOrIp)) == 3)
            {
                
server_cmd("removeip %s"szSteamIdOrIp)
            }
        }
        
server_exec()
            
        
fclose(fp)
        
        
fp 0
            
        server_cmd
("writeip")
        
server_exec()
    }

v0.0.3 update 04-16-23


v0.0.2 update 02-16-16


v0.0.1 release 11-09-12

Last edited by mlibre; 04-17-2023 at 19:34. Reason: v0.0.4 update
mlibre is offline
Reply


Thread Tools
Display Modes

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 16:44.


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