How would I grab a certains players name

I’m curious how would I be able to retrieve a certains player steamid when there row is clicked on dlistview? I know you have to use


Panel.OnClickLine

i’m curious how would I be able to grab just the player name on that row?

So from what I understand you have a player’s name in the list. You would probably want to do.



Panel.OnRowRightClick = function( Panel, line )
    local selection = tostring( Panel:GetLine( line ):GetValue( 1 )) //This is the current line selected string
    
    local menu = DermaMenu()
    menu:AddOption("Copy STEAM:ID to clipboard", function()
        playerSteamID = ""
        for k, ply in pairs(player.GetAll()) do
            if ply:GetName() == selection then
                playerSteamID = ply:SteamID()
            end
           end
    end)
end    


The only issue with this is the fact that if there are 2 of the same player names then you will have the steam id of one of them.

What you might be able to do is set the entity of the player on that list to the second value like this, I am not sure if it would work since I’ve forgotten.



Panel.AddLine("PLAYERNAME", ply)


And then have



Panel.OnRowRightClick = function( Panel, line )
    local ply = tostring( Panel:GetLine( line ):GetValue( 2 )) //I changed get value from 1 to 2
    
    local menu = DermaMenu()
    menu:AddOption("Copy STEAM:ID to clipboard", function()
        playerSteamID = ply:SteamID
    end)
end    


And then you can do whatever with the steam id, but only in the scope.

If you want it to just have one function then do.



Panel.OnClickLine= function( Panel, line )
    local ply = tostring( Panel:GetLine( line ):GetValue( 2 ))
    playerSteamID = ply:SteamID
end    


DListView:AddLine returns the control for the added line, so you could just do this:


line = list:AddLine( "..." )
line.Player = this guy

Then it’s pretty simple:



function list:OnClickLine( line, clear )
  if IsValid( line.Player ) then
    x = line.Player:SteamID( )
    ...
  end
end