View Single Post
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 02-23-2024 , 10:49   Re: Auto Restart /top15 for month
Reply With Quote #9

proof

PHP Code:
#include <amxmodx>

#define PLUGIN "autoResetStats"
#define VERSION "1.2a"
#define AUTHOR "mlibre"

new const cvar_csx[] = "csstats_reset"

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_cvar(PLUGINVERSIONFCVAR_SERVER FCVAR_SPONLY)
}

public 
plugin_cfg()
{
    if(
cvar_exists(cvar_csx))
    {
        
autoResetStats()
    }
    else
    {
        
server_print("[%s] The csx module is not loaded!"PLUGIN)
    }
}

autoResetStats()
{
    
set_cvar_num(cvar_csx0)
    
    
server_print("[%s] Checking day!"PLUGIN)
    
    new 
getDay[3]; get_time("%d"getDaycharsmax(getDay))
    
    if(
equal(getDay"01")) //<-every first day of the month
    
{
        if(
chk(PLUGIN))
        {
            
server_print("[%s] The statistics have already been reset this month!"PLUGIN)
            
            return
        }
        
        
set_cvar_num(cvar_csx1)
        
        
server_print("[%s] Statistics have been reset!"PLUGIN)
        
        new 
fp fopen(PLUGIN"w"); fclose(fp)
    }
    else
    {
        
server_print("[%s] It's not time!"PLUGIN)
        
        if(
chk(PLUGIN))
        {
            
delete_file(PLUGIN)
        }
    }
}

stock chk(file[])
{
    if(
file_exists(file))
    {
        return 
1
    
}
    
    return 
0

__________________

Last edited by mlibre; 02-23-2024 at 12:27. Reason: upd v1.2a
mlibre is offline