Search code examples
luagarrys-mod

Using "\n" in Garry's Mod draw.DrawText


I want to make an admin-online list. I have the v:Nick() part down but I want to place a new line after it.

Example: (At the top right corner, the names are INSIDE OF EACH OTHER.)


Solution

  • I'm not sure how to go about it, I'm not a VGUI kind of guy, but I believe I have found a solution. You could make a transparent panel with a DListView like this:

    local DermaPanel = vgui.Create( "DFrame" )
    DermaPanel:SetPos( 50,50 )
    
    DermaPanel:SetSize( 500, 700 )
    DermaPanel:SetTitle( "Admins online" )
    DermaPanel:SetVisible( false )
    DermaPanel:SetDraggable( false )
    DermaPanel:ShowCloseButton( false )
    DermaPanel:MakePopup()
    
    local DermaListView = vgui.Create("DListView")
    DermaListView:SetParent(DermaPanel)
    DermaListView:SetPos(25, 50)
    DermaListView:SetSize(450, 625)
    DermaListView:SetMultiSelect(false)
    DermaListView:AddColumn("Name") -- Add column
    DermaListView:AddColumn("Rank")
    
    for k,v in pairs(ply:GetUserGroup() == "admin" or "superadmin" or "owner") do
        DermaListView:AddLine(v:Nick(),v:GetUserGroup()) -- Add lines
    end
    

    Now all you have to do is a little ScrW() and ScrH() for re-sizing and you should be good to go! Also, I got this code from https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexe102.html so I could save time, I would really recommend checking it out if you have a chance!

    Hope I could help, Birdboat