Raised This Month: $ Target: $400
 0% 

logevent hook


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-14-2012 , 00:16   Re: logevent hook
Reply With Quote #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 
iArgsNumnmszTemp[64]

    
read_logdata(szMaincharsmax(szMain))

    
iArgsNum read_logargc()

    
0
    m 
formatex(szRegisteredcharsmax(szRegistered), "register_logevent(^"logevent_function^", %d"iArgsNum)

    for(new 
ii<iArgsNumi++)
    {
        
read_logargv(iszTempcharsmax(szTemp))
        if( !
&& contain(szTemp"<STEAM_") != -)
        {
            
+= formatex(szDetail[n], charsmax(szDetail)-n"^n%d=%s"iszTemp)
            if( 
replace(szRegisteredcharsmax(szRegistered), "logevent_function^"", "logevent_function_p^"") )
            {
                
+= 2
            
}
            
// replace(szRegistered, charsmax(szRegistered), "logevent_function(", "logevent_function_p(")
            // m = strlen(szRegistered)
        
}
        else
        {
            
+= formatex(szDetail[n], charsmax(szDetail)-n"^n%d=%s"iszTemp)
            
+= formatex(szRegistered[m], charsmax(szRegistered)-m", ^"%d=%s^""iszTemp)
        }
    }
    
+= formatex(szRegistered[m], charsmax(szRegistered)-m")^n")

    if(
g_iState==2)
    {
        static 
szLogFile[64], date[22]
        if( !
szLogFile[0] )
        {
            
get_localinfo("amxx_logs"szLogFilecharsmax(szLogFile))
            
get_time("%Y%m%d"datecharsmax(date))
            
format(szLogFilecharsmax(szLogFile), "%s/logevents_%s.log"szLogFiledate)
        }
        
get_time("%m/%d/%Y - %H:%M:%S"datecharsmax(date))
        new 
fp fopen(szLogFile"at")
        
fprintf(fp"L %s: %s%s^n%s^n^n"dateszMainszDetailszRegistered)
        
fclose(fp)
    }
    else
    {
        
server_print("^n%s%s^n%s"szMainszDetailszRegistered)
    }
}

public 
ServerCommand_LogEvents()
{
    new 
szArg1[6]
    
read_argv(1szArg1charsmax(szArg1))

    static const 
szStates[][] = {"stop""print""log"}

    for(new 
ii<sizeof(szStates); i++)
    {
        if( 
equal(szArg1szStates[i]) && g_iState != )
        {
            
g_iState i
            
break
        }
    }

    if( 
g_iState )
    {
        
state Running
    
}
    else
    {
        
state Stopped
    
}
    
server_print("[LogEvents Logger] Currently : %s"szStates[g_iState])

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 06-14-2012 at 00:44.
ConnorMcLeod is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:17.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode