View Single Post
Cruze
Veteran Member
Join Date: May 2017
Old 10-01-2018 , 06:51   Re: [CS:S/CS:GO] Chat/Scoreboard Tag Menu
Reply With Quote #59

If "name_color" is left blank/you use {teamcolor}, it is taking color from "tag_color" and applying on name. If "name_color" has any other thing than {teamcolor}/blank, it is working fine.
Help Please!

edit:-

If someone wants version that works with Chat Processor
PHP Code:
#pragma semicolon 1 

#define    PLUGIN_AUTHOR    "[W]atch [D]ogs"
#define PLUGIN_VERSION    "1.6.0 chat-processor"

#define MAXLENGTH_INPUT            128     // Inclues \0 and is the size of the chat input box.
#define MAXLENGTH_NAME            64        // This is backwords math to get compability.  Sourcemod has it set at 32, but there is room for more.
#define MAXLENGTH_MESSAGE        256        // This is based upon the SDK and the length of the entire message, including tags, name, : etc.

#include <sourcemod> 
#include <cstrike> 
#include <clientprefs>

#undef REQUIRE_PLUGIN
#include <chat-processor>
#define REQUIRE_PLUGIN

#include <multicolors>


Handle h_bEnable;
Handle g_hClientCookies;

char sTags[100][256];
char sFlags[100][8];
char sMode[100][32];
char sTagColors[100][32];
char sNameColors[100][32];
char sTextColors[100][32];
char sSteamIds[100][32];

int iTags 0;

public 
Plugin myinfo 
{
    
name "[CSGO/CSS] Chat/Scoreboard Tag Menu"
    
author PLUGIN_AUTHOR
    
description "An advanced chat & scoreboard tag menu for players"
    
version PLUGIN_VERSION
    
url "https://forums.alliedmods.net/showthread.php?t=299351"
};

public 
void OnPluginStart()
{
    
LoadTranslations("TagMenu.phrases");
    
    
h_bEnable CreateConVar("sm_tagmenu_enable""1""Enable / Disable tag menu"_true0.0true1.0);
    
    
RegConsoleCmd("sm_tag"Command_TagMenu);
    
RegConsoleCmd("sm_tags"Command_TagMenu);
    
RegConsoleCmd("sm_tagmenu"Command_TagMenu);
    
    
RegAdminCmd("sm_reloadtags"Command_ReloadTagsADMFLAG_GENERIC);
    
    
HookEvent("player_spawn"Event_PlayerSetTag);
    
HookEvent("player_team"Event_PlayerSetTag);
    
    
g_hClientCookies RegClientCookie("Tag_Menu""A cookie for saving clients's tags"CookieAccess_Private);
    
    
LoadTagsFromFile();
}

public 
void OnAllPluginsLoaded()
{
    if(!
LibraryExists("chat-processor"))
    {
        
LogError("[TagMenu] Chat Processor(https://forums.alliedmods.net/showthread.php?t=286913) plugin not found! Chat function is disabled.");
    }
}

public 
Action Event_PlayerSetTag(Handle event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    
SetClientTag(client);
}

public 
void OnClientPostAdminCheck(int client)
{
    if (
AreClientCookiesCached(client))
    {
        
SetClientTag(client);
    }
}

public 
void OnClientSettingsChanged(int client)
{
    if (
AreClientCookiesCached(client))
    {
        
SetClientTag(client);
    }
}

public 
Action Command_TagMenu(int clientint args)
{
    if (
GetConVarBool(h_bEnable))
        
TagMenu(client);
    else
        
CReplyToCommand(client"%t""TagMenu_Disabled");
    
    return 
Plugin_Handled;
}

public 
Action Command_ReloadTags(int clientint args)
{
    
LoadTagsFromFile();
    
CReplyToCommand(client"%t""Tags_Reloaded");
    return 
Plugin_Handled;
}

public 
void TagMenu(int client)
{
    
Handle menu CreateMenu(MenuCallBack);
    
SetMenuTitle(menu"%t""Menu_Title");
    
    
char sDisableItem[128];
    
Format(sDisableItemsizeof(sDisableItem), "%t""Item_Disable");
    
AddMenuItem(menu"0"sDisableItem);
    
    for (
int i 0iTagsi++)
    {
        
char sInfo[300];
        
Format(sInfosizeof(sInfo), "%s_,_%s"sMode[i], sTags[i]);
        
        if (
sFlags[i][0] == '\0')
        {
            if (
sSteamIds[i][0] != '\0')
            {
                
char sSteamID[32];
                
GetClientAuthId(clientAuthId_EnginesSteamIDsizeof(sSteamID));
                if (
StrEqual(sSteamIds[i], sSteamID))
                    
AddMenuItem(menusInfosTags[i]);
                else
                    
AddMenuItem(menusInfosTags[i], ITEMDRAW_DISABLED);
            }
            else
                
AddMenuItem(menusInfosTags[i]);
        }
        else
        {
            if (
CheckCommandAccess(client""ReadFlagString(sFlags[i])))
            {
                
AddMenuItem(menusInfosTags[i]);
            }
            else
                
AddMenuItem(menusInfosTags[i], ITEMDRAW_DISABLED);
        }
    }
    
    
DisplayMenu(menuclientMENU_TIME_FOREVER);
}

public 
int MenuCallBack(Handle menuMenuAction actionint clientint itemNum)
{
    if (
action == MenuAction_Select)
    {
        
char sItem[256], sSteamID[64];
        
GetMenuItem(menuitemNumsItemsizeof(sItem));
        
GetClientAuthId(clientAuthId_EnginesSteamIDsizeof(sSteamID));
        
        if (
itemNum == 0)
        {
            
CS_SetClientClanTag(client"");
            
SetAuthIdCookie(sSteamIDg_hClientCookies"");
            
CPrintToChat(client"%t""Tag_Disabled");
        }
        else
        {
            
char sItems[2][256];
            
ExplodeString(sItem"_,_"sItems2256);
            
            if (
StrEqual(sItems[0], "chat"))
            {
                
SetAuthIdCookie(sSteamIDg_hClientCookiessItem);
                
CPrintToChat(client"%t""ChatTag_Enabled"sItems[1]);
            }
            else
            {
                
CS_SetClientClanTag(clientsItems[1]);
                
SetAuthIdCookie(sSteamIDg_hClientCookiessItem);
                
CPrintToChat(client"%t""Tag_Enabled"sItems[1]);
            }
        }
    }
    else if (
action == MenuAction_End)CloseHandle(menu);
}

public 
Action CP_OnChatMessage(int &clientArrayList recipientschar[] flagstringchar[] sNamechar[] sMessagebool &processcolorsbool &removecolors)
{
    if(
GetConVarBool(h_bEnable) && (MaxClients >= client 0))
    {
        if(
sMessage[0] == '/' || sMessage[0] == '@')
        {
            return 
Plugin_Continue;
        }
        
        
char sCookie[300];
        
GetClientCookie(clientg_hClientCookiessCookiesizeof(sCookie));
        
        if (
sCookie[0] == '\0')
            return 
Plugin_Continue;
        
        
char sCookies[2][256];
        
ExplodeString(sCookie"_,_"sCookies2256);
        
        if (
StrEqual(sCookies[0], "scoreboard"))
            return 
Plugin_Continue;
        
        
char sTagColor[32], sNameColor[32], sTextColor[32];
        
FindTagColors(sCookies[1], sTagColorsNameColorsTextColor);
        
        
Format(sMessageMAXLENGTH_MESSAGE"%s%s"sTextColorsMessage);
        
Format(sNameMAXLENGTH_NAME"%s%s %s%s"sTagColorsCookies[1], sNameColorsName);
        
        
CFormatColor(sMessageMAXLENGTH_MESSAGE);
        
CFormatColor(sNameMAXLENGTH_MESSAGE);
        
        return 
Plugin_Changed;
    }

    return 
Plugin_Continue;
}

public 
void LoadTagsFromFile()
{
    
Handle kv CreateKeyValues("TagMenu");
    if (
FileToKeyValues(kv"addons/sourcemod/configs/tagmenu.cfg") && KvGotoFirstSubKey(kv))
    {
        
iTags 0;
        do
        {
            
KvGetString(kv"tag"sTags[iTags], 256);
            
KvGetString(kv"flag"sFlags[iTags], 8);
            
KvGetString(kv"steamid"sSteamIds[iTags], 32);
            
KvGetString(kv"tag_color"sTagColors[iTags], 32"{default}");
            
KvGetString(kv"name_color"sNameColors[iTags], 32"{teamcolor}");
            
KvGetString(kv"text_color"sTextColors[iTags], 32"{default}");
            
KvGetString(kv"mode"sMode[iTags], 32"both");
            
iTags++;
        } while (
KvGotoNextKey(kv));
    }
    else
    {
        
SetFailState("[TagMenu] Error in parsing file tagmenu.cfg.");
    }
    
CloseHandle(kv);
}

public 
void SetClientTag(int client)
{
    if (
client || client MaxClients || !GetConVarBool(h_bEnable) || !IsClientConnected(client) || IsFakeClient(client))
        return;
    
    
char sCookie[256];
    
GetClientCookie(clientg_hClientCookiessCookiesizeof(sCookie));
    
    if (
sCookie[0] == '\0')
        return;
    
    
char sCookies[2][256];
    
ExplodeString(sCookie"_,_"sCookies2256);
    
    if (!
StrEqual(sCookies[0], "chat"))
    {
        
char sPlayerTag[64];
        
CS_GetClientClanTag(clientsPlayerTagsizeof(sPlayerTag));
        if (!
StrEqual(sPlayerTagsCookies[1]))
        {
            
CS_SetClientClanTag(clientsCookies[1]);
        }
    }
}

public 
void FindTagColors(char[] sTagchar[] sTagColorchar[] sNameColorchar[] sTextColor)
{
    for (
int i 0iTagsi++)
    {
        if (
StrEqual(sTags[i], sTag))
        {
            
strcopy(sTagColor32sTagColors[i]);
            
strcopy(sNameColor32sNameColors[i]);
            
strcopy(sTextColor32sTextColors[i]);
            break;
        }
    }

Attached Files
File Type: zip Tag Menu 1.6.0 - Chat Processor.zip (40.5 KB, 140 views)
__________________
Taking paid private requests! Contact me

Last edited by Cruze; 10-01-2018 at 07:46. Reason: added chat-processor supported version!
Cruze is offline