Raised This Month: $32 Target: $400
 8% 

[CSGO] Set a prefix to a chat message


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
condolent
AlliedModders Donor
Join Date: Jan 2016
Location: gc_sLocation;
Old 12-15-2017 , 08:36   [CSGO] Set a prefix to a chat message
Reply With Quote #1

How can I set a prefix to a normal chat message from a user?

I was first thinking of just using a command listener for "say" and then change it to something like this:
PHP Code:
if(GetClientTeam(client) == CS_TEAM_CT)
    
CPrintToChatAll("{green}[%s] {team2}%N :{default} %s"gangclientmessage);
if(
GetClientTeam(client) == CS_TEAM_T)
    
CPrintToChatAll("{green}[%s] {team1}%N :{default} %s"gangclientmessage); 
But that would collide with other plugins that changes colors and such of messages.

So I was wondering if it was possible to get the final message and append to it, but at the start of the message?
__________________
condolent is offline
cristian20042
AlliedModders Donor
Join Date: Jun 2016
Location: Romania
Old 12-15-2017 , 12:32   Re: [CSGO] Set a prefix to a chat message
Reply With Quote #2

First, you can add
PHP Code:
RegConsoleCmd("say"SayHook); 
or a command listener like this :
PHP Code:
AddCommandListener(SayHook"say"); 
at the beggining of the plugin.
Then do a custom chat message like this :

PHP Code:
public Action:SayHook(client, const String:command[], args)  
{

        new 
String:szText[256];
        
GetCmdArg(1szTextsizeof(szText));
        
        if ( (
GetUserFlagBits client ) & ADMFLAG_RESERVATION )) {
        if(
IsClientInGame(client)) 
        {
            
PrintToChatAll("★ \x05[\x02V\x03I\x04P\x05] \x07%N : \x03%s"clientszText);
            return 
Plugin_Handled;
        }
        }
    
    return 
Plugin_Handled;

And your plugin should look like this :

PHP Code:
#include <sourcemod>

#define PLUGIN_VERSION   "1.0"

public Plugin:myinfo = {
    
name "",
    
author "",
    
description "",
    
version PLUGIN_VERSION,
    
url ""
};

public 
OnPluginStart() 
{
    
AddCommandListener(SayHook"say");   
}

public 
Action:SayHook(client, const String:command[], args)  
{

    new 
String:szText[256];
    
GetCmdArg(1szTextsizeof(szText));
        
    if(
GetClientTeam(client) == CS_TEAM_CT) {
        
PrintToChatAll("{green}[%s] {team2}%N :{default} %s"gangclientszText); 
        return 
Plugin_Handled;
    }
    else if(
GetClientTeam(client) == CS_TEAM_T) {
        
PrintToChatAll("{green}[%s] {team1}%N :{default} %s"gangclientszText);  
        return 
Plugin_Handled;
    }
        
    
    return 
Plugin_Continue;

OR you can use OnChatMessage !

REMEMBER !
It is just an example ! Also as you can see don't forget to add
PHP Code:
return Plugin_Continue
because it will make other chat plugins to get bugged if you have !

Last edited by cristian20042; 12-15-2017 at 12:35.
cristian20042 is offline
Papero
Veteran Member
Join Date: Aug 2016
Location: Italy
Old 12-16-2017 , 05:54   Re: [CSGO] Set a prefix to a chat message
Reply With Quote #3

Why you just don't use chat-processor

PHP Code:
public Action CP_OnChatMessage(intauthorArrayList recipientschar[] flagstringchar[] namechar[] messageboolprocesscolorsboolremovecolors)
{
    
Format(nameMAXLENGTH_NAME"{green}[%s]{teamcolor}%s{default}"gangname);
    return 
Plugin_Changed;

Then you just add checks for the team and it's done.

Available colors
__________________
My Plugins
SPCode


Steam: hexer504
Telegram: Hexah
Discord: Hexah#6903

If you like my work you can donate here!

Last edited by Papero; 12-16-2017 at 07:41. Reason: Colors
Papero is offline
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 12-16-2017 , 06:19   Re: [CSGO] Set a prefix to a chat message
Reply With Quote #4

Quote:
But that would collide with other plugins that changes colors and such of messages.
I don't think his issue is how to actually do it, but how to make it the final adjustment. Unfortunately hook order in sourcemod can't be relied on, so you'll have to work around that by editing the other plugins or creating a new forward/native.
hmmmmm 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:30.


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