Raised This Month: $ Target: $400
 0% 

Simulating UTIL_LogPrintf


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PartialCloning
Senior Member
Join Date: Dec 2015
Old 07-22-2017 , 09:29   Simulating UTIL_LogPrintf
Reply With Quote #1

Is it possible to send or fake a log message for other plugins to hook through register_logevent? Like "emessage" would.

I'm trying to get plugins using register_logevent to hook roundend to think the round has ended during the round.
PartialCloning is offline
Old 07-22-2017, 11:10
HamletEagle
This message has been deleted by HamletEagle.
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-22-2017 , 11:10   Re: Simulating UTIL_LogPrintf
Reply With Quote #3

PHP Code:
#include <amxmodx>
#include <orpheu>
#include <fakemeta>

#pragma ctrlchar '\'

new OrpheuFunction:HandleC_AlertMessage

public plugin_init()
{
    
register_logevent("OnLogEvent_RoundEnd"2"1=Round_End")  
    
register_srvcmd("test""ServerCommand_Test")
    
    
HandleC_AlertMessage OrpheuGetFunction("C_AlertMessage")
}

public 
ServerCommand_Test()
{
    
OrpheuCall(HandleC_AlertMessageat_logged"World triggered \"Round_End\"\n")
}

public 
OnLogEvent_RoundEnd()
{
    
server_print("OnLogEvent_RoundEnd called")

Code:
{
    "name"      : "C_AlertMessage",
    "library"   : "amxmodx_mm",
    "arguments" :
    [
        {
            "type"  : "int"
        },
        {
            "type"  : "char *"
        }
    ],
    "identifiers":
    [
        {
            "os"    : "windows",
            "mod"   : "cstrike",
            "value" : [0x83,"*","*","*","*",0x74,"*",0xA1,"*","*","*","*",0xC7,"*","*","*","*","*",0xC3,0x80]
        },
        {
            "os"    : "linux",
            "mod"   : "cstrike",
            "value" : [0x83,"*","*",0x83,"*","*","*","*",0x74,"*",0xA1]
        }
    ]
}
Reference: https://github.com/alliedmodders/amx..._api.cpp#L1457

Write "test" in the server console, the log event will be called.
__________________

Last edited by HamletEagle; 07-22-2017 at 11:15.
HamletEagle is offline
PartialCloning
Senior Member
Join Date: Dec 2015
Old 07-22-2017 , 11:28   Re: Simulating UTIL_LogPrintf
Reply With Quote #4

Thank you. Is it possible without Orpheu? I don't usually mind using Orpheu but I'd hate to include it for just a small thing.
PartialCloning is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-22-2017 , 11:42   Re: Simulating UTIL_LogPrintf
Reply With Quote #5

I knew you will ask that and you know I'll tell you that including a module is perfectly fine is this module can do the job.
But, to answer your question, I could not find a way without orpheu. UTIL_LogPrintf is using ALERT which is pfnAlertMessage. I tried using EngFunc_AllertMessage and even calling that function with orpheu instead of fakemeta, but it seems like metamod ignores this calls.
I did not check more than that, but at a first glance it looks like it's not possible without manually calling C_AlertMessage.
__________________

Last edited by HamletEagle; 07-22-2017 at 11:43.
HamletEagle is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 07-22-2017 , 12:37   Re: Simulating UTIL_LogPrintf
Reply With Quote #6

We need to add something like eengfunc and edllfunc to fakemeta.
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-22-2017 , 13:07   Re: Simulating UTIL_LogPrintf
Reply With Quote #7

Quote:
Originally Posted by PRoSToTeM@ View Post
We need to add something like eengfunc and edllfunc to fakemeta.
That would be handy for sure.
__________________
HamletEagle is offline
PartialCloning
Senior Member
Join Date: Dec 2015
Old 07-22-2017 , 13:39   Re: Simulating UTIL_LogPrintf
Reply With Quote #8

elog_message sounds like a more realistic addition. I don't see many if any uses for most of the engfuncs and dllfuncs. I also don't think anyone will want to do all the word involved.

elog_message would be pretty useful and it would have a lot of uses.
PartialCloning is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-22-2017 , 15:05   Re: Simulating UTIL_LogPrintf
Reply With Quote #9

elog_message as you call it would be eengfunc(EngFunc_AlertMessage). So if it's done for one, it's done for others.
__________________

Last edited by HamletEagle; 07-23-2017 at 10:28.
HamletEagle is offline
PartialCloning
Senior Member
Join Date: Dec 2015
Old 07-22-2017 , 17:58   Re: Simulating UTIL_LogPrintf
Reply With Quote #10

elog_message like log_message would only send at_logged alerts. register_logevent and plugin_log seem to only care about at_logged alerts.

https://github.com/alliedmodders/amx..._api.cpp#L1457

Correct me if I'm wrong, but wouldn't adding the elog_message native be as simple:

Code:
static cell AMX_NATIVE_CALL elog_message(AMX *amx, cell *params) /* 1 param */ {     int len;     g_langMngr.SetDefLang(LANG_SERVER);     char* message = format_amxstring(amx, params, 1, len);     message[len++] = '\n';     message[len] = 0;     ALERT(at_logged, "%s", message);     /* Call C_AlertMessae with the message and let it do the work? */     C_AlertMessage(at_logged, message);     /******************************************************/     return len; }
PartialCloning is offline
Reply



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 22:46.


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