Raised This Month: $51 Target: $400
 12% 

[CS:S] VoiceMgr v2.2.2 (Updated 23-07-2011)


Post New Thread Reply   
 
Thread Tools Display Modes
duydangle
Senior Member
Join Date: May 2010
Old 10-28-2011 , 11:42   Re: [CS:S] VoiceMgr v2.2.2 (Updated 23-07-2011)
Reply With Quote #31

OMG thank you very much. Can you add a feature that player can view channel's player list before/when you join the channel?
duydangle is offline
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 10-28-2011 , 12:47   Re: [CS:S] VoiceMgr v2.2.2 (Updated 23-07-2011)
Reply With Quote #32

download: http://forums.alliedmods.net/showpos...6&postcount=26

V 1.2
- ADDED cvar to show all players with channel @ public channel
__________________

Last edited by zipcore; 10-28-2011 at 12:47.
zipcore is offline
StrikerMan780
AlliedModders Donor
Join Date: Jul 2009
Location: Canada
Old 10-28-2011 , 16:48   Re: [CS:S] VoiceMgr v2.2.2 (Updated 23-07-2011)
Reply With Quote #33

Awesome stuff, thanks.
StrikerMan780 is offline
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 10-29-2011 , 12:45   Re: [CS:S] VoiceMgr v2.2.2 (Updated 23-07-2011)
Reply With Quote #34

download: http://forums.alliedmods.net/showpos...6&postcount=26

V 1.3
- FIXED hud bugs of v1.2
__________________
zipcore is offline
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 11-01-2011 , 09:54   Re: [CS:S] VoiceMgr v2.2.2 (Updated 23-07-2011)
Reply With Quote #35

download: http://forums.alliedmods.net/showpos...6&postcount=26

V1.4
- IMPROVED hud output
- ADDED cvar to allow admins ignore channel password
- ADDED cvar to set public chanel id
- RE-ADDED !vcs to set channels
- RE-ADDED !vcl to list channels (with passwords if admin)
__________________

Last edited by zipcore; 11-01-2011 at 09:55.
zipcore is offline
StrikerMan780
AlliedModders Donor
Join Date: Jul 2009
Location: Canada
Old 11-01-2011 , 19:59   Re: [CS:S] VoiceMgr v2.2.2 (Updated 23-07-2011)
Reply With Quote #36

EDIT: Updated my changes, to work in 1.4. Adds TF2 Support, plus there's some stuff added to make it easier to add support for other games such as HL2DM or DODS.

Code:
#include <sourcemod>
#include <sdktools>
#include <colors>
#include <smlib>
//#include <cstrike>

#define PLUGIN_VERSION "1.5"

#define MAXCLIENTS 255
#define ARRAYS_SIZE 128

// Added by StrikerMan780
new game;
#define UNKNOWN 0
#define CSTRIKE 1
#define DODS    2
#define HL2DM    3
#define TF2        4

#define TEAM_SPECTATOR 1
#define CS_TEAM_T 2
#define CS_TEAM_CT 3

#define TF2_TEAM_RED 2
#define TF2_TEAM_BLU 3

new g_iChannels;
new g_iChannelsMode[64];
new g_iChannelsTeams[64];
new g_iChannelsCount[64];
new String:g_sChannelsName[64][ARRAYS_SIZE];
new String:g_sChannelsPass[64][ARRAYS_SIZE];
new String:g_sChannelsFlag[64][ARRAYS_SIZE];
new String:SavePath[256]
new g_iClientChannel[MAXCLIENTS+1];
new g_iClientSpeakAll[MAXCLIENTS+1];
new g_iClientListenAll[MAXCLIENTS+1];
new g_iClientMuted[MAXCLIENTS+1][64];
new g_iClientInvites[MAXCLIENTS+1];
new g_iClientChTryPrivate[MAXCLIENTS+1];
new g_iClientChTryPw[MAXCLIENTS+1];

new Handle:HudHintTimers[MAXPLAYERS+1];

new Handle:vc_enable = INVALID_HANDLE;
new Handle:vc_invite_max = INVALID_HANDLE;
new Handle:vc_invite_admins = INVALID_HANDLE;
new Handle:vc_intive_enable = INVALID_HANDLE;
new Handle:vc_invite_admin_only = INVALID_HANDLE;
new Handle:vc_invite_public_only = INVALID_HANDLE;
new Handle:vc_hud_enable = INVALID_HANDLE;
new Handle:vc_hud_show_status = INVALID_HANDLE;
new Handle:vc_hud_show_self = INVALID_HANDLE;
new Handle:vc_hud_show_player_count = INVALID_HANDLE;
new Handle:vc_hud_show_invites = INVALID_HANDLE;
new Handle:vc_hud_show_invite_cmd = INVALID_HANDLE;
new Handle:vc_hud_show_channel_cmd = INVALID_HANDLE;
new Handle:vc_hud_show_team = INVALID_HANDLE;
new Handle:vc_hud_show_public_all = INVALID_HANDLE;
new Handle:vc_show_incoming = INVALID_HANDLE;
new Handle:vc_store_channel = INVALID_HANDLE;
new Handle:vc_admin_ignore_channel_pw = INVALID_HANDLE;
new Handle:vc_public_channel_id = INVALID_HANDLE;

new cvar_vc_enable;
new cvar_vc_invite_max;
new cvar_vc_invite_admins;
new cvar_vc_intive_enable;
new cvar_vc_invite_admin_only;
new cvar_vc_invite_public_only;
new cvar_vc_hud_enable;
new cvar_vc_hud_show_status;
new cvar_vc_hud_show_self;
new cvar_vc_hud_show_player_count;
new cvar_vc_hud_show_invites;
new cvar_vc_hud_show_invite_cmd;
new cvar_vc_hud_show_channel_cmd;
new cvar_vc_hud_show_team;
new cvar_vc_hud_show_public_all;
new cvar_vc_show_incoming;
new cvar_vc_store_channel;
new cvar_vc_admin_ignore_channel_pw;
new cvar_vc_public_channel_id;

public Plugin:myinfo = {
    name = "VoiceMgr",
    author = "s1dex & zipcore",
    description = "Advanced Voice Manager [CS:S]",
    version = PLUGIN_VERSION,
    url = "http://forums.alliedmods.net/showpost.php?p=1584256&postcount=26"
};

public OnPluginStart()
{
    CreateConVar("voicemgr_version", PLUGIN_VERSION, "VoiceMgr Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
    
    //CVARS GENERAL
    vc_enable = CreateConVar("vc_enable", "1", "Enable VoiceMgr (0=disable; 1=enable)");
    vc_show_incoming = CreateConVar("vc_show_incoming", "0", "Show channel transfer msg if client connected (0=disable; 1=enable)");
    vc_store_channel = CreateConVar("vc_store_channel", "1", "Store last channel? (0=disable; 1=enable)");
    vc_admin_ignore_channel_pw = CreateConVar("vc_admin_ingore_channel_pw", "1", "Can Admins join private channels without password? (0=disable; 1=enable)");
    vc_public_channel_id = CreateConVar("vc_public_channel_id", "0", "Id of your public channel");
    
    //CVARS INVITE
    vc_invite_max = CreateConVar("vc_invite_max", "3", "Max. invites per map for non-admins (0=unl.)");
    vc_invite_admins = CreateConVar("vc_invite_admins", "1", "Can non-admins invite admins? (0=disable; 1=enable)");
    vc_intive_enable = CreateConVar("vc_intive_enable", "1", "Enable invite cmd (0=disable; 1=enable)");
    vc_invite_admin_only = CreateConVar("vc_invite_admin_only", "0", "Only admins can invite (0=disable; 1=enable)");
    vc_invite_public_only = CreateConVar("vc_invite_public_only", "1", "Only invite player if they are in public channel (0=disable; 1=enable)");
    
    //CVARS HUD
    vc_hud_enable = CreateConVar("vc_hud_enable", "1", "Enable channel HUD (0=disable; 1=enable)");
    vc_hud_show_status = CreateConVar("vc_hud_show_status", "1", "Show [ALIVE] & [DEAD] behind name (0=disable; 1=enable)");
    vc_hud_show_self = CreateConVar("vc_hud_show_self", "1", "Show yourself listed (0=disable; 1=enable)");
    vc_hud_show_player_count = CreateConVar("vc_hud_show_player_count", "1", "Show count of online players in channel (0=disable; 1=enable)");
    vc_hud_show_invites = CreateConVar("vc_hud_show_invites", "1", "Show invites left (0=disable; 1=enable)");
    vc_hud_show_invite_cmd = CreateConVar("vc_hud_show_invite_cmd", "2", "Show !vci? (0=disable; 1=ever; 2=only if public channel is not empty)");
    vc_hud_show_channel_cmd = CreateConVar("vc_hud_show_channel_cmd", "2", "Show !vc? (0=disable; 1=ever; 2=only in public channel)");
    vc_hud_show_team = CreateConVar("vc_hud_show_team", "1", "Show team tags in front of name (0=disable; 1=enable)");
    vc_hud_show_public_all = CreateConVar("vc_hud_show_public_all", "1", "Show channels channel list instead if current channel is public channel (0=disable; 1=only not empty 2=all channels [!only 254 chars can be displayed])");
    
    AutoExecConfig(true, "voice_mgr");
    
    cvar_vc_enable = GetConVarInt(vc_enable);
    if(cvar_vc_enable == 1)
    {
        BuildPath(Path_SM, SavePath, 255, "data/VoiceMgrSave.txt");
        LoadTranslations("voicemgr.phrases");
        
        RegConsoleCmd("vc", VCChooseChannelGui);
        RegConsoleCmd("vci",VCInviteGui)
        RegConsoleCmd("vck",VCKickGui)
        RegConsoleCmd("vcs", VCSetChnl);
        RegConsoleCmd("vcl", VCList);
        
        RegConsoleCmd("say", CmdSay);
        
        HookEvent("player_team", EventPlayerTeam);
        
        cvar_vc_invite_max = GetConVarInt(vc_invite_max);
        cvar_vc_invite_admins = GetConVarInt(vc_invite_admins);
        cvar_vc_intive_enable = GetConVarInt(vc_intive_enable);
        cvar_vc_invite_admin_only = GetConVarInt(vc_invite_admin_only);
        cvar_vc_invite_public_only = GetConVarInt(vc_invite_public_only);
        cvar_vc_hud_enable = GetConVarInt(vc_hud_enable);
        cvar_vc_hud_show_status = GetConVarInt(vc_hud_show_status);
        cvar_vc_hud_show_self = GetConVarInt(vc_hud_show_self);
        cvar_vc_hud_show_player_count = GetConVarInt(vc_hud_show_player_count);
        cvar_vc_hud_show_invites = GetConVarInt(vc_hud_show_invites);
        cvar_vc_hud_show_invite_cmd = GetConVarInt(vc_hud_show_invite_cmd);
        cvar_vc_hud_show_channel_cmd = GetConVarInt(vc_hud_show_channel_cmd);
        cvar_vc_hud_show_team = GetConVarInt(vc_hud_show_team);
        cvar_vc_hud_show_public_all = GetConVarInt(vc_hud_show_public_all);
        cvar_vc_show_incoming = GetConVarInt(vc_show_incoming);
        cvar_vc_store_channel = GetConVarInt(vc_store_channel);
        cvar_vc_admin_ignore_channel_pw = GetConVarInt(vc_admin_ignore_channel_pw);
        cvar_vc_public_channel_id = GetConVarInt(vc_public_channel_id);
    }
}

public OnClientDisconnect(client)
{
    if(cvar_vc_enable == 1 && cvar_vc_hud_enable == 1)
    {
        KillHudHintTimer(client);
    }
}

public OnClientPutInServer(client)
{
    if(cvar_vc_enable == 1 && Client_MatchesFilter(client, CLIENTFILTER_INGAME))
    {
        if(cvar_vc_hud_enable == 1)
        {
            CreateHudHintTimer(client);
        }
        g_iClientChTryPw[client] = 0;
        g_iClientChTryPrivate[client] = 0;
        for (new i=0;i<=g_iChannels;i++)
        {
            if (g_iChannelsMode[i] != 0)
            {
                continue;
            }
            
            if(cvar_vc_public_channel_id >= 0)
            {
                g_iClientChannel[client] = cvar_vc_public_channel_id;
            }
            else
            {
                g_iClientChannel[client] = i;
            }
            if(cvar_vc_store_channel == 1)
            {
                LoadSettings(client);
            }
            RefreshClientChannel(client);
            if(cvar_vc_show_incoming == 1)
            {
                decl String:name[64];
                GetClientName(client, name, sizeof(name));
                CPrintToChatAll("%t", "ChangeChannel", name, g_sChannelsName[g_iClientChannel[client]]);
            }
            break;
        }
    }
}

public OnMapStart()
{
    if(cvar_vc_enable == 1)
    {
        g_iChannels = -1;
        for(new i = 1; i <= MaxClients; i++) 
        {
            g_iClientInvites[i] = cvar_vc_invite_max;
        }
        decl String:file[PLATFORM_MAX_PATH];
        BuildPath(Path_SM, file, sizeof(file), "configs/voicemgr.channels.cfg");
        new Handle:kv = CreateKeyValues("Channels");
        FileToKeyValues(kv, file);
        if (KvGotoFirstSubKey(kv))
        {
            do
            {
                g_iChannels++;
                
                decl String:buffer[32];
                KvGetSectionName(kv, g_sChannelsName[g_iChannels], ARRAYS_SIZE);
                KvGetString(kv, "mode", buffer, sizeof(buffer), "public");
                if (StrEqual(buffer, "private"))
                    g_iChannelsMode[g_iChannels] = 1;
                else if (StrEqual(buffer, "admins"))
                    g_iChannelsMode[g_iChannels] = 2;
                else
                    g_iChannelsMode[g_iChannels] = 0;
                
                if (g_iChannelsMode[g_iChannels] == 1)
                    KvGetString(kv, "password", g_sChannelsPass[g_iChannels], ARRAYS_SIZE, "pw");
                if (g_iChannelsMode[g_iChannels] == 2)
                    KvGetString(kv, "flag", g_sChannelsFlag[g_iChannels], ARRAYS_SIZE, "slay");
                
                g_iChannelsTeams[g_iChannels] = KvGetNum(kv, "teams", 0);
            }
            while (KvGotoNextKey(kv))
        }
    }
}

public Action:EventPlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(cvar_vc_enable == 1)
    {
        new client = GetClientOfUserId(GetEventInt(event, "userid"));
        RefreshClientChannel(client);
    }
}

public Action:VCChooseChannelGui(client, args)
{
    if(cvar_vc_enable == 1 && Client_MatchesFilter(client, CLIENTFILTER_INGAME))
    {
        decl String:szText[254];
        new Handle:menu = CreateMenu(MenuChooseChannel);
        SetMenuTitle(menu, "Choose a voice channel [current: %s]", g_sChannelsName[g_iClientChannel[client]]);
        
        decl String:buffer[5];
        for (new i=0;i<=g_iChannels;i++)
        {
            Format(szText, sizeof(szText), "%s (%d online)", g_sChannelsName[i], g_iChannelsCount[i]);
            IntToString(i, buffer, sizeof(buffer));
            AddMenuItem(menu, buffer, szText);
        }
        SetMenuExitButton(menu, true);
        DisplayMenu(menu, client, 20);
    }
    return Plugin_Handled;
}

public Action:VCSetChnl(client, args)
{
    if(cvar_vc_enable == 1 && Client_MatchesFilter(client, CLIENTFILTER_INGAME))
    {
        decl String:arg[32];
        GetCmdArg(1, arg, sizeof(arg));
        
        new chnl = StringToInt(arg);
        if (chnl > g_iChannels)
        {
            CPrintToChat(client, "%t", "NotRegistered", chnl);
            return Plugin_Handled;
        }
        else if (chnl == g_iClientChannel[client])
        {
            CPrintToChat(client, "%t", "AlreadyIn");
            return Plugin_Handled;
        }
        else
        {
            if (g_iChannelsMode[chnl] == 2)
            {
                new AdminId:admin;
                if ((admin = GetUserAdmin(client)) == INVALID_ADMIN_ID)
                {
                    CPrintToChat(client, "%t", "AdminsOnly");
                    return Plugin_Handled;
                }
                else
                {
                    new AdminFlag:flag;
                    FindFlagByName(g_sChannelsFlag[chnl], flag);
                    
                    if (!GetAdminFlag(admin, flag))
                    {
                        CPrintToChat(client, "%t", "InvalidFlag", g_sChannelsFlag[chnl]);
                        return Plugin_Handled;
                    }
                }
            }
            else if (g_iChannelsMode[chnl] == 1)
            {
                decl String:info[128];
                GetClientInfo(client, "_vcpass", info, sizeof(info));
                if (!StrEqual(info, g_sChannelsPass[chnl]))
                {
                    CPrintToChat(client, "%t", "Private1");
                    CPrintToChat(client, "%t", "Private2");
                    return Plugin_Handled;
                }
            }
            
            decl String:name[64];
            GetClientName(client, name, sizeof(name));
            
            g_iClientChannel[client] = chnl;
            RefreshClientChannel(client);
            CPrintToChatAll("%t", "ChangeChannel", name, g_sChannelsName[chnl]);
        }
    }
    return Plugin_Handled;
}

public Action:VCList(client, args)
{
    if(cvar_vc_enable == 1 && Client_MatchesFilter(client, CLIENTFILTER_INGAME))
    {
        PrintToConsole(client, "[VoiceMgr] Channels:");
        for (new i=0;i<=g_iChannels;i++)
        {
            if(Client_IsAdmin(client) && g_iChannelsMode[i] == 1)
            {
                PrintToConsole(client, "ID: %d - %s (pw: %s)", i, g_sChannelsName[i], g_sChannelsPass[i]);
            }
            else
            {
                PrintToConsole(client, "ID: %d - %s", i, g_sChannelsName[i]);
            }
        }
        
        CPrintToChat(client, "%t", "ListChannels");
    }
    return Plugin_Handled;
}

public Action:VCKickGui(client, args)
{
    if(cvar_vc_enable == 1 && Client_MatchesFilter(client, CLIENTFILTER_INGAME))
    {
        decl String:szText[254];
        new i_counter;
        
        if(Client_IsAdmin(client))
        {
            if(g_iClientChannel[client] != cvar_vc_public_channel_id)
            {
                new Handle:menu = CreateMenu(MenuKickChannel);
                SetMenuTitle(menu, "Kick a player out of your channel [current: %s]", g_sChannelsName[g_iClientChannel[client]]);
                
                decl String:buffer[5];
                for (new i=1;i<=MAXPLAYERS;i++)
                {
                    if(Client_IsIngame(i) && i != client && g_iClientChannel[client] == g_iClientChannel[i])
                    {
                        i_counter++;
                        Format(szText, sizeof(szText), "%N", i);
                        IntToString(i, buffer, sizeof(buffer));
                        AddMenuItem(menu, buffer, szText);
                    }
                }
                if(i_counter < 1)
                {
                    Format(szText, sizeof(szText), "Sorry, no other players found!");
                    IntToString(-1, buffer, sizeof(buffer));
                    AddMenuItem(menu, buffer, szText);
                }
                SetMenuExitButton(menu, true);
                DisplayMenu(menu, client, 20);
            }
            else
            {
                CPrintToChat(client, "%t", "KickFailedPublic");
            }
        }
        else
        {
            CPrintToChat(client, "%t", "KickFailedPermission");
        }
    }
    return Plugin_Handled;
}

public Action:VCInviteGui(client, args)
{
    if(cvar_vc_enable == 1 && Client_MatchesFilter(client, CLIENTFILTER_INGAME))
    {
        if(cvar_vc_intive_enable == 1)
        {
            decl String:szText[254];
            new i_counter;
            
            if((cvar_vc_invite_admin_only < 1 && g_iClientInvites[client] > 0) || Client_IsAdmin(client) || cvar_vc_invite_max < 1)
            {
                new Handle:menu = CreateMenu(MenuInviteChannel);
                SetMenuTitle(menu, "Invite a player into your channel [current: %s]", g_sChannelsName[g_iClientChannel[client]]);
                
                decl String:buffer[5];
                for (new i=1;i<=MAXPLAYERS;i++)
                {
                    if(Client_IsIngame(i) && i != client)
                    {
                        if(cvar_vc_invite_public_only == 0 || g_iClientChannel[i] == cvar_vc_public_channel_id)
                        {
                            if((cvar_vc_invite_admins == 1 || !Client_IsAdmin(i)) || Client_IsAdmin(client))
                            {
                                i_counter++;
                                Format(szText, sizeof(szText), "%N", i);
                                IntToString(i, buffer, sizeof(buffer));
                                AddMenuItem(menu, buffer, szText);
                            }
                        }
                    }
                }
                if(i_counter < 1)
                {
                    Format(szText, sizeof(szText), "Sorry, no other players found!");
                    IntToString(-1, buffer, sizeof(buffer));
                    AddMenuItem(menu, buffer, szText);
                }
                SetMenuExitButton(menu, true);
                DisplayMenu(menu, client, 20);
            }
            else
            {
                CPrintToChat(client, "%t", "NoInvitesLeft", cvar_vc_invite_max);
            }
        }
    }
    return Plugin_Handled;
}

public Action:CmdSay(client, args)
{
    if(cvar_vc_enable == 1 && Client_MatchesFilter(client, CLIENTFILTER_INGAME))
    {
        decl String:text[128];
        decl String:name[MAX_NAME_LENGTH+1];
        
        GetClientName(client, name, sizeof(name));
        GetCmdArgString(text, sizeof(text));
        
        ReplaceString(text, sizeof(text), "\"", "");
        
        if (Client_MatchesFilter(client, CLIENTFILTER_INGAME))
        {
            if (g_iClientChTryPw[client] == 1)
            {
                if(StrEqual(text, g_sChannelsPass[g_iClientChTryPrivate[client]]))
                {
                    if(g_iClientChannel[client] != g_iClientChTryPrivate[client])
                    {
                        CPrintToChatAll("%t", "ChangeChannel", name, g_sChannelsName[g_iClientChTryPrivate[client]]);
                        g_iClientChannel[client] = g_iClientChTryPrivate[client];
                        if(cvar_vc_store_channel == 1)
                        {
                            SaveSettings(client);
                        }
                    }
                    else
                    {
                        CPrintToChat(client, "%t", "AlreadyIn");
                    }
                    
                    RefreshClientChannel(client);
                }
                else
                {
                    CPrintToChat(client, "%t", "PasswordIncorrect");
                }
                g_iClientChTryPw[client] = 0;
                g_iClientChTryPrivate[client] = 0;
                return Plugin_Handled;    
            }
        }
    }
    return Plugin_Continue;
}

public MenuKickChannel(Handle:menu, MenuAction:action, client, param2)
{
    if(cvar_vc_enable == 1)
    {
        if ( action == MenuAction_Select ) 
        {
            decl String:info[5];
            GetMenuItem(menu, param2, info, sizeof(info));
            
            new target = StringToInt(info);
            
            decl String:clientname[64];
            GetClientName(client, clientname, sizeof(clientname));
            
            decl String:targetname[64];
            GetClientName(target, targetname, sizeof(targetname));
            
            if(target > -1)
            {
                g_iClientChannel[target]=cvar_vc_public_channel_id;
                RefreshClientChannel(target);
                CPrintToChatAll("%t", "KickedOutOfChannel", targetname, g_sChannelsName[g_iClientChannel[client]], clientname);
            }
        }
    }
}

public MenuInviteChannel(Handle:menu, MenuAction:action, client, param2)
{
    if(cvar_vc_enable == 1)
    {
        if ( action == MenuAction_Select ) 
        {
            decl String:info[5];
            GetMenuItem(menu, param2, info, sizeof(info));
            
            new target = StringToInt(info);
            new chnl = g_iClientChannel[client];
            
            if(target > -1)
            {
                if(cvar_vc_invite_max > 0)
                {
                    g_iClientInvites[client]--;
                }
                new Handle:menu2 = CreateMenu(MenuChooseChannel);
                SetMenuTitle(menu2, "%N invited you to join %s voice channel:", client, g_sChannelsName[chnl]);
                
                decl String:buffer[5];
                IntToString(chnl, buffer, sizeof(buffer));
                AddMenuItem(menu2, buffer, "Change");
                IntToString(-1, buffer, sizeof(buffer));
                AddMenuItem(menu2, buffer, "Stay");
                SetMenuExitButton(menu, true);
                DisplayMenu(menu2, target, 20);
            }
        }
    }
}

public MenuChooseChannel(Handle:menu, MenuAction:action, client, param2)
{
    if(cvar_vc_enable == 1)
    {
        if (action == MenuAction_Select)
        {
            decl String:info[5];
            GetMenuItem(menu, param2, info, sizeof(info));
            
            new chnl = StringToInt(info);
            if (chnl > -1)
            {
                if (g_iChannelsMode[chnl] == 2)
                {
                    new AdminId:admin;
                    if ((admin = GetUserAdmin(client)) == INVALID_ADMIN_ID)
                    {
                        CPrintToChat(client, "%t", "AdminsOnly");
                        return;
                    }
                    else
                    {
                        new AdminFlag:flag;
                        FindFlagByName(g_sChannelsFlag[chnl], flag);
                        
                        if (!GetAdminFlag(admin, flag))
                        {
                            CPrintToChat(client, "%t", "InvalidFlag", g_sChannelsFlag[chnl]);
                            return;
                        }
                    }
                }
                else if (g_iChannelsMode[chnl] == 1)
                {
                    if(cvar_vc_admin_ignore_channel_pw == 1 && Client_IsAdmin(client))
                    {    
                        g_iClientChannel[client] = chnl;
                        RefreshClientChannel(client);
                    }
                    else
                    {
                        g_iClientChTryPrivate[client] = chnl;
                        g_iClientChTryPw[client] = 1;
                        CPrintToChat(client, "%t", "Private1");
                    }
                    return;
                }
                decl String:name[64];
                GetClientName(client, name, sizeof(name));
                
                g_iChannelsCount[g_iClientChannel[client]]--;
                if(g_iClientChannel[client] != chnl)
                {
                    CPrintToChatAll("%t", "ChangeChannel", name, g_sChannelsName[chnl]);
                }
                g_iClientChannel[client] = chnl;
                RefreshClientChannel(client);
                if(cvar_vc_store_channel == 1)
                {
                    SaveSettings(client);
                }
            }
        }
    }
}    

public Action:Timer_UpdateHudHint(Handle:timer, any:client)
{
    decl String:szText[254];
    new ch_count;
    szText[0] = '\0';
    
    if (0 < client <= MaxClients)
    {
        if(cvar_vc_hud_show_public_all > 0 && g_iClientChannel[client] == cvar_vc_public_channel_id)
        {
            Format(szText, sizeof(szText), "Player-channel list:\n\n");
            for (new i=0;i<=g_iChannels;i++)
            {
                if(i== 0)
                {
                    ch_count++;
                }
                if(g_iChannelsCount[i] > 0 || cvar_vc_hud_show_public_all == 2)
                {
                    if(cvar_vc_hud_show_player_count == 1)
                    {
                        Format(szText, sizeof(szText), "%s%s: %d online\n", szText, g_sChannelsName[i], g_iChannelsCount[i]);
                    }
                    else
                    {
                        Format(szText, sizeof(szText), "%s%s:\n", szText, g_sChannelsName[i]);
                    }
                    for(new j = 1; j <= MaxClients; j++) 
                    {
                        if (Client_MatchesFilter(j, CLIENTFILTER_INGAME))
                        {
                            if(g_iClientChannel[j] == i)
                            {
                                Format(szText, sizeof(szText), "%s- ", szText);
                                if(cvar_vc_hud_show_team == 1 && game == CSTRIKE)
                                {
                                    if(GetClientTeam(j) == TEAM_SPECTATOR) 
                                    {
                                        Format(szText, sizeof(szText), "%s[SPEC] ", szText);
                                    }
                                    else if(GetClientTeam(j) == CS_TEAM_CT) 
                                    {
                                        Format(szText, sizeof(szText), "%s[CT] ", szText);
                                    }
                                    else if(GetClientTeam(j) == CS_TEAM_T) 
                                    {
                                        Format(szText, sizeof(szText), "%s[T] ", szText);
                                    }
                                }
                                else if(cvar_vc_hud_show_team == 1 && game == TF2)
                                {
                                    if(GetClientTeam(j) == TEAM_SPECTATOR) 
                                    {
                                        Format(szText, sizeof(szText), "%s[SPEC] ", szText);
                                    }
                                    else if(GetClientTeam(j) == TF2_TEAM_RED) 
                                    {
                                        Format(szText, sizeof(szText), "%s[RED] ", szText);
                                    }
                                    else if(GetClientTeam(j) == TF2_TEAM_BLU) 
                                    {
                                        Format(szText, sizeof(szText), "%s[BLU] ", szText);
                                    }
                                }
                                
                                if(cvar_vc_hud_show_status == 1)
                                {
                                    if(!Client_MatchesFilter(j, CLIENTFILTER_SPECTATORS))
                                    {
                                        if(Client_MatchesFilter(j, CLIENTFILTER_ALIVE))
                                        {
                                            Format(szText, sizeof(szText), "%s%N [ALIVE]\n", szText, j);
                                        }
                                        else
                                        {
                                            Format(szText, sizeof(szText), "%s%N [DEAD]\n", szText, j);
                                        }
                                    }
                                    else
                                    {
                                        Format(szText, sizeof(szText), "%s%N\n", szText, j);
                                    }
                                }
                                else
                                {
                                    Format(szText, sizeof(szText), "%s%N\n", szText, j);
                                }
                            }
                        }
                    }
                }
            }
        }
        else
        {
            if(cvar_vc_hud_show_player_count == 1)
            {
                Format(szText, sizeof(szText), "%s: %d(%d) online\n\n", g_sChannelsName[g_iClientChannel[client]], (g_iChannelsCount[g_iClientChannel[client]]-1), g_iChannelsCount[g_iClientChannel[client]]);
            }
            else
            {
                Format(szText, sizeof(szText), "%s:\n\n", g_sChannelsName[g_iClientChannel[client]]);
            }
        
            for(new i = 1; i <= MaxClients; i++) 
            {
                if (!Client_MatchesFilter(i, CLIENTFILTER_INGAME))
                {
                    continue;
                }
            
                if(g_iClientChannel[client] != g_iClientChannel[i])
                {
                    continue;
                }
                
                if(g_iClientChannel[client] == g_iClientChannel[i])
                {
                    ch_count++;
                }
            
                if (cvar_vc_hud_show_self != 1 && i == client)
                {
                    continue;
                }
                
                if(cvar_vc_hud_show_team == 1 && game == CSTRIKE)
                {
                    if(GetClientTeam(i) == TEAM_SPECTATOR) 
                    {
                        Format(szText, sizeof(szText), "%s[SPEC] ", szText);
                    }
                    else if(GetClientTeam(i) == CS_TEAM_CT) 
                    {
                        Format(szText, sizeof(szText), "%s[CT] ", szText);
                    }
                    else if(GetClientTeam(i) == CS_TEAM_T) 
                    {
                        Format(szText, sizeof(szText), "%s[T] ", szText);
                    }
                }
                else if(cvar_vc_hud_show_team == 1 && game == TF2)
                {
                    if(GetClientTeam(i) == TEAM_SPECTATOR) 
                    {
                        Format(szText, sizeof(szText), "%s[SPEC] ", szText);
                    }
                    else if(GetClientTeam(i) == TF2_TEAM_RED) 
                    {
                        Format(szText, sizeof(szText), "%s[RED] ", szText);
                    }
                    else if(GetClientTeam(i) == TF2_TEAM_BLU) 
                    {
                        Format(szText, sizeof(szText), "%s[BLU] ", szText);
                    }
                }
            
                if(cvar_vc_hud_show_status == 1)
                {
                    if(!Client_MatchesFilter(i, CLIENTFILTER_SPECTATORS))
                    {
                        if(Client_MatchesFilter(i, CLIENTFILTER_ALIVE))
                        {
                            Format(szText, sizeof(szText), "%s%N [ALIVE]\n", szText, i);
                        }
                        else
                        {
                            Format(szText, sizeof(szText), "%s%N [DEAD]\n", szText, i);
                        }
                    }
                    else
                    {
                        Format(szText, sizeof(szText), "%s%N\n", szText, i);
                    }
                }
                else
                {
                    Format(szText, sizeof(szText), "%s%N\n", szText, i);
                }
            }
        }
                
        if((g_iClientChannel[client] == cvar_vc_public_channel_id && cvar_vc_hud_show_channel_cmd == 2) || cvar_vc_hud_show_channel_cmd == 1)
        {
            Format(szText, sizeof(szText), "%s\nType !vc to change your voice channel", szText);
        }
        
        if(cvar_vc_intive_enable  == 1)
        {
            if((g_iChannelsCount[0] > 0 && cvar_vc_hud_show_invite_cmd == 2) || cvar_vc_hud_show_invite_cmd == 1)
            {
                Format(szText, sizeof(szText), "%s\nType !vci to invite other players", szText);
            }
        }
        
        if(!Client_IsAdmin(client) && cvar_vc_hud_show_invites == 1 && cvar_vc_invite_max > 0)
        {
            Format(szText, sizeof(szText), "%s\nYou have %d invites left this map", szText, g_iClientInvites[client]);
        }
        g_iChannelsCount[g_iClientChannel[client]] = ch_count;
        // Send our message
        new Handle:hBuffer = StartMessageOne("KeyHintText", client); 
        BfWriteByte(hBuffer, 1); 
        BfWriteString(hBuffer, szText); 
        EndMessage();
    }
    return Plugin_Continue;
}

