• Garry's Mod - DComboBox read Data from Table
    0 replies, posted
Hello, I don't have the best lua knowledge but I've been giving this a shot for a few hours and still have yet to figure it out. Goal: To have a DComboBox create choices from a table and set the name, model, and filename of that choice. [CODE] PComboBox = vgui.Create( "DComboBox", s) PComboBox:SetPos( 650, 450 ) PComboBox:SetSize( 150, 20 ) PComboBox:SetValue( "Primary Weapons" ) for _, v in pairs( WL.Weapons ) do local weaponname = v.Name local weaponmodel = v.Model if v.Class == "primary" then PComboBox:AddChoice(weaponname, weaponname, true) else PComboBox:AddChoice(weaponname, weaponname, false) end PComboBox.OnSelect = function() surface.PlaySound( "buttons/button14.wav" ) pmdl:SetModel(weaponmodel or "models/weapons/v_rif_ak47.mdl") end end[/CODE]
Sorry, you need to Log In to post a reply to this thread.