Raised This Month: $51 Target: $400
 12% 

Change Console Prefix


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
godzcsgo
Senior Member
Join Date: Jul 2017
Old 12-28-2018 , 07:27   Change Console Prefix
Reply With Quote #1

Whenever you type in rcon, the say command prefix is usualy Console: is there any way to change this?
godzcsgo is offline
potatoz
AlliedModders Donor
Join Date: Nov 2016
Old 12-28-2018 , 07:56   Re: Change Console Prefix
Reply With Quote #2

There's probably a more effective way i can't think of atm, but you could rewrite this plugin to make edits to any usermessage: https://forums.alliedmods.net/showthread.php?p=1729023
__________________
potatoz is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-28-2018 , 10:10   Re: Change Console Prefix
Reply With Quote #3

Not sure is this perfect.
I mean, does other plugin(s) get conflict together.

*edit
Dam, this is now only protobuf version. Works in CSGO tough.
- Need add bitbuffer

*edit edit
Updated both, protobuf and bitbuffer

PHP Code:



/*
Name:     SayText
Structure:     
int32     ent_idx     
string     text     
bool     chat     
bool     textallchat 
*/

DataPack pack;

public 
void OnPluginStart()
{
    
pack = new DataPack();

    
HookUserMessage(GetUserMessageId("SayText"), hook_messagetruehook_message_post);
}

public 
Action hook_message(UserMsg msg_idProtobuf msg, const int[] playersint playersNumbool reliablebool init)
{
    if(!
reliable) return Plugin_Continue;

    
char buffer[254];

    if(
GetUserMessageType() == UM_Protobuf)
    {
        if(
msg.ReadInt("ent_idx") != || !msg.ReadBool("chat") || !msg.ReadBool("textallchat")) return Plugin_Continue;

        
msg.ReadString("text"buffersizeof(buffer));
    }
    else
    {
        
BfRead bfreadmsg view_as<BfRead>(msg);

        if(
bfreadmsg.ReadByte() != 0) return Plugin_Continue// ent_index ?

        
bfreadmsg.ReadStringbuffersizeof(buffer), false); // string

        // Not sure what are last to bits, bool, char, int ?? What those mean ?
        //bfreadmsg.ReadBool();
        //bfreadmsg.ReadBool());

    
}

    if(
StrContains(buffer"Console: "false) != 0) return Plugin_Continue;


    
pack.Reset(true);

    
pack.WriteString(buffer);
    
pack.WriteCell(playersNum);

    for(
int i 0playersNumi++) pack.WriteCell(players[i]);

    return 
Plugin_Stop;
}

public 
void hook_message_post(UserMsg msg_idbool sent)
{
    if(
sent) return;

    
char buffer[254];

    
pack.Reset(false);
    
pack.ReadString(buffersizeof(buffer));

    if(
GetUserMessageType() == UM_Protobuf)
    {
        
Format(buffersizeof(buffer), " \x04[SM] \x01%s"buffer[9]) //  g_sOutput[9] will replace 'Console :' part.
    
}
    else
    {
        
Format(buffersizeof(buffer), "\x04[SM] \x01%s"buffer[9]) //  g_sOutput[9] will replace 'Console :' part.
    
}

    
//PrintToChatAll("%s", buffer);

    
int playersNum pack.ReadCell();

    for(
int i 0playersNumi++) PrintToChat(pack.ReadCell(), buffer);


__________________
Do not Private Message @me

Last edited by Bacardi; 12-28-2018 at 23:30. Reason: update code; datapack
Bacardi is offline
godzcsgo
Senior Member
Join Date: Jul 2017
Old 12-28-2018 , 13:52   Re: Change Console Prefix
Reply With Quote #4

Quote:
Originally Posted by Bacardi View Post
Not sure is this perfect.
I mean, does other plugin(s) get conflict together.

*edit
Dam, this is now only protobuf version. Works in CSGO tough.
- Need add bitbuffer

*edit edit
Updated both, protobuf and bitbuffer

PHP Code:


/*
Name:     SayText
Structure:     
int32     ent_idx     
string     text     
bool     chat     
bool     textallchat 
*/

char g_sOutput[254];

public 
void OnPluginStart()
{
    
HookUserMessage(GetUserMessageId("SayText"), hook_messagetruehook_message_post);
}

public 
Action hook_message(UserMsg msg_idProtobuf msg, const int[] playersint playersNumbool reliablebool init)
{
    if(!
reliable) return Plugin_Continue;

    if(
GetUserMessageType() == UM_Protobuf)
    {
        if(
msg.ReadInt("ent_idx") != || !msg.ReadBool("chat") || !msg.ReadBool("textallchat")) return Plugin_Continue;

        
msg.ReadString("text"g_sOutputsizeof(g_sOutput));
    }
    else
    {
        
BfRead bfreadmsg view_as<BfRead>(msg);

        if(
bfreadmsg.ReadByte() != 0) return Plugin_Continue// ent_index ?

        
bfreadmsg.ReadStringg_sOutputsizeof(g_sOutput), false); // string

        // Not sure what are last to bits, bool, char, int ?? What those mean ?
        //bfreadmsg.ReadBool();
        //bfreadmsg.ReadBool());

    
}

    if(
StrContains(g_sOutput"Console: "false) != 0) return Plugin_Continue;


    return 
Plugin_Stop;
}

public 
void hook_message_post(UserMsg msg_idbool sent)
{
    if(
sent) return;

    if(
GetUserMessageType() == UM_Protobuf)
    {
        
Format(g_sOutputsizeof(g_sOutput), " \x04[SM] \x01%s"g_sOutput[9]) //  g_sOutput[9] will replace 'Console :' part.
    
}
    else
    {
        
Format(g_sOutputsizeof(g_sOutput), "\x04[SM] \x01%s"g_sOutput[9]) //  g_sOutput[9] will replace 'Console :' part.
    
}
    
PrintToChatAll("%s"g_sOutput);
    
g_sOutput[0] = '\0';

Where is the myPluginInfo
and the includes?
godzcsgo is offline
godzcsgo
Senior Member
Join Date: Jul 2017
Old 12-28-2018 , 14:04   Re: Change Console Prefix
Reply With Quote #5

Quote:
Originally Posted by Bacardi View Post
Not sure is this perfect.
I mean, does other plugin(s) get conflict together.

*edit
Dam, this is now only protobuf version. Works in CSGO tough.
- Need add bitbuffer

*edit edit
Updated both, protobuf and bitbuffer

PHP Code:


/*
Name:     SayText
Structure:     
int32     ent_idx     
string     text     
bool     chat     
bool     textallchat 
*/

char g_sOutput[254];

public 
void OnPluginStart()
{
    
HookUserMessage(GetUserMessageId("SayText"), hook_messagetruehook_message_post);
}

public 
Action hook_message(UserMsg msg_idProtobuf msg, const int[] playersint playersNumbool reliablebool init)
{
    if(!
reliable) return Plugin_Continue;

    if(
GetUserMessageType() == UM_Protobuf)
    {
        if(
msg.ReadInt("ent_idx") != || !msg.ReadBool("chat") || !msg.ReadBool("textallchat")) return Plugin_Continue;

        
msg.ReadString("text"g_sOutputsizeof(g_sOutput));
    }
    else
    {
        
BfRead bfreadmsg view_as<BfRead>(msg);

        if(
bfreadmsg.ReadByte() != 0) return Plugin_Continue// ent_index ?

        
bfreadmsg.ReadStringg_sOutputsizeof(g_sOutput), false); // string

        // Not sure what are last to bits, bool, char, int ?? What those mean ?
        //bfreadmsg.ReadBool();
        //bfreadmsg.ReadBool());

    
}

    if(
StrContains(g_sOutput"Console: "false) != 0) return Plugin_Continue;


    return 
Plugin_Stop;
}

public 
void hook_message_post(UserMsg msg_idbool sent)
{
    if(
sent) return;

    if(
GetUserMessageType() == UM_Protobuf)
    {
        
Format(g_sOutputsizeof(g_sOutput), " \x04[SM] \x01%s"g_sOutput[9]) //  g_sOutput[9] will replace 'Console :' part.
    
}
    else
    {
        
Format(g_sOutputsizeof(g_sOutput), "\x04[SM] \x01%s"g_sOutput[9]) //  g_sOutput[9] will replace 'Console :' part.
    
}
    
PrintToChatAll("%s"g_sOutput);
    
g_sOutput[0] = '\0';

When i do rcon say test it spams it about 8 times, i want it 1 time not 8 times.
godzcsgo is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-28-2018 , 14:06   Re: Change Console Prefix
Reply With Quote #6

Because you not need them ? :/

*edit
ok, show your plugins list


sm plugins list


*edit edit
Maybe UserMessage(SayText) is send to each client... that's why it spam. Need fix it later.

Last edited by Bacardi; 12-28-2018 at 14:08.
Bacardi is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-28-2018 , 23:34   Re: Change Console Prefix
Reply With Quote #7

Updated post
https://forums.alliedmods.net/showpo...35&postcount=3

Now it use DataPack, to store UserMessage string and player(s), then print in chat for each player.
Bacardi 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 16:32.


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