|
Veteran Member
Join Date: Jul 2006
Location: France (95)
|

06-14-2012
, 00:16
Re: logevent hook
|
#4
|
You can run this and look in log file if the log you are trying to register does exist, and if it exists if you have correctly formulated it.
You will have to figure which arguments don't have to be specified in filters though, because plugin is an idiot.
PHP Code:
#include <amxmodx>
#define VERSION "1.0.1" new g_iState
public plugin_init() { state Stopped register_plugin("LogEvents Logger", VERSION, "ConnorMcLeod") register_srvcmd("logevents", "ServerCommand_LogEvents", _, "<print> | <log> | <stop>") }
public plugin_log() <Stopped> {} public plugin_log() <Running> { static szMain[256], szDetail[256], szRegistered[256] static iArgsNum, n, m, szTemp[64]
read_logdata(szMain, charsmax(szMain))
iArgsNum = read_logargc()
n = 0 m = formatex(szRegistered, charsmax(szRegistered), "register_logevent(^"logevent_function^", %d", iArgsNum)
for(new i; i<iArgsNum; i++) { read_logargv(i, szTemp, charsmax(szTemp)) if( !i && contain(szTemp, "<STEAM_") != -1 ) { n += formatex(szDetail[n], charsmax(szDetail)-n, "^n%d=%s", i, szTemp) if( replace(szRegistered, charsmax(szRegistered), "logevent_function^"", "logevent_function_p^"") ) { m += 2 } // replace(szRegistered, charsmax(szRegistered), "logevent_function(", "logevent_function_p(") // m = strlen(szRegistered) } else { n += formatex(szDetail[n], charsmax(szDetail)-n, "^n%d=%s", i, szTemp) m += formatex(szRegistered[m], charsmax(szRegistered)-m, ", ^"%d=%s^"", i, szTemp) } } m += formatex(szRegistered[m], charsmax(szRegistered)-m, ")^n")
if(g_iState==2) { static szLogFile[64], date[22] if( !szLogFile[0] ) { get_localinfo("amxx_logs", szLogFile, charsmax(szLogFile)) get_time("%Y%m%d", date, charsmax(date)) format(szLogFile, charsmax(szLogFile), "%s/logevents_%s.log", szLogFile, date) } get_time("%m/%d/%Y - %H:%M:%S", date, charsmax(date)) new fp = fopen(szLogFile, "at") fprintf(fp, "L %s: %s%s^n%s^n^n", date, szMain, szDetail, szRegistered) fclose(fp) } else { server_print("^n%s%s^n%s", szMain, szDetail, szRegistered) } }
public ServerCommand_LogEvents() { new szArg1[6] read_argv(1, szArg1, charsmax(szArg1))
static const szStates[][] = {"stop", "print", "log"}
for(new i; i<sizeof(szStates); i++) { if( equal(szArg1, szStates[i]) && g_iState != i ) { g_iState = i break } }
if( g_iState > 0 ) { state Running } else { state Stopped } server_print("[LogEvents Logger] Currently : %s", szStates[g_iState]) }
__________________
Last edited by ConnorMcLeod; 06-14-2012 at 00:44.
|
|