AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Server log - connected message rewrite (https://forums.alliedmods.net/showthread.php?t=154563)

portocala 04-10-2011 09:30

Server log - connected message rewrite
 
Hello,

How can I rewrite the following message in the server logs ?
Code:

Player<4><STEAM_0:0:12345><>" connected, address "127.0.0.1:27005"
I tried with plugin_log() and FM_AlertMessage, but this kind of message isn't returned.

Thank you!

ConnorMcLeod 04-10-2011 10:25

Re: Server log - connected message rewrite
 
You can't, you have to remake them.

Arkshine 04-10-2011 10:28

Re: Server log - connected message rewrite
 
You probably can using Orpheu.

But you want to do what exactly ?

portocala 04-10-2011 10:47

Re: Server log - connected message rewrite
 
I want to change the whole message by blocking the old one and rewrite (with log_message() maybe) a new one.

Ex:
"Playe1r<4><STEAM_0:0:123><>" connected, address "127.0.0.1:27005"
to
Player2<4><STEAM_0:0:456><>" connected, address "127.0.0.1:27005"

The way can be different, I just want to edit that message.

Thank you for replies!

Arkshine 04-10-2011 10:51

Re: Server log - connected message rewrite
 
Well you could try to hook SV_ConnectClient(), then hooking Log_Printf(), checking it's your string, sending a new one, and superceding the original call.

portocala 04-10-2011 11:09

Re: Server log - connected message rewrite
 
Code:

#include <amxmodx>
#include <orpheu>

public plugin_init()
{
    OrpheuRegisterHook(OrpheuGetFunction("Log_Printf"), "OnLog_Printf");
}

public OrpheuHookReturn:OnSLog_Printf()
{
    new args[192]; read_args(args, 191);
    log_amx("NEW: %s", args);
}

Result: [ORPHEU] Function "Log_Printf" not found

Arkshine 04-10-2011 11:33

Re: Server log - connected message rewrite
 
You have created the file Log_Printf, right ? You can't just hook randomly function, you need to provide a file and signature.

portocala 04-10-2011 13:59

Re: Server log - connected message rewrite
 
No, I haven't created it.

The function (Log_Print) returns the log message that I need ? In this case, I don't need SV_ConnectClient(), because I can identify the message by contain(string, "connected, address") != -1

I will try to understand from tutorials how to do that file and signature, even it is strange by now. Thank you!

Arkshine 04-10-2011 14:15

Re: Server log - connected message rewrite
 
I've said to hook SV_ConnectClient() to filter the messages. Log_Print is used probably often, when in this function there is only 2 Log_Print(), including the wanted string. So you would check 2 strings max, which would be more efficient.


All times are GMT -4. The time now is 20:10.

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