Simple Online Logger by mx?!

Shadowless

Пользователь
Регистрация
24 Фев 2019
Сообщения
237
Симпатии
4
Пол
Мужской
OS
Linux
Amx Mod X
AMXX 1.9.0
Билд
NoNeed
ReGamedll
NoNeed
Metamod
NoNeed
Meta модули
Код:
NoNeed
Плагины
Код:
NoNeed
Amxx Модули
Код:
NoNeed
Ошибка
Код:
NoNeed
Исходник
Код:
/* При просмотре и редактировании данного файла необходимо использовать кодировку 'UTF-8 без BOM' */
/* Требования:
* AMX Mod X версии 1.8.1, либо новее
* Модуль nVault
*/

/* ---------------------- НАСТРОЙКИ ---------------------- */

const MAXSIZE = 33 // MaxPlayers + 1

// Записи игроков, не заходивших указанное кол-во дней, удаляются из хранилища
#define PRUNE_DAYS 30 // Меньше 1, - отключить (не рекомендуется)

// Имя хранилища (директория хранения: addons/amxmodx/data/vault)
#define VAULT_NAME "sol_online"

/* ---------------------- НАСТРОЙКИ ---------------------- */

#include <amxmodx>
#include <nvault>

#define CheckBit(%0,%1) (%0 & (1 << %1))
#define SetOneBit(%0,%1) (%0 |= (1 << %1))
#define ClearBit(%0,%1) (%0 &= ~(1 << %1))
#define chx charsmax

stock const SECONDS_IN_DAY = 86400 // Количество секунд в одном дне [time.inc -> SECONDS_IN_DAY]
const AUTHID_STRLEN = 24

new g_iTime[MAXSIZE], g_iVault, g_iConnPlayers, g_iAuthPlayers, g_iCheckPlayers

public plugin_init() {
register_plugin( "Simple Online Logger", "10.04.18", "mx?!" )
if((g_iVault = nvault_open(VAULT_NAME)) == INVALID_HANDLE)
set_fail_state("Error opening vault!")

#if PRUNE_DAYS > 0
nvault_prune(g_iVault, 0, get_systime() - (PRUNE_DAYS * SECONDS_IN_DAY))
#endif
}

public plugin_natives() {
register_native("sol_get_user_time", "_sol_get_user_time")
}

public _sol_get_user_time(/*iPluginID, iParamCount*/) {
new id = get_param(1)
if(!CheckBit(g_iCheckPlayers, id)) {
if(!CheckBit(g_iAuthPlayers, id))
return INVALID_HANDLE;

SetOneBit(g_iCheckPlayers, id);

new szAuthID[AUTHID_STRLEN]
get_user_authid(id, szAuthID, chx(szAuthID))
g_iTime[id] = nvault_get(g_iVault, szAuthID)
}

return g_iTime[id] + get_user_time(id, 1)
}

public client_authorized(id) {
SetOneBit(g_iAuthPlayers, id);
}

public client_putinserver(id) {
SetOneBit(g_iConnPlayers, id);
}

#if AMXX_VERSION_NUM < 183
public client_disconnect(id)
#else
public client_disconnected(id)
#endif
{
if(CheckBit(g_iConnPlayers, id) && CheckBit(g_iAuthPlayers, id)) {
new szAuthID[AUTHID_STRLEN]
get_user_authid(id, szAuthID, chx(szAuthID))
if(szAuthID[0] == 'S' || szAuthID[0] == 'V') {
new iTime = !CheckBit(g_iCheckPlayers, id) ? nvault_get(g_iVault, szAuthID) : g_iTime[id];
iTime += get_user_time(id, 1)
new szTime[14]
num_to_str(iTime, szTime, chx(szTime))
nvault_set(g_iVault, szAuthID, szTime)
}
g_iTime[id] = 0
}
ClearBit(g_iConnPlayers, id);
ClearBit(g_iAuthPlayers, id);
ClearBit(g_iCheckPlayers, id);
}

public plugin_end() {
nvault_close(g_iVault)
}
how to reset logs? (nvault) with cmd (or cvar if is there: ) of Simple Online Logger by mx?! don`t advice for delete it from ftp :) something like csstats_reset 1

как стереть логи? (nvault) от Simple Online Logger by mx?! ... прошу не советовать FTP :) типа этого csstats_reset 1
 
Последнее редактирование:

Shadowless

Пользователь
Регистрация
24 Фев 2019
Сообщения
237
Симпатии
4
Пол
Мужской
i found this but amx_sol_reset does not work :(

C++:
#include <amxmodx>
#include <nvault>
#include <nvault_util>

const MAXSIZE = 33 // MaxPlayers + 1

#define PRUNE_DAYS 30 // Меньше 1, - отключить (не рекомендуется)

#define VAULT_NAME "sol_online"

#define CheckBit(%0,%1) (%0 & (1 << %1))
#define SetOneBit(%0,%1) (%0 |= (1 << %1))
#define ClearBit(%0,%1) (%0 &= ~(1 << %1))
#define chx charsmax

stock const SECONDS_IN_DAY = 86400 // Количество секунд в одном дне [time.inc -> SECONDS_IN_DAY]
const AUTHID_STRLEN = 24

new g_iTime[MAXSIZE], g_iVault, g_iConnPlayers, g_iAuthPlayers, g_iCheckPlayers

new const sol_online_vault[] = "addons/amxmodx/data/vault/sol_online.vault"
new const sol_online_journal[] = "addons/amxmodx/data/vault/sol_online.journal"

public plugin_init() {
    register_plugin("Simple Online Logger", "10.04.18", "mx?!")
    register_clcmd("amx_sol_reset", "sol_reset")
    register_concmd("amx_sol_reset", "sol_reset", ADMIN_CVAR, "<sol_reset>" )
    register_srvcmd("amx_sol_reset","sol_reset")
   
    if((g_iVault = nvault_open(VAULT_NAME)) == INVALID_HANDLE)
        set_fail_state("Error opening vault!")

#if PRUNE_DAYS > 0
    nvault_prune(g_iVault, 0, get_systime() - (PRUNE_DAYS * SECONDS_IN_DAY))
#endif
}

public plugin_natives() {
    register_native("sol_get_user_time", "_sol_get_user_time")
}


public sol_reset(id) {
    if (!(get_user_flags(id) & ADMIN_CVAR)) {
        client_print(id,print_console,"[AMXX] You have no access to that command")
        return PLUGIN_HANDLED
    }

    set_task(1.0,"sol_clear")
    set_task(30.0,"sol_delete")
    /* set_task(60.0,"sol_creat") */
    client_print(id,print_console,"[AMXX] SOL Reseted")
    nvault_prune( g_iVault , 0 , get_systime() )
    return PLUGIN_CONTINUE
}

public sol_clear( g_iVault , const szVault[] ) {
    nvault_prune( g_iVault , 0 , get_systime() );
    new iUtilVault;
    if ( ( iUtilVault = nvault_util_open( szVault ) ) ) {
        new iCount , iPos , szKey[ 256 ] , szVal[ 2 ] , iTS;
        if ( ( iCount = nvault_util_count( iUtilVault ) ) ) {
            for ( new i = 0 ; i < iCount ; i++ )
            {
                iPos = nvault_util_read( iUtilVault , iPos , szKey , charsmax( szKey ) , szVal , charsmax( szVal ) , iTS );
                nvault_remove( g_iVault , szKey );
            }
        }
        nvault_util_close( iUtilVault );
    }
}

public sol_delete() {
    new sol_online_vault[128]
    formatex(sol_online_vault, charsmax(sol_online_vault), "addons/amxmodx/data/vault/sol_online.vault")
   
    if(file_exists(sol_online_vault))  
        delete_file(sol_online_vault)
   
    new sol_online_journal[128]
    formatex(sol_online_journal, charsmax(sol_online_journal), "addons/amxmodx/data/vault/sol_online.journal")
   
    if(file_exists(sol_online_journal))  
        delete_file(sol_online_journal)  
}

public sol_creat() {
    if(!file_exists(sol_online_vault)) {
        write_file(sol_online_vault, "")
    }
    if(!file_exists(sol_online_journal)) {
        write_file(sol_online_journal, "")
    }
}

public _sol_get_user_time(/*iPluginID, iParamCount*/) {
    new id = get_param(1)
    if(!CheckBit(g_iCheckPlayers, id)) {
        if(!CheckBit(g_iAuthPlayers, id))
            return INVALID_HANDLE;
           
        SetOneBit(g_iCheckPlayers, id);
       
        new szAuthID[AUTHID_STRLEN]
        get_user_authid(id, szAuthID, chx(szAuthID))
        g_iTime[id] = nvault_get(g_iVault, szAuthID)
    }
   
    return g_iTime[id] + get_user_time(id, 1)
}

public client_authorized(id) {
    SetOneBit(g_iAuthPlayers, id);
}

public client_putinserver(id) {
    SetOneBit(g_iConnPlayers, id);
}

public client_disconnected(id) {
    if(CheckBit(g_iConnPlayers, id) && CheckBit(g_iAuthPlayers, id)) {
        new szAuthID[AUTHID_STRLEN]
        get_user_authid(id, szAuthID, chx(szAuthID))
        if(szAuthID[0] == 'S' || szAuthID[0] == 'V') {
            new iTime = !CheckBit(g_iCheckPlayers, id) ? nvault_get(g_iVault, szAuthID) : g_iTime[id];
            iTime += get_user_time(id, 1)
            new szTime[14]
            num_to_str(iTime, szTime, chx(szTime))
            nvault_set(g_iVault, szAuthID, szTime)
        }
        g_iTime[id] = 0
    }
    ClearBit(g_iConnPlayers, id);
    ClearBit(g_iAuthPlayers, id);
    ClearBit(g_iCheckPlayers, id);
}
   
public plugin_end() {
    nvault_close(g_iVault)
}
 
Сверху Снизу