Placing all teams in a DListView

Having some trouble in regards to getting all teams, then placing them in a DListView and showing [TEAM NAME] [Number of Players].

Doing some searching around I found the following thread;
While it did get me a step further, I do not wish to list the 3 automatically assigned teams (connecting, unassigned, spectator).

local list = vgui.Create(“DListView”, join_pnl)
list:SetPos(5, 5)
list:SetSize(join_pnl:GetWide() - 10, join_pnl:GetTall() - 75)

for k,v in pairs(team.GetAllTeams()) do
list:AddLine(v.Name, “N/A”)

“N/A” is merely a placeholder due to my inexperience and dumbfounding on getting the corresponding teams number of players.

Any help is appreciated.

Anyone at all able to help?

Wouldn’t this work?

list:AddLine(v.Name, team.NumPlayers(k))

You should probably use Team.GetAllTeams to find the teams then Team.NumPlayers to find the numbers of players in the team.

Simple loop:
for k, i in pairs( team.GetAllTeams() ) do
list.AddLine( i[Name], i.NumPlayers() )

If you don’t want it to display the first three, I’d just remove the first three lines in the list.

Thank you very much Gaming_Unlim, god I’m going to regret these questions in a few months time haha.

Also, how would I go about sorting the 3 default teams that are placed?

  • EDIT: Never mind, just ran a check to see if a team has more then 1 player before showing the list. Thank you again for the help guys.

Sort them by what? Alphabetical order?

Sorry >> just submitted the EDIT, ran a check on if the team has more then 1 player.