Admin Commands Log

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
6
Реакции
8
Ошибка
L 01/09/2019 - 02:09:30: String formatted incorrectly - parameter 4 (total 3)
L 01/09/2019 - 02:09:30: [AMXX] Displaying debug trace (plugin "admin_commands_log.amxx", version "1.0")
L 01/09/2019 - 02:09:30: [AMXX] Run time error 25: parameter error
L 01/09/2019 - 02:09:30: [AMXX] [0] admin_commands_log.sma::plugin_init (line 85)
ОС
Linux
Amx Mod X
AMX Mod X 1.9.0.5234 (http://www.amxmodx.org)
Authors:
David "BAILOPAN" Anderson, Pavol "PM OnoTo" Marko
Felix "SniperBeamer" Geyer, Jonny "Got His Gun" Bergstrom
Lukasz "SidLuke" Wlasinski, Christian "Basic-Master" Hammacher
Borja "faluco" Ferrer, Scott "DS" Ehlert
Compiled: Nov 3 2018 14:55:29
Built from: https://github.com/alliedmodders/amxmodx/commit/9eb1f42
Build ID: 5234:9eb1f42
Core mode: JIT+ASM32
Билд
Protocol version 48
Exe version 1.1.2.7/Stdio (cstrike)
ReHLDS version: 3.4.0.668-dev
Build date: 09:47:42 Sep 29 2018 (1631)
Build from: https://github.com/dreamstalker/rehlds/commit/89be216
ReGamedll
ReGameDLL version: 5.7.0.318-dev
Build date: 21:07:26 Oct 30 2018
Build from: https://github.com/s1lentq/ReGameDLL_CS/commit/932001b
Версия Metamod
Metamod-r v1.3.0.128, API (5:13)
Metamod-r build: 17:47:54 Aug 24 2018
Metamod-r from: https://github.com/theAsmodai/metamod-r/commit/0cf2f70
Список метамодулей
Currently loaded plugins:
description stat pend file vers src load unload
[ 1] Reunion RUN - reunion_mm_i386.so v0.1.0.92 ini Start Never
[ 2] ReAuthCheck RUN - reauthcheck_mm_i386.so v0.1.6 ini Start Never
[ 3] Rechecker RUN - rechecker_mm_i386.so v2.5 ini Chlvl ANY
[ 4] VoiceTranscoder RUN - VoiceTranscoder.so v2017RC3 ini ANY ANY
[ 5] AMX Mod X RUN - amxmodx_mm_i386.so v1.9.0.5234 ini Start ANY
[ 6] WHBlocker RUN - whblocker_mm_i386.so v1.5.692 ini Chlvl ANY
[ 7] ReSemiclip RUN - resemiclip_mm_i386.so v2.3.9 ini Chlvl ANY
[ 8] ReSRDetector RUN - resrdetector_mm_i386.so v0.1.0 ini Chlvl ANY
[ 9] MySQL RUN - mysql_amxx_i386.so v1.9.0.5234 pl5 ANY ANY
[10] FakeMeta RUN - fakemeta_amxx_i386.so v1.9.0.5234 pl5 ANY ANY
[11] CStrike RUN - cstrike_amxx_i386.so v1.9.0.5234 pl5 ANY ANY
[12] Ham Sandwich RUN - hamsandwich_amxx_i386.so v1.9.0.5234 pl5 ANY ANY
[13] ReAimDetector RUN - reaimdetector_amxx_i386.so v0.2.2 pl5 ANY Never
[14] Engine RUN - engine_amxx_i386.so v1.9.0.5234 pl5 ANY ANY
[15] ReAPI RUN - reapi_amxx_i386.so v5.7.0.162-dev pl5 ANY Never
15 plugins, 15 running
Список плагинов
Currently loaded plugins:
name version author file status
[ 1] fb_forwards 0.1.5 Kanagava & Realu fb_forwards.amx running
[ 2] WebHS 0.1 kanagava fb_web_online.a running
[ 3] FreshBans 1.4.0b kanagava fresh_bans_140_ running
[ 4] DopBan 3.0.3b kanagava dop_ban_new.amx running
[ 5] admin_loader 0.3.7 kanagava admin_loader_fo running
[ 6] ReAimDetector API 0.2.2 ReHLDS Team reaimdetector.a running
[ 7] Lite Admin ESP 1.1 neygomon, AcE admin_esp_new.a running
[ 8] Admin Commands 1.9.0.5234 AMXX Dev Team admincmd.amxx running
[ 9] Admin Help 1.9.0.5234 AMXX Dev Team adminhelp.amxx running
[ 10] Ultimate Chats Control 4.7 neygomon ucc.amxx debug
[ 11] Slots Reservation 1.9.0.5234 AMXX Dev Team adminslots.amxx running
[ 12] Multi-Lingual System 1.9.0.5234 AMXX Dev Team multilingual.am running
[ 13] CSStatsX SQL 0.7.4 serfreeman1337 csstatsx_sql.am running
[ 14] amx_kickmenu reasons a 0.3a Beta Flash kickmenu_reason running
[ 15] Nick Change Menu 0.1.1 serfreeman1337 nickchange_menu running
[ 16] Menus Front-End 1.5 neugomon menufront_end.a running
[ 17] Commands Menu 1.9.0.5234 AMXX Dev Team cmdmenu.amxx running
[ 18] Players Menu 1.9.0.5234 AMXX Dev Team plmenu.amxx running
[ 19] Plugin Menu 1.9.0.5234 AMXX Dev Team pluginmenu.amxx running
[ 20] Nextmap Chooser 1.9.0.5234 AMXX Dev Team mapchooser.amxx running
[ 21] NextMap 1.9.0.5234 AMXX Dev Team nextmap.amxx running
[ 22] Admin Chat 1.9.0.5234 AMXX Dev Team adminchat.amxx running
[ 23] Anti Flood 1.9.0.5234 AMXX Dev Team antiflood.amxx running
[ 24] Scrolling Message 1.9.0.5234 AMXX Dev Team scrollmsg.amxx running
[ 25] Info. Messages 1.9.0.5234 AMXX Dev Team imessage.amxx running
[ 26] Admin Votes 1.9.0.5234 AMXX Dev Team adminvote.amxx running
[ 27] Pause Plugins 1.9.0.5234 AMXX Dev Team pausecfg.amxx running
[ 28] Stats Configuration 1.9.0.5234 AMXX Dev Team statscfg.amxx running
[ 29] Restrict Weapons 1.9.0.5234 AMXX Dev Team restmenu.amxx running
[ 30] StatsX 1.9.0.5234 AMXX Dev Team statsx.amxx running
[ 31] [ReAPI] AdminFreeLook 1.0 ReHLDS Team adminfreelook.a running
[ 32] DemoRecoder 1.1 neygomon amx_demorec.amx running
[ 33] [ReAPI] Random Weapons 2.4.9 neugomon/h1k3 random_weapons_ running
[ 34] [ReAPI] IDEAL VIP by W 1.4.5 Wikiname (Remake reapi_ideal_vip debug
[ 35] Custom Knife Model 0.1 Safety1st custom_knife.am running
[ 36] Fraglimit Advanced 1.1 Sho0ter fraglimit.amxx running
[ 37] Afk Control 0.5.1 neygomon afk_control.amx running
[ 38] Ping Checker 26.0.1 RC1 h1k3 ping_checker.am running
[ 39] Lite VoteBan 1.4 neygomon lite_voteban.am running
[ 40] resetscore(ReAPI) 1.0 Phantom resetscore.amxx running
[ 41] Web Chat 1.3.11 BaHeK webchat.amxx running
[ 42] Lite Translit 2.8 neygomon lite_translit.a running
[ 43] Night VIP 0.1 F@nt0M night_vip.amxx running
[ 44] Map Spawns Editor 1.0.16 iG_os map_spawns_edit running
[ 45] WalkGuard 1.3.2 mogel walkguard.amxx running
[ 46] Admin Commands Log 1.0 w0w admin_commands_ debug
46 plugins, 46 running
Автор плагина
w0w
Версия плагина
1.0
Исходный код
/*
* Author contact: http://t.me/twisternick or:
* - Official topic of the resource in Russian forum: https://dev-cs.ru/threads/3944/
* - Official topic of the resource in English forum: https://forums.alliedmods.net/showthread.php?p=2626738#post2626738
* - Official topic of the resource in Spanish forum: https://amxmodx-es.com/Thread-Admin-Commands-Log-v1-0
*
* Idea: DrStrange. Topic: https://dev-cs.ru/threads/3792/
*
* Credits to:
* - mx?!
* - wopox1337
* - F@nt0m (reloadcfg/readcfg methods)
*
* Changelog:
* - 1.0:
* - Removed AMX Mod X 1.8.2/1.8.3 support.
* - Defines are replaced by CVars.
* - Added automatic creation and execution of a configuration file with CVars: "amxmodx/configs/plugins/admin_commands_log.cfg".
* - CVars' description are in "data/lang/admin_commands.log.txt" (multilang added).
* - Thanks to F@nt0m:
* - g_szCmds array changed to acl_list.ini (you can add commands in "amxmodx/configs/acl_list.ini").
* - Added "acl_reloadcfg" command.
* - 0.3: Fixed 2 errors regarding LOG_FORMAT define (thanks to DrStrange for bug-report).
* - 0.2:
* - Fixed an error with AMX Mod X 1.8.3. I still recommend to upgrade your server to AMX Mod X 1.9. or higher.
* - Added two settings:
* - TYPE_CMDS_LOG (logging commands which starts with "amx_" or only commands from array g_szCmds).
* - LOG_FORMAT (0 - log to a file; 1 - log to a file created every day in folder g_szLogFileFolder; 2 - log to a file created every month in folder g_szLogFileFolder).
* - 0.1: Release.
*/

#include <amxmodx>

#pragma semicolon 1

#define PLUGIN_VERSION "1.0"

/****************************************************************************************
****************************************************************************************/

// Filename for cfg file where you can add commands (CVar acl_type = )
new const g_szCfgFileName[] = "acl_list.ini";

new g_szLogFile[PLATFORM_MAX_PATH];
new g_iCvarType, g_szCvarAccess[32];
// acl_type = 2 || acl_type = 3
new g_szCommands[256][64], g_iCommandsNum;

public plugin_init()
{
register_plugin("Admin Commands Log", PLUGIN_VERSION, "w0w");
register_dictionary("admin_commands_log.txt");

new pCvarType, pCvarAccess, pCvarLogType, pCvarReloadCfg;
new iCvarLogType, szCvarReloadCfg[32];
// 0 - logging all commands which starts with "amx_"; 1 - logging all commands from the cfg file; 2 - values 0 and 1 of this CVar are combined
pCvarType = create_cvar("acl_type", "0", FCVAR_NONE, fmt("%l", "ACL_CVAR_TYPE"), true, 0.0, true, 2.0);

// Logging will only for for players who has one of the specified flags
pCvarAccess = create_cvar("acl_access", "cdhlm", FCVAR_NONE, fmt("%l", "ACL_CVAR_ACCESS"));
bind_pcvar_string(pCvarAccess, g_szCvarAccess, charsmax(g_szCvarAccess));

// 0 - log all commands to a file; 1 - log all commands to a different file created every day; 2 - log all commands to a different file created every month
pCvarLogType = create_cvar("acl_log_type", "0", FCVAR_NONE, fmt("%l", "ACL_CVAR_LOG_TYPE"), true, 0.0, true, 2.0);
// Flag to use the command acl_reloadcfg
pCvarReloadCfg = create_cvar("acl_reloadcfg_access", "h", FCVAR_NONE, fmt("%l", "ACL_CVAR_RELOADCFG_ACCESS"));

AutoExecConfig(true, "admin_commands_log");

// After execution of the config, not before.
g_iCvarType = get_pcvar_num(pCvarType);
iCvarLogType = get_pcvar_num(pCvarLogType);
get_pcvar_string(pCvarReloadCfg, szCvarReloadCfg, charsmax(szCvarReloadCfg));

register_concmd("acl_reloadcfg", "func_ConCmdReloadCfg", read_flags(szCvarReloadCfg));

new szLogsDir[PLATFORM_MAX_PATH];
get_localinfo("amxx_logs", szLogsDir, charsmax(szLogsDir));

new szLogFileName[128];

switch(iCvarLogType)
{
case 0: formatex(szLogFileName, charsmax(szLogFileName), "admin_commands");
case 1: formatex(szLogFileName, charsmax(szLogFileName), "admin_commands_%d-%m-%Y");
case 2: formatex(szLogFileName, charsmax(szLogFileName), "admin_commands_%m-%Y");
}

if(iCvarLogType != 0)
{
new szBigBuff[PLATFORM_MAX_PATH];

formatex(szBigBuff, charsmax(szBigBuff), "%s/admin_commands", szLogsDir);
if(!dir_exists(szBigBuff))
mkdir(szBigBuff);

get_time(fmt("%s/%s", szBigBuff, szLogFileName), g_szLogFile, charsmax(g_szLogFile));
}
else formatex(g_szLogFile, charsmax(g_szLogFile), "%s.log", szLogFileName);

func_ReadCfgFile();
}

public OnConfigsExecuted()
{
if(g_iCvarType != 0 && !func_ReadCfgFile())
set_fail_state("[ACL]: Error load cfg ^"%s^"", g_szCfgFileName);
}

public client_command(id)
{
if(!(get_user_flags(id) & read_flags(g_szCvarAccess)))
return PLUGIN_CONTINUE;

enum { command = 0 };

new szCommand[64]; read_argv(command, szCommand, charsmax(szCommand));

switch(g_iCvarType)
{
case 0:
{
if(containi(szCommand, "amx_") == -1 || !szCommand[4])
return PLUGIN_CONTINUE;
}
case 1:
{
if(!func_CommandInList(szCommand))
return PLUGIN_CONTINUE;
}
case 2:
{
if(!func_CommandInList(szCommand) && containi(szCommand, "amx_") == -1)
return PLUGIN_CONTINUE;
}
}

new szArgs[64]; read_args(szArgs, charsmax(szArgs));

if(szArgs[0])
func_LogToFile(id, szCommand, szArgs);
else func_LogToFile(id, szCommand);

return PLUGIN_CONTINUE;
}

func_LogToFile(id, szCommand[], szArgs[] = "")
{
new szAuthID[MAX_AUTHID_LENGTH], szIP[MAX_IP_LENGTH];
get_user_authid(id, szAuthID, charsmax(szAuthID));
get_user_ip(id, szIP, charsmax(szIP), 1);

if(szArgs[0])
log_to_file(g_szLogFile, "%n (<%s> <%s>) ---> %s %s", id, szAuthID, szIP, szCommand, szArgs);
else log_to_file(g_szLogFile, "%n (<%s> <%s>) ---> %s", id, szAuthID, szIP, szCommand);
}

// F@nt0m's code ( https://dev-cs.ru/threads/2672/#post-30421 )
public func_ConCmdReloadCfg(id, lvl, cid)
{
if(~get_user_flags(id) & lvl)
console_print(id, "[ACL]: You have not access to this command");
else if(!func_ReadCfgFile())
console_print(id, "[ACL]: Error load cfg ^"%s^"", g_szCfgFileName);
else console_print(id, "[ACL]: Reload cfg ^"%s^"", g_szCfgFileName);
return PLUGIN_HANDLED;
}

bool:func_ReadCfgFile()
{
new szConfigsDir[PLATFORM_MAX_PATH], szFilePath[PLATFORM_MAX_PATH];
get_localinfo("amxx_configsdir", szConfigsDir, charsmax(szConfigsDir));
formatex(szFilePath, charsmax(szFilePath), "%s/%s", szConfigsDir, g_szCfgFileName);

new iFileHandle = fopen(szFilePath, "rt");
if(!iFileHandle)
return false;

g_iCommandsNum = 0;

new szString[256];
while(!feof(iFileHandle))
{
fgets(iFileHandle, szString, charsmax(szString));
trim(szString);
if(szString[0] == EOS || szString[0] == ';')
continue;

remove_quotes(szString);

copy(g_szCommands[g_iCommandsNum], sizeof g_szCommands[], szString);
g_iCommandsNum++;

if(g_iCommandsNum >= sizeof g_szCommands)
break;
}

fclose(iFileHandle);
return true;
}

bool:func_CommandInList(const szCommand[])
{
for(new i; i < g_iCommandsNum; i++)
{
if(equal(g_szCommands[i], szCommand))
return true;
}
return false;
}
логов не создавалось. ошибка в debug.
плагин без изменений. где вообще логи должны создаваться?
в plugins.ini плагин в конце
 
В этой теме было размещено решение! Перейти к решению.
Сообщения
2,491
Реакции
2,790
Помог
61 раз(а)
bloodknife, fix
Код:
switch(iCvarLogType)
{
-     case 0: formatex(szLogFileName, charsmax(szLogFileName), "admin_commands");
-     case 1: formatex(szLogFileName, charsmax(szLogFileName), "admin_commands_%d-%m-%Y");
-     case 2: formatex(szLogFileName, charsmax(szLogFileName), "admin_commands_%m-%Y");
+     case 0: copy(szLogFileName, charsmax(szLogFileName), "admin_commands");
+     case 1: copy(szLogFileName, charsmax(szLogFileName), "admin_commands_%d-%m-%Y");
+     case 2: copy(szLogFileName, charsmax(szLogFileName), "admin_commands_%m-%Y");
}
 
Сообщения
6
Реакции
8
fantom, После внесения изменений, заменив 3 строчки на другие, файл создался, ежедневный, но без расширения, просто файл
admin_commands_09-01-2019
Таким быть и должен? или всё-таки в формате .log?
 
Сообщения
1,419
Реакции
2,508
Помог
59 раз(а)
bloodknife,
Код:
-get_time(fmt("%s/%s", szBigBuff, szLogFileName), g_szLogFile, charsmax(g_szLogFile));
+get_time(fmt("%s/%s.log", szBigBuff, szLogFileName), g_szLogFile, charsmax(g_szLogFile));
И ещё лучше так:
Код:
-new szLogFileName[128];
+new szLogFileName[PLATFORM_MAX_PATH];
 
Сообщения
2,491
Реакции
2,790
Помог
61 раз(а)
bloodknife, замените
Код:
new szLogsDir[PLATFORM_MAX_PATH];
    get_localinfo("amxx_logs", szLogsDir, charsmax(szLogsDir));

    new szLogFileName[128];

    switch(iCvarLogType)
    {
        case 0: formatex(szLogFileName, charsmax(szLogFileName), "admin_commands");
        case 1: formatex(szLogFileName, charsmax(szLogFileName), "admin_commands_%d-%m-%Y");
        case 2: formatex(szLogFileName, charsmax(szLogFileName), "admin_commands_%m-%Y");
    }

    if(iCvarLogType != 0)
    {
        new szBigBuff[PLATFORM_MAX_PATH];

        formatex(szBigBuff, charsmax(szBigBuff), "%s/admin_commands", szLogsDir);
        if(!dir_exists(szBigBuff))
            mkdir(szBigBuff);

        get_time(fmt("%s/%s", szBigBuff, szLogFileName), g_szLogFile, charsmax(g_szLogFile));
    }
    else formatex(g_szLogFile, charsmax(g_szLogFile), "%s.log", szLogFileName);
На
Код:
new szLogsDir[PLATFORM_MAX_PATH];
get_localinfo("amxx_logs", szLogsDir, charsmax(szLogsDir));

if(iCvarLogType != 0)
{
    new szBigBuff[PLATFORM_MAX_PATH];

    formatex(szBigBuff, charsmax(szBigBuff), "%s/admin_commands", szLogsDir);
    if(!dir_exists(szBigBuff))
        mkdir(szBigBuff);

    new year, month, day;
    date(year, month, day);
    switch(iCvarLogType)
    {
        case 1: formatex(g_szLogFile, charsmax(g_szLogFile), "%s/admin_commands_%d-%d-%d.log", szLogsDir, day, month, year);
        case 2: formatex(g_szLogFile, charsmax(g_szLogFile), "%s/admin_commands_%d-%d.log", szLogsDir, month, year);
    }
}
else formatex(g_szLogFile, charsmax(g_szLogFile), "%s/admin_commands.log", szLogsDir);
 
Статус
В этой теме нельзя размещать новые ответы.

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу