AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Simulating UTIL_LogPrintf (https://forums.alliedmods.net/showthread.php?t=299663)

PartialCloning 07-22-2017 09:29

Simulating UTIL_LogPrintf
 
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.

HamletEagle 07-22-2017 11:10

Re: Simulating UTIL_LogPrintf
 
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.

PartialCloning 07-22-2017 11:28

Re: Simulating UTIL_LogPrintf
 
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.

HamletEagle 07-22-2017 11:42

Re: Simulating UTIL_LogPrintf
 
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.

PRoSToTeM@ 07-22-2017 12:37

Re: Simulating UTIL_LogPrintf
 
We need to add something like eengfunc and edllfunc to fakemeta.

HamletEagle 07-22-2017 13:07

Re: Simulating UTIL_LogPrintf
 
Quote:

Originally Posted by PRoSToTeM@ (Post 2536957)
We need to add something like eengfunc and edllfunc to fakemeta.

That would be handy for sure.

PartialCloning 07-22-2017 13:39

Re: Simulating UTIL_LogPrintf
 
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.

HamletEagle 07-22-2017 15:05

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

PartialCloning 07-22-2017 17:58

Re: Simulating UTIL_LogPrintf
 
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; }

PRoSToTeM@ 07-22-2017 18:21

Re: Simulating UTIL_LogPrintf
 
@PartialCloning you should use g_pEngTable like in emessage_begin.


All times are GMT -4. The time now is 22:46.

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