This is from 2.3.2 pre configured cs/cz:
Code: Select all
// Prune the database of old records
public XP_Prune()
{
#if ADVANCED_DEBUG
writeDebugInfo("XP_Prune", 0);
#endif
if ( iCvar[FT_AUTO_PRUNING] )
{
// Vault pruning (only works with vaults created with version 2.2.8)
if ( !iCvar[SV_SQL] )
{
new szVault[] = "addons/amxmodx/data/vault.ini";
// Make sure the vault exists
if ( file_exists( szVault ) )
{
new len, line, szText[256];
new iCurrentTime = get_systime();
// 86400 = 24 hours * 60 minutes * 60 seconds
new iExpiredTime = iCurrentTime - (iCvar[SV_DAYSBEFOREDELETE] * 86400);
// Check every line in the vault
while ( (line = read_file(szVault, line, szText, 255, len)) != 0 )
{
// The first 2 lines are not actual data, so lets skip them
if ( line > 2 )
{
new szID[32], szAuthID[32], szXP[8], szRace[2], szSkill1[2], szSkill2[2], szSkill3[2], szSkill4[2], szIP[32], szTimestamp[32];
parse(szText, szID, 31, szAuthID, 31, szXP, 7, szRace, 1, szSkill1, 1, szSkill2, 1, szSkill3, 1, szSkill4, 1, szIP, 31, szTimestamp, 31);
// Verify its the new vault timestamp
if ( strlen(szTimestamp) > 2 )
{
new iUserTimestamp = str_to_num( szTimestamp );
server_print( "[VAULT] Checking %d < %d", iUserTimestamp, iExpiredTime );
if ( iUserTimestamp < iExpiredTime )
{
server_print( "[VAULT] Expired removing %s", szID );
}
}
}
}
}
}
// MySQL/SQLLite pruning
else
{
new query[256];
if ( iSQLtype == SQL_MYSQL )
{
// Timestamp format: 20030912122142
// Y = 2003 M = 09 D = 12 H = 12 M = 21 S = 42
format( query, 255, "DELETE FROM `%s` WHERE DATE_SUB(CURDATE(),INTERVAL %d DAY) > time;", g_DBTableName, iCvar[SV_DAYSBEFOREDELETE] );
}
else if ( iSQLtype == SQL_SQLITE )
{
// Timestamp format: 2003-09-12 12:21:42
// Y = 2003 M = 09 D = 12 H = 12 M = 21 S = 42
format( query, 255, "DELETE FROM `%s` WHERE ((julianday(`time`) + %d) < julianday('now'))", g_DBTableName, iCvar[SV_DAYSBEFOREDELETE] );
}
dbi_query(sql, query);
// Vacuum the SQL LITE DB Table
if (iSQLtype == SQL_SQLITE)
{
format( query, 255, "VACUUM `%s`", g_DBTableName );
dbi_query( sql, query );
}
}
log_amx("Database pruning successful, data older than %d days was removed", iCvar[SV_DAYSBEFOREDELETE]);
}
}
Is suppose it should be something like that:
Code: Select all
...
server_print( "[VAULT] Checking %d < %d", iUserTimestamp, iExpiredTime );
if ( iUserTimestamp < iExpiredTime )
{
server_print( "[VAULT] Expired removing %s", szID );
vault_remove(id);
}
...
Otherwise, nothing will be removed, like now.