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; http://www.facepunch.com/threads/771437
While it did get me a step further, I do not wish to list the 3 automatically assigned teams (connecting, unassigned, spectator).

[lua]
local list = vgui.Create(“DListView”, join_pnl)
list:SetPos(5, 5)
list:SetSize(join_pnl:GetWide() - 10, join_pnl:GetTall() - 75)
list:SetMultiSelect(false)
list:AddColumn(“Team”)
list:AddColumn("##"):SetFixedWidth(30)

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

“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?

[lua]
list:AddLine(v.Name, team.NumPlayers(k))
[/lua]

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

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

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.