• Problems with DComboBox and DButton
    4 replies, posted
[lua] function ShowMainMenu() local Background = vgui.Create( "DFrame" ) Background:SetPos( 10,10 ) Background:SetSize( 600, 500 ) Background:SetTitle( "UnderGroundRP" ) Background:SetVisible( true ) Background:SetDraggable( true ) Background:ShowCloseButton( true ) Background:MakePopup() local JobsComboBox = vgui.Create( "DComboBox", Background ) JobsComboBox:SetPos( 50, 85 ) JobsComboBox:SetSize( 100, 185 ) JobsComboBox:SetMultiple( false ) JobsComboBox:AddItem( "Ghetto Kid" ) JobsComboBox:AddItem( "Russian Mafia" ) JobsComboBox:AddItem( "Amarican Mafia" ) JobsComboBox:AddItem( "Mexican Mafia" ) JobsComboBox:AddItem( "Hitman" ) JobsComboBox:AddItem( "Weapons Dealer" ) JobsComboBox:AddItem( "Thief" ) local DermaButton = vgui.Create( "DButton" ) DermaButton:SetParent( Background ) DermaButton:SetText( "Select Job" ) DermaButton:SetPos( 300, 350 ) DermaButton:SetSize( 150, 50 ) DermaButton.DoClick = function () if JobsComboBox:GetSelectedItems()[1] then RunConsoleCommand( "Team_GhettoKid" ) end if JobsComboBox:GetSelectedItems()[2] then RunConsoleCommand( "Team_RussianMafia" ) end end end [/lua] no matter if i select ghetto kid or russian mafia it turns me into ghetto kid.. :( some one plz help me .. :)
[lua]JobsComboBox:GetSelectedItems()[/lua] This returns a table of the selected items. So if you select something, it will always be put into JobsComboBox:GetSelectedItems()[1]. Try something like this: [lua] if JobsComboBox:GetSelectedItems()[1] == "Ghetto Kid" then RunConsoleCommand( "Team_GhettoKid" ) end [/lua]
[lua] function ShowMainMenu() local Background = vgui.Create( "DFrame" ) Background:SetPos( 10,10 ) Background:SetSize( 600, 500 ) Background:SetTitle( "UnderGroundRP" ) Background:SetVisible( true ) Background:SetDraggable( true ) Background:ShowCloseButton( true ) Background:MakePopup() local JobsComboBox = vgui.Create( "DComboBox", Background ) JobsComboBox:SetPos( 50, 85 ) JobsComboBox:SetSize( 100, 185 ) JobsComboBox:SetMultiple( false ) JobsComboBox:AddItem( "Ghetto Kid" ) JobsComboBox:AddItem( "Russian Mafia" ) JobsComboBox:AddItem( "Amarican Mafia" ) JobsComboBox:AddItem( "Mexican Mafia" ) JobsComboBox:AddItem( "Hitman" ) JobsComboBox:AddItem( "Weapons Dealer" ) JobsComboBox:AddItem( "Thief" ) local DermaButton = vgui.Create( "DButton" ) DermaButton:SetParent( Background ) DermaButton:SetText( "Select Job" ) DermaButton:SetPos( 300, 350 ) DermaButton:SetSize( 150, 50 ) DermaButton.DoClick = function () if JobsComboBox:GetSelectedItems()[1] == "Ghetto Kid" then RunConsoleCommand( "Team_GhettoKid" ) end if JobsComboBox:GetSelectedItems()[2] == "Russian Mafia" then RunConsoleCommand( "Team_RussianMafia" ) end end end [/lua] not working, but i know the concommands work, i did test in console.. :) when i select a team and press button nothing happends .. :(
Try this bit (to see what is going on): [lua] DermaButton.DoClick = function () PrintTable(JobsComboBox:GetSelectedItems()) end [/lua] Tell me what it outputs into console.
nothing happends.. :(
Sorry, you need to Log In to post a reply to this thread.