1. Post #1
    Zyler's Avatar
    February 2010
    483 Posts




    here's the whole code:
    // Clientside only stuff goes here
    function ShowTeamMenu()
    local DermaPanel = vgui.Create( "DFrame" ) -- Creates the frame itself
    DermaPanel:SetPos( 80,80 ) -- Position on the players screen
    DermaPanel:SetSize( 600, 500 ) -- Size of the frame
    DermaPanel:SetTitle( "Main Menu" ) -- Title of the frame
    DermaPanel:SetVisible( true )
    DermaPanel:SetDraggable( false ) -- Draggable by mouse?
    DermaPanel:ShowCloseButton( true ) -- Show the close button?
    DermaPanel:MakePopup() -- Show the frame
      
    local TestingPanel = vgui.Create( "DPanel", DermaPanel )
    TestingPanel:SetPos( 25, 50 )
    TestingPanel:SetSize( 550, 50 )
    TestingPanel.Paint = function() -- Paint function
        surface.SetDrawColor( 50, 50, 50, 255 ) -- Set our rect color below us; we do this so you can see items added to this panel
        surface.DrawRect( 0, 0, TestingPanel:GetWide(), TestingPanel:GetTall() ) -- Draw the rect
    surface.DrawText( "Message of the Day: Zyler Rocks!" )
    end
      
    local PropertySheet = vgui.Create( "DPropertySheet" )
    PropertySheet:SetParent( DermaPanel )
    PropertySheet:SetPos( 25, 110 )
    PropertySheet:SetSize( 550, 315 )
       
    local Welcome = vgui.Create( "DLabel" )
    Welcome:SetText( "A" )
    Welcome:SetColor(Color(191,255,0,255))
    Welcome:SizeToContents()
       
    local Character = vgui.Create( "DPanel" )
    Character:SetSize( 305, 305 )
    Character.paint = function()
    surface.SetDrawColor(Color(191,255,0,255))
    surface.DrawRect( 0, 0, TestingPanel:GetWide(), TestingPanel:GetTall() )
    surface.DrawText( "Characters" )
    end
      
    local Props = vgui.Create( "DPanel" )
    Props:SetSize( 305, 305 )
    Props.paint = function()
    surface.SetDrawColor(Color(191,255,0,255))
    surface.DrawRect( 0, 0, TestingPanel:GetWide(), TestingPanel:GetTall() )
    surface.DrawText( "Pick props to spawn" )
    end
      
      
    local food = {}
       
            food[1] = "models/props_junk/garbage_milkcarton002a.mdl"
        food[2] = "models/props_junk/PopCan01a.mdl"
        food[3] = "models/props_junk/garbage_takeoutcarton001a.mdl"
        food[4] = "models/props_junk/watermelon01.mdl"
        food[5] = "models/props_junk/garbage_metalcan001a.mdl"
        food[6] = "models/props_lab/box01a.mdl"
        food[7] = "models/props_lab/box01b.mdl"
      
    local Proplist1 = vgui.Create("DCollapsibleCategory", Props)
    Proplist1:SetPos(25, 50)
    Proplist1:SetSize( 450, 50 ) -- Keep the second number at 50
    Proplist1:SetLabel( "Proplist1" )
      
    Proplist1menu = vgui.Create("DModelSelect", Proplist1 )
    Proplist1menu:SetSize( 300, 300 )
    Proplist1menu:SetSpacing( 5 )
    Proplist1menu:EnableHorizontal( true )
    Proplist1menu:EnableVerticalScrollbar( false )
    Proplist1menu:SetPadding( 4 )
      
    for k,v in pairs(food) do
        local icon = vgui.Create( "SpawnIcon", Proplist1menu )
        icon:SetModel( v )
        Proplist1menu:AddItem( icon )
        icon.DoClick = function( icon ) surface.PlaySound( "ui/buttonclickrelease.wav" ) RunConsoleCommand("gm_spawn", v)
    end
    end
    Proplist1:SetContents(Proplist1menu)
    PropertySheet:AddSheet( "Welcome", Welcome, "gui/silkicons/user", false, false, "Rules and stuff" )
    PropertySheet:AddSheet( "Character/Groups", Character, "gui/silkicons/group", false, false, "Manage your character and groups" )
    PropertySheet:AddSheet( "Props/Tools", Props, "gui/silkicons/group", false, false, "Get Props and Tools" )
    
    local groupsnamesasdf = {}
    groupsnamesasdf[1] = "Civil Service"
    groupsnamesasdf[2] = "Government"
    groupsnamesasdf[3] = "Employable"
      
     local groupslist = vgui.Create("DCollapsibleCategory", Character)
    groupslist:SetPos(25, 50)
    groupslist:SetSize( 450, 45 ) -- Keep the second number at 50
    groupslist:SetLabel( "Groups" )
     
    local group1 = vgui.Create("DLabel", groupslist)
    group1:SetPos(20,20)
    group1:SetColor(Color(255,255,255,255))
    group1:SetFont("default")
    group1:SetText(groupsnamesasdf[1])
    group1:SizeToContents()
    
    group1menu = vgui.Create("DModelSelect", groupslist )
    group1menu:SetPos(40, 40)
    group1menu:SetSize( 300, 300 )
    group1menu:SetSpacing( 5 )
    group1menu:EnableHorizontal( true )
    group1menu:EnableVerticalScrollbar( false )
    group1menu:SetPadding( 4 )
     
    for _, pl in pairs( team.GetPlayers( 1 ) ) do -- loop through all the players on TEAM_WHATEVER
     
        local spawnicon = vgui.Create( "SpawnIcon", group1menu )
        spawnicon:SetModel( pl:GetModel() ) -- get their model, set the spawnicon to it
        spawnicon:SetTooltip( pl:Nick() ) -- "little yellow speech bubbles when you move your cursor over them"
        group1menu:AddItem( spawnicon )
         
    end
    end
      
    usermessage.Hook( "call_vgui", ShowTeamMenu )

    the code in question:
    local groupsnamesasdf = {}
    groupsnamesasdf[1] = "Civil Service"
    groupsnamesasdf[2] = "Government"
    groupsnamesasdf[3] = "Employable"
      
     local groupslist = vgui.Create("DCollapsibleCategory", Character)
    groupslist:SetPos(25, 50)
    groupslist:SetSize( 450, 45 ) -- Keep the second number at 50
    groupslist:SetLabel( "Groups" )
     
    local group1 = vgui.Create("DLabel", groupslist)
    group1:SetPos(20,20)
    group1:SetColor(Color(255,255,255,255))
    group1:SetFont("default")
    group1:SetText(groupsnamesasdf[1])
    group1:SizeToContents()
    
    group1menu = vgui.Create("DModelSelect", groupslist )
    group1menu:SetPos(40, 40)
    group1menu:SetSize( 300, 300 )
    group1menu:SetSpacing( 5 )
    group1menu:EnableHorizontal( true )
    group1menu:EnableVerticalScrollbar( false )
    group1menu:SetPadding( 4 )
     
    for _, pl in pairs( team.GetPlayers( 1 ) ) do -- loop through all the players on TEAM_WHATEVER
     
        local spawnicon = vgui.Create( "SpawnIcon", group1menu )
        spawnicon:SetModel( pl:GetModel() ) -- get their model, set the spawnicon to it
        spawnicon:SetTooltip( pl:Nick() ) -- "little yellow speech bubbles when you move your cursor over them"
        group1menu:AddItem( spawnicon )
         
    end
    end

  2. Post #2
    Best Gamemode Ever
    Deadman123's Avatar
    July 2011
    1,603 Posts
    groupslist:SetSize( 450, 45 ) -- Keep the second number at 50
    line 8 of questionable code.
    Durrrr
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Dumb Dumb x 2 (list)

  3. Post #3
    Zyler's Avatar
    February 2010
    483 Posts
    groupslist:SetSize( 450, 45 ) -- Keep the second number at 50
    line 8 of questionable code.
    Durrrr
    That just affects the size of the Collapsible Catorgory before you open it. I've tried changing the value to different things and it makes no difference whether it is set to 50, 45 or even 150, except changing the actual size of the Catorgory before it is opened.

    No matter what size I set it to it still doesn't expand however

  4. Post #4
    Best Gamemode Ever
    Deadman123's Avatar
    July 2011
    1,603 Posts
    Then go to the wiki? lemme look at the code more

    Edit: Is DModelSelect even a Derma control? last time i checked it wasn't, or I at least didnt see it
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Dumb Dumb x 1 (list)

  5. Post #5
    Zyler's Avatar
    February 2010
    483 Posts
    Then go to the wiki? lemme look at the code more

    Edit: Is DModelSelect even a Derma control? last time i checked it wasn't, or I at least didnt see it
    http://wiki.garrysmod.com/?title=DModelSelect

    It's a panel of spawnicons.

  6. Post #6
    Best Gamemode Ever
    Deadman123's Avatar
    July 2011
    1,603 Posts
    I see
    Edit: You could just use Spawnicons and a loop with a .DoClick function, thats the way i always do it and it works

  7. Post #7
    Zyler's Avatar
    February 2010
    483 Posts
    I see
    Edit: You could just use Spawnicons and a loop with a .DoClick function, thats the way i always do it and it works
    Could I have an example?

  8. Post #8
    Best Gamemode Ever
    Deadman123's Avatar
    July 2011
    1,603 Posts
    like
    props = {}
    props[1] = "Models/hurrdurr.mdl"
    props[2] = "Models/hurrdurr2.mdl"
    
    for k,v in pairs(props) do
        icon = vgui.Create("SpawnIcon", <Parent Panel Here>)
        icon:SetModel(v)
        icon.DoClick = function() RunConsoleCommand("gm_spawn"..v)
    end
    

    something along those lines

  9. Post #9
    Zyler's Avatar
    February 2010
    483 Posts
    tried this:
     local groupslist = vgui.Create("DCollapsibleCategory", Character)
    groupslist:SetPos(25, 50)
    groupslist:SetSize( 450, 45 ) -- Keep the second number at 50
    groupslist:SetLabel( "Groups" )
     
    local group1 = vgui.Create("DLabel", groupslist)
    group1:SetPos(20,20)
    group1:SetColor(Color(255,255,255,255))
    group1:SetFont("default")
    group1:SetText(groupsnamesasdf[1])
    group1:SizeToContents()
    
    for _, pl in pairs( team.GetPlayers( 1 ) ) do -- loop through all the players on TEAM_WHATEVER
     
        local spawnicon = vgui.Create( "SpawnIcon", groupslist )
        spawnicon:SetModel( pl:GetModel() ) -- get their model, set the spawnicon to it
        spawnicon:SetTooltip( pl:Nick() ) -- "little yellow speech bubbles when you move your cursor over them"
        group1menu:AddItem( spawnicon )
         
    end

    Didn't work, got this:




    Still doesn't open :(

  10. Post #10
    Best Gamemode Ever
    Deadman123's Avatar
    July 2011
    1,603 Posts
    idk then

  11. Post #11
    Gold Member
    Blasphemy's Avatar
    December 2009
    401 Posts
    You need groupslist:SetContents(group1menu) after your for loop.

  12. Post #12
    Zyler's Avatar
    February 2010
    483 Posts
    You need groupslist:SetContents(group1menu) after your for loop.
    no effect :(.




    I tried both inside (at the end of) and outside the loop:

    // Clientside only stuff goes here
    function ShowTeamMenu()
    local DermaPanel = vgui.Create( "DFrame" ) -- Creates the frame itself
    DermaPanel:SetPos( 80,80 ) -- Position on the players screen
    DermaPanel:SetSize( 600, 500 ) -- Size of the frame
    DermaPanel:SetTitle( "Main Menu" ) -- Title of the frame
    DermaPanel:SetVisible( true )
    DermaPanel:SetDraggable( false ) -- Draggable by mouse?
    DermaPanel:ShowCloseButton( true ) -- Show the close button?
    DermaPanel:MakePopup() -- Show the frame
      
    local TestingPanel = vgui.Create( "DPanel", DermaPanel )
    TestingPanel:SetPos( 25, 50 )
    TestingPanel:SetSize( 550, 50 )
    TestingPanel.Paint = function() -- Paint function
        surface.SetDrawColor( 50, 50, 50, 255 ) -- Set our rect color below us; we do this so you can see items added to this panel
        surface.DrawRect( 0, 0, TestingPanel:GetWide(), TestingPanel:GetTall() ) -- Draw the rect
    surface.DrawText( "Message of the Day: Zyler Rocks!" )
    end
      
    local PropertySheet = vgui.Create( "DPropertySheet" )
    PropertySheet:SetParent( DermaPanel )
    PropertySheet:SetPos( 25, 110 )
    PropertySheet:SetSize( 550, 315 )
       
    local Welcome = vgui.Create( "DLabel" )
    Welcome:SetText( "A" )
    Welcome:SetColor(Color(191,255,0,255))
    Welcome:SizeToContents()
       
    local Character = vgui.Create( "DPanel" )
    Character:SetSize( 305, 305 )
    Character.paint = function()
    surface.SetDrawColor(Color(191,255,0,255))
    surface.DrawRect( 0, 0, TestingPanel:GetWide(), TestingPanel:GetTall() )
    surface.DrawText( "Characters" )
    end
      
    local Props = vgui.Create( "DPanel" )
    Props:SetSize( 305, 305 )
    Props.paint = function()
    surface.SetDrawColor(Color(191,255,0,255))
    surface.DrawRect( 0, 0, TestingPanel:GetWide(), TestingPanel:GetTall() )
    surface.DrawText( "Pick props to spawn" )
    end
      
      
    local food = {}
       
            food[1] = "models/props_junk/garbage_milkcarton002a.mdl"
        food[2] = "models/props_junk/PopCan01a.mdl"
        food[3] = "models/props_junk/garbage_takeoutcarton001a.mdl"
        food[4] = "models/props_junk/watermelon01.mdl"
        food[5] = "models/props_junk/garbage_metalcan001a.mdl"
        food[6] = "models/props_lab/box01a.mdl"
        food[7] = "models/props_lab/box01b.mdl"
      
    local Proplist1 = vgui.Create("DCollapsibleCategory", Props)
    Proplist1:SetPos(25, 50)
    Proplist1:SetSize( 450, 50 ) -- Keep the second number at 50
    Proplist1:SetLabel( "Proplist1" )
      
    Proplist1menu = vgui.Create("DModelSelect", Proplist1 )
    Proplist1menu:SetSize( 300, 300 )
    Proplist1menu:SetSpacing( 5 )
    Proplist1menu:EnableHorizontal( true )
    Proplist1menu:EnableVerticalScrollbar( false )
    Proplist1menu:SetPadding( 4 )
      
    for k,v in pairs(food) do
        local icon = vgui.Create( "SpawnIcon", Proplist1menu )
        icon:SetModel( v )
        Proplist1menu:AddItem( icon )
        icon.DoClick = function( icon ) surface.PlaySound( "ui/buttonclickrelease.wav" ) RunConsoleCommand("gm_spawn", v)
    end
    end
    Proplist1:SetContents(Proplist1menu)
    PropertySheet:AddSheet( "Welcome", Welcome, "gui/silkicons/user", false, false, "Rules and stuff" )
    PropertySheet:AddSheet( "Character/Groups", Character, "gui/silkicons/group", false, false, "Manage your character and groups" )
    PropertySheet:AddSheet( "Props/Tools", Props, "gui/silkicons/group", false, false, "Get Props and Tools" )
    
    local groupsnamesasdf = {}
    groupsnamesasdf[1] = "Civil Service"
    groupsnamesasdf[2] = "Government"
    groupsnamesasdf[3] = "Employable"
      
     local groupslist = vgui.Create("DCollapsibleCategory", Character)
    groupslist:SetPos(25, 50)
    groupslist:SetSize( 450, 45 ) -- Keep the second number at 50
    groupslist:SetLabel( "Groups" )
     
    local group1 = vgui.Create("DLabel", groupslist)
    group1:SetPos(20,20)
    group1:SetColor(Color(255,255,255,255))
    group1:SetFont("default")
    group1:SetText(groupsnamesasdf[1])
    group1:SizeToContents()
    
    for _, pl in pairs( team.GetPlayers( 1 ) ) do -- loop through all the players on TEAM_WHATEVER
     
        local spawnicon = vgui.Create( "SpawnIcon", groupslist )
        spawnicon:SetModel( pl:GetModel() ) -- get their model, set the spawnicon to it
        spawnicon:SetTooltip( pl:Nick() ) -- "little yellow speech bubbles when you move your cursor over them"
        group1menu:AddItem( spawnicon )
    	 
    end
    groupslist:SetContents(group1menu)
    end
      
    usermessage.Hook( "call_vgui", ShowTeamMenu )

  13. Post #13
    Gold Member
    Blasphemy's Avatar
    December 2009
    401 Posts
    http://pastebin.com/v9bHDCsh

    That works perfectly, you changed a lot of stuff around in your newer code when all you needed was to grouplist:SetContents(group1menu) in your old code.

  14. Post #14
    Zyler's Avatar
    February 2010
    483 Posts
    http://pastebin.com/v9bHDCsh

    That works perfectly, you changed a lot of stuff around in your newer code when all you needed was to grouplist:SetContents(group1menu) in your old code.
    works now, but nothing appears in the Collapsed Catorgory:



    Uploaded with ImageShack.us

  15. Post #15
    Gold Member
    Blasphemy's Avatar
    December 2009
    401 Posts
    That would mean there are no players in team 1.

  16. Post #16
    Zyler's Avatar
    February 2010
    483 Posts
    That would mean there are no players in team 1.
    It sets the players team to team 1 in the server code, how would I make a user message that specifies this?

  17. Post #17
    Zyler's Avatar
    February 2010
    483 Posts
    It sets the players team to team 1 in the server code, how would I make a user message that specifies this?
    bump! It doesn't have to be a user message

  18. Post #18
    Gold Member
    Blasphemy's Avatar
    December 2009
    401 Posts
    You don't need a usermessage. There obviously are no players in team 1, change what it's sorting through to player.GetAll() to verify.