stock RefreshClientChannel(client)
{
    if(0 < client <= MaxClients)
    for (new i=1;i<=MaxClients;i++)
    {
        if (IsClientInGame(i))
        {
            if (g_iClientChannel[client] == g_iClientChannel[i])
            {
                if (g_iChannelsTeams[g_iClientChannel[client]])                
                {
                    if (GetClientTeam(client) == GetClientTeam(i))
                    {
                        SetListenOverride(client, i, Listen_Yes);
                        SetListenOverride(i, client, Listen_Yes);
                    }
                    else
                    {
                        SetListenOverride(client, i, Listen_No);
                        SetListenOverride(i, client, Listen_No);
                    }
                }
                else
                {
                    SetListenOverride(client, i, Listen_Yes);
                    SetListenOverride(i, client, Listen_Yes);
                }
            }
            else
            {
                SetListenOverride(client, i, Listen_No);
                SetListenOverride(i, client, Listen_No);
            }
        }
    }
}

SaveSettings(client)
{
    if(0 < client <= MaxClients)
    {
        decl Handle:kv
        decl String:cName[MAX_NAME_LENGTH]
        kv = CreateKeyValues("Settings")
        FileToKeyValues(kv, SavePath);
        GetClientAuthString(client, cName, sizeof(cName))
        KvJumpToKey(kv, cName, true)
        KvSetNum(kv, "channelid", g_iClientChannel[client])
        KvRewind(kv)
        KeyValuesToFile(kv, SavePath)
        CloseHandle(kv)
    }
}

LoadSettings(client)
{
    if(0 < client <= MaxClients)
    {
        decl Handle:kv
        decl String:cName[MAX_NAME_LENGTH]
        kv = CreateKeyValues("Settings")
        FileToKeyValues(kv, SavePath)
        GetClientAuthString(client, cName, sizeof(cName))
        KvJumpToKey(kv, cName, true)
        g_iClientChannel[client] = KvGetNum(kv, "channelid", 0)
        CloseHandle(kv)
    }
}

CreateHudHintTimer(client)
{
    HudHintTimers[client] = CreateTimer(1.0, Timer_UpdateHudHint, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}

KillHudHintTimer(client)
{
    if (HudHintTimers[client] != INVALID_HANDLE)
    {
        KillTimer(HudHintTimers[client]);
        HudHintTimers[client] = INVALID_HANDLE;
    }
}

// Added by StrikerMan780

public SetGameVersion()
{
    new String:gamestr[64];
    GetGameFolderName(gamestr, sizeof(gamestr));
    
    if (!strcmp(gamestr, "cstrike"))
    {
        game = CSTRIKE;
    }
    else if (!strcmp(gamestr, "dod"))
    {
        game = DODS;
    }
    else if (!strcmp(gamestr, "hl2mp"))
    {
        game = HL2DM;
    }
    else if (!strcmp(gamestr, "tf"))
    {
        game = TF2;
    }
    else
    {
        game = UNKNOWN;
    }
}

Last edited by StrikerMan780; 11-02-2011 at 03:29.
StrikerMan780 is offline
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 11-02-2011 , 06:10   Re: [CS:S] VoiceMgr v2.2.2 (Updated 23-07-2011)
Reply With Quote #37

looks like u was faster than me i was on they way doing this today

i will create this plugin as a new thread and will support it from now on

btw thx to your code
__________________
zipcore is offline
StrikerMan780
AlliedModders Donor
Join Date: Jul 2009
Location: Canada
Old 11-11-2011 , 20:45   Re: [CS:S] VoiceMgr v2.2.2 (Updated 23-07-2011)
Reply With Quote #38

Any news?
StrikerMan780 is offline
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 11-11-2011 , 23:17   Re: [CS:S] VoiceMgr v2.2.2 (Updated 23-07-2011)
Reply With Quote #39

sry I'm very busy at the moment

next weeked i will spend some free time to finish what I started up ;)
__________________
zipcore is offline
StrikerMan780
AlliedModders Donor
Join Date: Jul 2009
Location: Canada
Old 11-13-2011 , 01:47   Re: [CS:S] VoiceMgr v2.2.2 (Updated 23-07-2011)
Reply With Quote #40

Ah, good to know that this isn't dead at least.

EDIT: Hello again?

Last edited by StrikerMan780; 11-21-2011 at 13:44.
StrikerMan780 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:56.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode