Raised This Month: $32 Target: $400
 8% 

[CS:GO] Getting team name


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
decowboy
AlliedModders Donor
Join Date: Oct 2015
Location: Guadalajara, Mexico
Old 02-25-2016 , 16:44   [CS:GO] Getting team name
Reply With Quote #1

If all players in a certain team (either terrorist or counter-terrorist) have the same clan tag, then CS:GO will automatically name that team after the clan.

You can use mp_teamname_1/mp_teamname_2 to override that team name, but if CS:GO selects the team name automatically, then those cvar's will remain empty.

I am looking to obtain the name of a team that was automatically set by CS:GO. In this case the mp_teamname_x cvar's will be empty, so I can't use those.

Is anyone aware of a way to do this?
decowboy is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 02-25-2016 , 16:57   Re: [CS:GO] Getting team name
Reply With Quote #2

Have you tried GetTeamName?
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
decowboy
AlliedModders Donor
Join Date: Oct 2015
Location: Guadalajara, Mexico
Old 02-25-2016 , 17:40   Re: [CS:GO] Getting team name
Reply With Quote #3

Unfortunately, it seems that functions returns either "TERRORIST" OR "COUNTER-TERRORIST" when the team names aren't explicitly set by cvar.
decowboy is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 02-25-2016 , 17:42   Re: [CS:GO] Getting team name
Reply With Quote #4

So what about netprops?
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
decowboy
AlliedModders Donor
Join Date: Oct 2015
Location: Guadalajara, Mexico
Old 02-25-2016 , 19:49   Re: [CS:GO] Getting team name
Reply With Quote #5

Currently I am just looping through all the players in a team to get their clan tag using CS_GetClientClanTag. It works. But I believe this will get me the tag of the steam group, and not it's name. And I believe the teams are named after the steam group name, not after the tag.

So if anyone has a better idea, I would be really interested.

net_props seems like the way to go, but I have no clue where to start.

Last edited by decowboy; 02-25-2016 at 19:49.
decowboy is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 02-25-2016 , 19:54   Re: [CS:GO] Getting team name
Reply With Quote #6

Not sure what you could use (possibly an extension), that takes the id that it gives you and query the actual group name. Taking it a step further from what you are currently doing. Using Steam's API.

If I can better explain or provide an example, I will later.
Maxximou5 is offline
decowboy
AlliedModders Donor
Join Date: Oct 2015
Location: Guadalajara, Mexico
Old 02-26-2016 , 06:57   Re: [CS:GO] Getting team name
Reply With Quote #7

Thanks for chipping in guys.

For anyone stumbling on this thread at a later time, I though I'd post the code I have so far.
This snippet checks whether all non-bots in a team have the same clan tag and if so, it stores that clan tag in a string.

Code:
    int team = CS_TEAM_T; //for example

    char name[65];
    bool found = false;
    bool match = true;
    
    for (int i=1; i<=MaxClients; i++) {
        if (IsClientConnected(i) && IsClientInGame(i) && !IsFakeClient(i)) {
            if (GetClientTeam(i) == team) {
                char newname[65];
                CS_GetClientClanTag(i, newname, sizeof(newname));
                if (newname[0] != EOS) {
                    if (found) {
                        if (!StrEqual(name, newname)) {
                            match = false;
                        }
                    } else {
                        found = true;
                        strcopy(name, sizeof(name), newname);
                    }
                }
            }
        }
    }
    
    if (found && match) {
        // bla bla do something
    }
decowboy is offline
exc4libur
Member
Join Date: Oct 2015
Old 02-29-2016 , 11:33   Re: [CS:GO] Getting team name
Reply With Quote #8

Hello,

i think i have nearly the same problem. Must know the Teamname of a team to know where i must update my score db.
exc4libur is offline
lingzhidiyu
Senior Member
Join Date: Mar 2014
Old 02-29-2016 , 13:09   Re: [CS:GO] Getting team name
Reply With Quote #9

PHP Code:
public void OnPluginStart() {
    
RegConsoleCmd("sm_ptm"Command_PrintTeamName"This is a command"ADMFLAG_ROOT);
}

    
public 
Action Command_PrintTeamName(int clientint args) {
    
int teamIndex_T = -1teamIndex_CT = -1;

    
int index = -1;
    while ((
index FindEntityByClassname(index"cs_team_manager")) != -1) {
        
int teamNum GetEntProp(indexProp_Send"m_iTeamNum");
        if (
teamNum == CS_TEAM_T) {
            
teamIndex_T index;
        } else if (
teamNum == CS_TEAM_CT) {
            
teamIndex_CT index;
        }
    }

    if (
teamIndex_T == -|| teamIndex_CT == -1) {
        
PrintToChatAll("404 not found");
        return;
    }

    
char teamName_T[32];
    
GetEntPropString(teamIndex_TProp_Send"m_szClanTeamname"teamName_T32);
    
char teamName_CT[32];
    
GetEntPropString(teamIndex_CTProp_Send"m_szClanTeamname"teamName_CT32);

    
PrintToChatAll("T: %s"teamName_T);
    
PrintToChatAll("CT: %s"teamName_CT);
    
PrintToChatAll(" \x04Done");

lingzhidiyu is offline
decowboy
AlliedModders Donor
Join Date: Oct 2015
Location: Guadalajara, Mexico
Old 03-02-2016 , 06:33   Re: [CS:GO] Getting team name
Reply With Quote #10

I don't have the time to test that right now, but it looks wonderful!
Thanks!
decowboy 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 07:31.


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