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

Generic Method To Get Team Indexes


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dubbeh
Senior Member
Join Date: Jul 2007
Old 09-15-2016 , 07:40   Generic Method To Get Team Indexes
Reply With Quote #1

Has anyone tried or does it already exist, a generic method to get team indexes?

Was thinking something like:
Code:
    iTeamCount = GetTeamCount();
    g_iSpecIndex = -1;
    g_iUnassignedIndex = -1;
    g_iObserverIndex = -1;
    
    for (i = 0; i < iTeamCount; i++)
    {
        GetTeamName(i, g_szTeamNames[i], sizeof(g_szTeamNames[i]));
        if (StrContains(g_szTeamNames[i], "spect", false) != -1)
            g_iSpecIndex = i;
        else if (StrContains(g_szTeamNames[i], "unass", false) != -1)
            g_iUnassignedIndex = i;
        else if (StrContains(g_szTeamNames[i], "obser", false) != -1)
            g_iObserverIndex = i;
    }


Could potentially work.

Has SourceMod got an inbuilt function or do mods have hardcoded values that can be read through SDKHooks?

Would make it way easier for plugins that require team indexes.
__________________
SM Plugins - dubbeh.net - Plugin requests are welcome
dubbeh is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-15-2016 , 08:21   Re: Generic Method To Get Team Indexes
Reply With Quote #2

https://sm.alliedmods.net/new-api/clients/getclientteam

This return team index.
Not in all games but usually these indexs present
0 = no team
1 = spec
2 = team 1
3 = team 2
__________________
Do not Private Message @me

Last edited by Bacardi; 09-15-2016 at 08:21.
Bacardi is offline
dubbeh
Senior Member
Join Date: Jul 2007
Old 09-15-2016 , 08:33   Re: Generic Method To Get Team Indexes
Reply With Quote #3

Thanks Bacardi, Think i remember something a while back about it only working if mod authors don't change the indexes themselves.
__________________
SM Plugins - dubbeh.net - Plugin requests are welcome
dubbeh is offline
psychonic

BAFFLED
Join Date: May 2008
Old 09-15-2016 , 10:40   Re: Generic Method To Get Team Indexes
Reply With Quote #4

The only game I've seen where 0 and 1 and not unassigned and spectator respectively is Insurgency Mod. (I don't know offhand if the current retail version is like that).

For other teams/games, indexes will start at 2 (FIRST_GAME_TEAM in the SDK) and go through however many teams there are. Most games have 2 (so, indexes 2 and 3).

Pirates, Vikings, and Knights for example has 3 (so there is a team at index 4), and if I remember correctly, Fortress Forever has 4 teams, but which teams are at which index can vary per map (which also happened in Insurgency Mod). Those are all corner cases though.
psychonic is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 09-15-2016 , 11:01   Re: Generic Method To Get Team Indexes
Reply With Quote #5

Quote:
Originally Posted by psychonic View Post
Fortress Forever has 4 teams
I think that's supposed to be Fistful Of Frags (4 playing teams, 1 spectator team, 1 (team 0) FFA team)
https://github.com/MitchDizzle/Custo...rmodels.cfg#L7
Mitchell is offline
dubbeh
Senior Member
Join Date: Jul 2007
Old 09-15-2016 , 12:30   Re: Generic Method To Get Team Indexes
Reply With Quote #6

Thanks for the feedback - Seems like a very small amount of mods don't follow the standard defines and is easy enough to check that.
__________________
SM Plugins - dubbeh.net - Plugin requests are welcome
dubbeh is offline
psychonic

BAFFLED
Join Date: May 2008
Old 09-15-2016 , 13:12   Re: Generic Method To Get Team Indexes
Reply With Quote #7

Quote:
Originally Posted by Mitchell View Post
I think that's supposed to be Fistful Of Frags (4 playing teams, 1 spectator team, 1 (team 0) FFA team)
https://github.com/MitchDizzle/Custo...rmodels.cfg#L7
I was definitely thinking of Fortress Forever with the four teams, but I think I was conflating with something else regarding them changing per map. I think the map just determines how many of the teams are used.

https://github.com/fortressforever/f...rules.cpp#L278

Interesting about FoF though. I haven't play it very much in a while, despite doing (a small) bit of work on the pre-Steam version of the mod.

Last edited by psychonic; 09-15-2016 at 13:14.
psychonic is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 09-15-2016 , 13:27   Re: Generic Method To Get Team Indexes
Reply With Quote #8

Quote:
Originally Posted by psychonic View Post
Interesting about FoF though. I haven't play it very much in a while, despite doing (a small) bit of work on the pre-Steam version of the mod.
It pretty much died after a couple weeks or so.
They only thing that could bring the game back to life is some kind of mixup. cowboys vs aliens would be nice.
Mitchell is offline
Reply


Thread Tools
Display Modes

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:20.


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