AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [CS:GO] Getting team name (https://forums.alliedmods.net/showthread.php?t=279588)

decowboy 02-25-2016 16:44

[CS:GO] Getting team name
 
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?

KissLick 02-25-2016 16:57

Re: [CS:GO] Getting team name
 
Have you tried GetTeamName?

decowboy 02-25-2016 17:40

Re: [CS:GO] Getting team name
 
Unfortunately, it seems that functions returns either "TERRORIST" OR "COUNTER-TERRORIST" when the team names aren't explicitly set by cvar.

KissLick 02-25-2016 17:42

Re: [CS:GO] Getting team name
 
So what about netprops?

decowboy 02-25-2016 19:49

Re: [CS:GO] Getting team name
 
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.

Maxximou5 02-25-2016 19:54

Re: [CS:GO] Getting team name
 
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.

decowboy 02-26-2016 06:57

Re: [CS:GO] Getting team name
 
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
    }


exc4libur 02-29-2016 11:33

Re: [CS:GO] Getting team name
 
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.

lingzhidiyu 02-29-2016 13:09

Re: [CS:GO] Getting team name
 
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");



decowboy 03-02-2016 06:33

Re: [CS:GO] Getting team name
 
I don't have the time to test that right now, but it looks wonderful!
Thanks!


All times are GMT -4. The time now is 10:19.

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