Advertisement
B2SX

[AVC] Admin Voice Channel

Oct 12th, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.11 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3.  
  4. #define PREFIX "\x01[\x05AVC\x01]"
  5. bool Channel[32] = false;
  6.  
  7. public Plugin myinfo =
  8. {
  9.     name = "[AVC] Admin Voice Channel",
  10.     author = "BaroNN",
  11.     description = "",
  12.     version = "1.0",
  13.     url = "http://steamcommunity.com/id/BaRoNN-Main"
  14. };
  15.  
  16. public void OnPluginStart()
  17. {
  18.     RegConsoleCmd("sm_admintalk", Command_AdminChannel);
  19.     RegConsoleCmd("sm_avc", Command_AdminChannel);
  20. }
  21.  
  22. public Action ShowMenu(int client)
  23. {
  24.     if(!IsValidClient(client))
  25.     {
  26.         PrintToChat(client, "%s \x02You are not allowed to use the admintalk", PREFIX)
  27.         return Plugin_Handled;
  28.     }
  29.    
  30.     char CF[512];
  31.     Menu menu = new Menu(AdminMenuHandler);
  32.     menu.SetTitle("[AVC] Admin Voice Channel");
  33.     FormatEx(CF, sizeof(CF), "Admin Channel: [%s]", (Channel[client])? "ON":"OFF");
  34.     menu.AddItem("", CF);
  35.     menu.Display(client, MENU_TIME_FOREVER);
  36.     return Plugin_Handled;
  37. }
  38.  
  39. public int AdminMenuHandler(Menu menu, MenuAction action, int client, int item)
  40. {
  41.     if(action == MenuAction_Select)
  42.     {
  43.         Channel[client] = !Channel[client];
  44.         SetClientVoice(client, Channel[client]);
  45.         if(Channel[client])PrintToChat(client, "%s \x10You have entered\x01 the admin voice channel", PREFIX);
  46.         else PrintToChat(client, "%s \x04You have %s quit\x01 the admin voice channel", PREFIX);
  47.         ShowMenu(client);
  48.     }
  49. }
  50.  
  51. public void SetClientVoice(int client, bool adminchannel)
  52. {
  53.     for(int i = 1; i <= MaxClients; i++)
  54.     {
  55.         if(IsValidClient(i))
  56.         {
  57.             ListenOverride override = ((adminchannel && Channel[i]) || (!adminchannel && !Channel[i]))? Listen_Yes:Listen_No;
  58.             SetListenOverride(i, client, override);
  59.             SetListenOverride(client, i, override);
  60.         }
  61.     }
  62. }
  63.  
  64. public OnClientPostAdminCheck(int client)
  65. {
  66.     Channel[client] = false;
  67. }
  68.  
  69. public Action Command_AdminChannel(int client, int args)
  70. {
  71.     if(IsValidClient(client))ShowMenu(client);
  72. }
  73.  
  74. stock bool IsValidClient(int client)
  75. {
  76.     if (client >= 1 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && !IsFakeClient(client) && !IsClientSourceTV(client) && !CheckCommandAccess(client, "sm_admin", ADMFLAG_GENERIC))return true;
  77.     return false;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement