Lua Player Lists

Hello all :slight_smile: Iā€™m wanting for create a DermaMenu with a list of all players on my server but i have no idea for create it.

I have an image of what i want. If someone can give me some help I say yes :slight_smile:

Sorry for my english Iā€™m french and I try to learn LUA.

http://image.noelshack.com/fichiers/2017/01/1483477502-2017-01-03-220401.png

For what i want that ?
Because i want put someone in a special Job when i click on his name :slight_smile:

Try something like:


for k, v in pairs(player.GetAll()) do
    v:addsheet(v:Nick(), self)
end

Or something along those lines.

Thank You Very Much

Now i want create the fonction for Switch the Target name in the Cop Team (Team_Police).

I have create



function Menu()
menu = vgui.Create( "DMenu", frame1 )
menu:SetPos(310,170)
local menu1 = menu:AddOption( "Cops" ) 
menu1:SetIcon( "icon16/award_star_bronze_1.png" )
menu1.DoClick = function()
--I search this function :-(
end
end


But i search the function of the DoClick for switch the player in a team

Complete code:



surface.CreateFont( "f4", {
font = "DermaLarge",
size = 22,
weight = 1000,
blursize = 0,
scanlines = 0,
antialias = true,
underline = false,
italic = false,
strikeout = false,
symbol = false,
rotary = false,
shadow = false,
additive = false,
outline = false,
} )

hook.Add( "OnPlayerChat", "OpenCMD", function( ply, text )
	
	if (string.sub(text, 1, 6) == "!chefp") && ply == LocalPlayer() then 

local PlayerJob = team.GetName(LocalPlayer():Team())
local PlayerRank = (LocalPlayer():GetUserGroup() )

local DRFrame = vgui.Create( "DFrame" )
DRFrame:SetSize( 420, 520 )
DRFrame:Center()
DRFrame:MakePopup()
DRFrame:GetIsMenu()
DRFrame:SetDraggable( false )
DRFrame:SetTitle( "" )
DRFrame.Paint = function()
surface.SetDrawColor( 50, 50, 50, 255 ) 
	surface.DrawRect( 0, 0, DRFrame:GetWide(), DRFrame:GetTall() )
	surface.SetDrawColor( 0, 0, 0, 255 ) 
	surface.DrawOutlinedRect( 0, 0, DRFrame:GetWide(), DRFrame:GetTall() )
end

local llist = vgui.Create("DListView", DRFrame)
	llist:SetPos(3, 24 + 3)
	llist:SetSize(DRFrame:GetWide() - 6, DRFrame:GetTall() - 24 - 6 - 30)
	llist:SetMultiSelect(false)
	llist:AddColumn("RolePlay Name")
	llist:AddColumn("Job")
	llist:AddColumn("Player Rank")
	llist.Columns[1]:SetWidth(200)
	llist.Columns[2]:SetWidth(llist:GetWide()-llist.Columns[1]:GetWide())
	llist.Columns[3]:SetWidth(llist:GetWide()-llist.Columns[2]:GetWide())
	
for k, v in pairs(player.GetAll() ) do
    llist:AddLine(v:Nick(),PlayerJob, PlayerRank)
end

function Menu()
menu = vgui.Create( "DMenu", frame1 )
menu:SetPos(310,170)
local menu1 = menu:AddOption( "Cops" ) 
menu1:SetIcon( "icon16/award_star_bronze_1.png" )
menu1.DoClick = function()
--I search this function :-(
end
end

label = vgui.Create("DLabel", DRFrame)
label:SetPos(160,2)
label:SetText("Police Menu")
label:SetFont("f4")
label:SizeToContents()
label:SetTextColor( Color(158, 158, 158))

function llist:DoDoubleClick( lineID, line, ply)
 		Menu()
end

		return true 
	end
	
end )


http://image.noelshack.com/fichiers/2017/01/1483559358-20170104203945-1.jpg