DComboBox like DMultiChoice

Hi,



local MainCheckbox = vgui.Create('DComboBox', MainFrame)
MainCheckbox:SetSize(221, 221)
MainCheckbox:SetPos(89, 48)
MainCheckbox:CenterHorizontal( )

	local Players = player.GetAll()
		for i = 1, table.Count(Players) do
			local plyb = Players*
			MainCheckbox:AddItem( plyb:Nick() )
		end 

function MainCheckbox:Think()
	if (MainCheckbox:GetSelectedItems() and MainCheckbox:GetSelectedItems()[1]) then
		if (MainCheckbox:GetSelectedItems()[1]:GetValue() ~= LastValue) then
			local Players = player.GetAll()
							for i = 1, table.Count(Players) do
								local ply = Players*
								if (MainCheckbox:GetSelectedItems() and MainCheckbox:GetSelectedItems()[1]) then						
									if (ply:Nick() == MainCheckbox:GetSelectedItems()[1]:GetValue()) then
										w,d,h,m,s = timeToStrInd( ply:GetUTime() + CurTime() - ply:GetUTimeStart() )
										CheckWeek:SetValue(w)
										CheckDay:SetValue(d)
										CheckHours:SetValue(h)
										CheckMinutes:SetValue(m)
										CheckSeconds:SetValue(s)
										LastValue = ply:Nick()
									end
								end
							end	
		end
	end
end --function end


Needs to work like DMultiChoice. So if [A] Show me how to fix this or direct me to a wiki or site that could help me, ** Just do it for me, because your a cool, or [C] other, ect

Also, if you need the more of the code to see a “vitual effect” of what I’m trying to do, I’ll be happy to show you the whole script.

This is pseudo-code, but it explains how you’d go about doing it:

[lua]local Players = player.GetAll()
for i = 1, #Players do
local plyb = Players*
MainCheckbox:AddChoice( plyb:Nick() )
end

local LastValue
function MainCheckbox:OnSelect(index, val, data)
if val == LastValue then return end
local pl = player.GetAll()
for i = 1, #pl do
local ply = pl*
if ply:Nick() == val then
//Your code for the selected player here.

		LastValue = val
	end
end

end[/lua]

index is the position in the list of the selected item, val is the item text, and data is the additional (unseen) value for each item you can include as a second argument in AddChoice. If you need further information, have a look at the VGUI/Derma sections on the wiki or old wiki.