Advertisement
Guest User

Untitled

a guest
Dec 15th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.20 KB | None | 0 0
  1. #pragma semicolon 1
  2. #pragma tabsize 0
  3. #include <morecolors>
  4. #include <csgo_colors>
  5.  
  6. #pragma newdecls required
  7.  
  8. #define CLIENT_MESSAGE "%s%s %s%N {default}: %s%s", szColorPrefix, szPrefix, szColorNick, iClient, szColorText, szMessage
  9.  
  10. EngineVersion   g_Game;
  11. KeyValues       g_Chat;
  12.  
  13. enum ChatAdminEnum
  14. {
  15.     ChatAdmin_NoCommand = 0,
  16.     ChatAdmin_ChangePrefix,
  17.     ChatAdmin_ChangePrefixColor,
  18.     ChatAdmin_ChangeNameColor,
  19.     ChatAdmin_ChangeTextColor
  20. }
  21.  
  22. int ChatAdminChange = view_as<int>(ChatAdmin_NoCommand);
  23.  
  24. public Plugin myinfo =
  25. {
  26.     name = "Chat",
  27.     author = "Xummuk97",
  28.     description = "Custom chat for client",
  29.     version = "1.1",
  30.     url = "vk.com/xummuk_vk"
  31. };
  32.  
  33. public void OnPluginStart()
  34. {
  35.     g_Game = GetEngineVersion();
  36.    
  37.     if (g_Game != Engine_CSGO && g_Game != Engine_CSS)
  38.         SetFailState("This plugin is for CSGO/CSS only.")
  39.    
  40.     RegAdminCmd("sm_chatadmin", CMD_ChatAdmin, ADMFLAG_ROOT);
  41.  
  42.     LoadKV();
  43. }
  44.  
  45. public void LoadKV()
  46. {
  47.     char szPath[256];
  48.     BuildPath(Path_SM, szPath, sizeof szPath, "configs/chat.ini");
  49.     g_Chat = new KeyValues("Chat");
  50.    
  51.     if (!g_Chat.ImportFromFile(szPath))  
  52.     {
  53.         PrintToServer("[CHAT] Error importing from file 'configs/chat.ini'.");
  54.         g_Chat = null;
  55.         delete g_Chat;
  56.     }
  57. }
  58.  
  59. public void SaveKV()
  60. {
  61.     char szPath[256];
  62.     BuildPath(Path_SM, szPath, sizeof szPath, "configs/chat.ini");
  63.    
  64.     g_Chat.Rewind();
  65.     g_Chat.ExportToFile(szPath);
  66. }
  67.  
  68. public Action OnClientSayCommand(int iClient, const char[] command, const char[] szMessage)
  69. {
  70.     if (g_Chat == null)
  71.         return Plugin_Continue;
  72.        
  73.     if (ChatAdminChange != view_as<int>(ChatAdmin_NoCommand))
  74.     {
  75.         switch (ChatAdminChange)
  76.         {
  77.             case ChatAdmin_ChangePrefix:
  78.             {
  79.                 g_Chat.SetString("prefix", szMessage);
  80.             }
  81.             case ChatAdmin_ChangePrefixColor:
  82.             {
  83.                 g_Chat.SetString("color_prefix", szMessage);
  84.             }
  85.             case ChatAdmin_ChangeNameColor:
  86.             {
  87.                 g_Chat.SetString("color_nick", szMessage);
  88.             }
  89.             case ChatAdmin_ChangeTextColor:
  90.             {
  91.                 g_Chat.SetString("color_text", szMessage);
  92.             }
  93.         }
  94.        
  95.         ChatAdminChange = view_as<int>(ChatAdmin_NoCommand);
  96.        
  97.         SaveKV();
  98.         LoadKV();
  99.     }
  100.    
  101.     char szSteamID[32];
  102.     GetClientAuthId(iClient, AuthId_Steam3, szSteamID, 32);
  103.    
  104.     g_Chat.Rewind();
  105.    
  106.     if (g_Chat.JumpToKey(szSteamID)
  107.         || (g_Chat.JumpToKey("admin") && GetUserFlagBits(iClient) & ADMFLAG_BAN)
  108.         ||  g_Chat.JumpToKey("player"))
  109.     {
  110.         char szPrefix[32], szColorPrefix[32], szColorNick[32], szColorText[32];
  111.        
  112.         g_Chat.GetString("prefix",          szPrefix,       sizeof szPrefix);
  113.         g_Chat.GetString("color_prefix",    szColorPrefix,  sizeof szColorPrefix);
  114.         g_Chat.GetString("color_nick",      szColorNick,    sizeof szColorNick);
  115.         g_Chat.GetString("color_text",      szColorText,    sizeof szColorText);
  116.            
  117.         if (g_Game == Engine_CSS)
  118.             CPrintToChatAll(CLIENT_MESSAGE);
  119.         else
  120.             CGOPrintToChatAll(CLIENT_MESSAGE);
  121.            
  122.         return Plugin_Handled;
  123.     }
  124.    
  125.     return Plugin_Continue;
  126. }
  127.  
  128. public Action CMD_ChatAdmin(int iClient, int iArgs)
  129. {
  130.     Menu menuAdmin = new Menu(MenuHandler_ChatAdmin);
  131.     menuAdmin.SetTitle("[CHAT ADMIN]");
  132.    
  133.     g_Chat.Rewind();
  134.     g_Chat.GotoFirstSubKey();
  135.    
  136.     do
  137.     {
  138.         char szChatSection[32];
  139.         g_Chat.GetSectionName(szChatSection, sizeof szChatSection);
  140.         menuAdmin.AddItem(szChatSection, szChatSection);
  141.     }
  142.     while (g_Chat.GotoNextKey());
  143.    
  144.     menuAdmin.Display(iClient, MENU_TIME_FOREVER);
  145. }
  146.  
  147. public int MenuHandler_ChatAdmin(Menu menuAdmin, MenuAction action, int iClient, int iItem)
  148. {
  149.     switch (action)
  150.     {
  151.         case MenuAction_Select:
  152.         {
  153.             char szChatSection[128];
  154.             menuAdmin.GetItem(iItem, szChatSection, sizeof szChatSection);
  155.            
  156.             g_Chat.Rewind();
  157.             g_Chat.JumpToKey(szChatSection);
  158.            
  159.             Menu menuSection = new Menu(MenuHandle_Section);
  160.            
  161.             char szBuff[32];
  162.             g_Chat.GetString("prefix", szBuff, sizeof szBuff);
  163.            
  164.             menuSection.SetTitle(szBuff);
  165.            
  166.             menuSection.AddItem(szBuff, szBuff);
  167.            
  168.             g_Chat.GetString("color_prefix", szBuff, sizeof szBuff);
  169.             menuSection.AddItem(szBuff, szBuff);
  170.            
  171.             g_Chat.GetString("color_nick", szBuff, sizeof szBuff);
  172.             menuSection.AddItem(szBuff, szBuff);
  173.            
  174.             g_Chat.GetString("color_text", szBuff, sizeof szBuff);
  175.             menuSection.AddItem(szBuff, szBuff);
  176.  
  177.             menuSection.Display(iClient, MENU_TIME_FOREVER);
  178.         }
  179.         case MenuAction_End:
  180.         {
  181.             delete menuAdmin;
  182.         }
  183.     }
  184.    
  185.     return 0;
  186. }
  187.  
  188. public int MenuHandle_Section(Menu menuSection, MenuAction action, int iClient, int iItem)
  189. {
  190.     switch (action)
  191.     {
  192.         case MenuAction_Select:
  193.         {
  194.             ChatAdminChange = iItem + 1;
  195.            
  196.             switch (ChatAdminChange)
  197.             {
  198.                 case ChatAdmin_ChangePrefix:
  199.                 {
  200.                     CPrintToChat(iClient, "{green}[CHAT] {lightgreen}Введите новый префикс...");
  201.                 }
  202.                 case ChatAdmin_ChangePrefixColor:
  203.                 {
  204.                     CPrintToChat(iClient, "{green}[CHAT] {lightgreen}Введите новый цвет префикса...");
  205.                 }
  206.                 case ChatAdmin_ChangeNameColor:
  207.                 {
  208.                     CPrintToChat(iClient, "{green}[CHAT] {lightgreen}Введите новый цвет ника...");
  209.                 }
  210.                 case ChatAdmin_ChangeTextColor:
  211.                 {
  212.                     CPrintToChat(iClient, "{green}[CHAT] {lightgreen}Введите новый цвет текста...");
  213.                 }
  214.             }
  215.         }
  216.         case MenuAction_End:
  217.         {
  218.             delete menuSection;
  219.         }
  220.     }
  221.    
  222.     return 0;
  223. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement