Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma semicolon 1
- #pragma tabsize 0
- #include <morecolors>
- #include <csgo_colors>
- #pragma newdecls required
- #define CLIENT_MESSAGE "%s%s %s%N {default}: %s%s", szColorPrefix, szPrefix, szColorNick, iClient, szColorText, szMessage
- EngineVersion g_Game;
- KeyValues g_Chat;
- enum ChatAdminEnum
- {
- ChatAdmin_NoCommand = 0,
- ChatAdmin_ChangePrefix,
- ChatAdmin_ChangePrefixColor,
- ChatAdmin_ChangeNameColor,
- ChatAdmin_ChangeTextColor
- }
- int ChatAdminChange = view_as<int>(ChatAdmin_NoCommand);
- public Plugin myinfo =
- {
- name = "Chat",
- author = "Xummuk97",
- description = "Custom chat for client",
- version = "1.1",
- url = "vk.com/xummuk_vk"
- };
- public void OnPluginStart()
- {
- g_Game = GetEngineVersion();
- if (g_Game != Engine_CSGO && g_Game != Engine_CSS)
- SetFailState("This plugin is for CSGO/CSS only.");
- RegAdminCmd("sm_chatadmin", CMD_ChatAdmin, ADMFLAG_ROOT);
- LoadKV();
- }
- public void LoadKV()
- {
- char szPath[256];
- BuildPath(Path_SM, szPath, sizeof szPath, "configs/chat.ini");
- g_Chat = new KeyValues("Chat");
- if (!g_Chat.ImportFromFile(szPath))
- {
- PrintToServer("[CHAT] Error importing from file 'configs/chat.ini'.");
- g_Chat = null;
- delete g_Chat;
- }
- }
- public void SaveKV()
- {
- char szPath[256];
- BuildPath(Path_SM, szPath, sizeof szPath, "configs/chat.ini");
- g_Chat.Rewind();
- g_Chat.ExportToFile(szPath);
- }
- public Action OnClientSayCommand(int iClient, const char[] command, const char[] szMessage)
- {
- if (g_Chat == null)
- return Plugin_Continue;
- if (ChatAdminChange != view_as<int>(ChatAdmin_NoCommand))
- {
- switch (ChatAdminChange)
- {
- case ChatAdmin_ChangePrefix:
- {
- g_Chat.SetString("prefix", szMessage);
- }
- case ChatAdmin_ChangePrefixColor:
- {
- g_Chat.SetString("color_prefix", szMessage);
- }
- case ChatAdmin_ChangeNameColor:
- {
- g_Chat.SetString("color_nick", szMessage);
- }
- case ChatAdmin_ChangeTextColor:
- {
- g_Chat.SetString("color_text", szMessage);
- }
- }
- ChatAdminChange = view_as<int>(ChatAdmin_NoCommand);
- SaveKV();
- LoadKV();
- }
- char szSteamID[32];
- GetClientAuthId(iClient, AuthId_Steam3, szSteamID, 32);
- g_Chat.Rewind();
- if (g_Chat.JumpToKey(szSteamID)
- || (g_Chat.JumpToKey("admin") && GetUserFlagBits(iClient) & ADMFLAG_BAN)
- || g_Chat.JumpToKey("player"))
- {
- char szPrefix[32], szColorPrefix[32], szColorNick[32], szColorText[32];
- g_Chat.GetString("prefix", szPrefix, sizeof szPrefix);
- g_Chat.GetString("color_prefix", szColorPrefix, sizeof szColorPrefix);
- g_Chat.GetString("color_nick", szColorNick, sizeof szColorNick);
- g_Chat.GetString("color_text", szColorText, sizeof szColorText);
- if (g_Game == Engine_CSS)
- CPrintToChatAll(CLIENT_MESSAGE);
- else
- CGOPrintToChatAll(CLIENT_MESSAGE);
- return Plugin_Handled;
- }
- return Plugin_Continue;
- }
- public Action CMD_ChatAdmin(int iClient, int iArgs)
- {
- Menu menuAdmin = new Menu(MenuHandler_ChatAdmin);
- menuAdmin.SetTitle("[CHAT ADMIN]");
- g_Chat.Rewind();
- g_Chat.GotoFirstSubKey();
- do
- {
- char szChatSection[32];
- g_Chat.GetSectionName(szChatSection, sizeof szChatSection);
- menuAdmin.AddItem(szChatSection, szChatSection);
- }
- while (g_Chat.GotoNextKey());
- menuAdmin.Display(iClient, MENU_TIME_FOREVER);
- }
- public int MenuHandler_ChatAdmin(Menu menuAdmin, MenuAction action, int iClient, int iItem)
- {
- switch (action)
- {
- case MenuAction_Select:
- {
- char szChatSection[128];
- menuAdmin.GetItem(iItem, szChatSection, sizeof szChatSection);
- g_Chat.Rewind();
- g_Chat.JumpToKey(szChatSection);
- Menu menuSection = new Menu(MenuHandle_Section);
- char szBuff[32];
- g_Chat.GetString("prefix", szBuff, sizeof szBuff);
- menuSection.SetTitle(szBuff);
- menuSection.AddItem(szBuff, szBuff);
- g_Chat.GetString("color_prefix", szBuff, sizeof szBuff);
- menuSection.AddItem(szBuff, szBuff);
- g_Chat.GetString("color_nick", szBuff, sizeof szBuff);
- menuSection.AddItem(szBuff, szBuff);
- g_Chat.GetString("color_text", szBuff, sizeof szBuff);
- menuSection.AddItem(szBuff, szBuff);
- menuSection.Display(iClient, MENU_TIME_FOREVER);
- }
- case MenuAction_End:
- {
- delete menuAdmin;
- }
- }
- return 0;
- }
- public int MenuHandle_Section(Menu menuSection, MenuAction action, int iClient, int iItem)
- {
- switch (action)
- {
- case MenuAction_Select:
- {
- ChatAdminChange = iItem + 1;
- switch (ChatAdminChange)
- {
- case ChatAdmin_ChangePrefix:
- {
- CPrintToChat(iClient, "{green}[CHAT] {lightgreen}Введите новый префикс...");
- }
- case ChatAdmin_ChangePrefixColor:
- {
- CPrintToChat(iClient, "{green}[CHAT] {lightgreen}Введите новый цвет префикса...");
- }
- case ChatAdmin_ChangeNameColor:
- {
- CPrintToChat(iClient, "{green}[CHAT] {lightgreen}Введите новый цвет ника...");
- }
- case ChatAdmin_ChangeTextColor:
- {
- CPrintToChat(iClient, "{green}[CHAT] {lightgreen}Введите новый цвет текста...");
- }
- }
- }
- case MenuAction_End:
- {
- delete menuSection;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement