Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- #define PREFIX "\x01[\x05AVC\x01]"
- bool Channel[32] = false;
- public Plugin myinfo =
- {
- name = "[AVC] Admin Voice Channel",
- author = "BaroNN",
- description = "",
- version = "1.0",
- url = "http://steamcommunity.com/id/BaRoNN-Main"
- };
- public void OnPluginStart()
- {
- RegConsoleCmd("sm_admintalk", Command_AdminChannel);
- RegConsoleCmd("sm_avc", Command_AdminChannel);
- }
- public Action ShowMenu(int client)
- {
- if(!IsValidClient(client))
- {
- PrintToChat(client, "%s \x02You are not allowed to use the admintalk", PREFIX)
- return Plugin_Handled;
- }
- char CF[512];
- Menu menu = new Menu(AdminMenuHandler);
- menu.SetTitle("[AVC] Admin Voice Channel");
- FormatEx(CF, sizeof(CF), "Admin Channel: [%s]", (Channel[client])? "ON":"OFF");
- menu.AddItem("", CF);
- menu.Display(client, MENU_TIME_FOREVER);
- return Plugin_Handled;
- }
- public int AdminMenuHandler(Menu menu, MenuAction action, int client, int item)
- {
- if(action == MenuAction_Select)
- {
- Channel[client] = !Channel[client];
- SetClientVoice(client, Channel[client]);
- if(Channel[client])PrintToChat(client, "%s \x10You have entered\x01 the admin voice channel", PREFIX);
- else PrintToChat(client, "%s \x04You have %s quit\x01 the admin voice channel", PREFIX);
- ShowMenu(client);
- }
- }
- public void SetClientVoice(int client, bool adminchannel)
- {
- for(int i = 1; i <= MaxClients; i++)
- {
- if(IsValidClient(i))
- {
- ListenOverride override = ((adminchannel && Channel[i]) || (!adminchannel && !Channel[i]))? Listen_Yes:Listen_No;
- SetListenOverride(i, client, override);
- SetListenOverride(client, i, override);
- }
- }
- }
- public OnClientPostAdminCheck(int client)
- {
- Channel[client] = false;
- }
- public Action Command_AdminChannel(int client, int args)
- {
- if(IsValidClient(client))ShowMenu(client);
- }
- stock bool IsValidClient(int client)
- {
- if (client >= 1 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && !IsFakeClient(client) && !IsClientSourceTV(client) && !CheckCommandAccess(client, "sm_admin", ADMFLAG_GENERIC))return true;
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement