Get other persons playermodel after looking them up..

So I’m not sure the best way to go about this…
What I have now is (in theory) you should be able to look up a player and grab their name and playermodel.

local search = vgui.Create( "DTextEntry", mainpanel )	-- create the form as a child of frame
search:SetPos( 25, 125 )
search:SetSize( 200, 45 )
search:SetText( "Put person's name here" )
search.OnEnter = function( ply )
	-- Where the *find player code goes and grab player model*
Pseudocode attempt:
    check players name == a player on the server
        if player model is good then make model appear along with their info
        elseif then make another derma/box pop up asking if they are spelling the name correctly.

Not sure of the best way to go about making sure the players name is okay and then grab their model. Facepunch has been nice to me today so lets see if the streak keeps going! :slight_smile:

try loopying through all players with player.GetAll() then check if string.lower(search:GetValue()) == string.lower(ply:Nick()). If true the ply:GetModel() would be the Model of the player AS a string. You can display it with a DModelPanel.

[editline]16th February 2016[/editline]

Also, you might want to have a DListView with a search bar. Would be more easy for players to use, because they do not need to know the exact name.

So i’ve done what you said and it somewhat works…

local plylist = vgui.Create("DListView", mainpanel)
plylist:SetPos(10, 300)
plylist:SetSize(200, 125)

local clmColumn1 = plylist:AddColumn("Name")
for k,v in pairs(player.GetAll()) do
    plylist:AddLine(v:Nick()) -- Add lines

plylist.DoDoubleClick = function( checkid )
		DModel = vgui.Create( "DModelPanel", mainpanel)
		DModel:SetSize(250, 250)

local eyepos = DModel.Entity:GetBonePosition( DModel.Entity:LookupBone( "ValveBiped.Bip01_Head1" ) )

		eyepos:Add( Vector( 0, 0, 2 ) )	-- Move up slightly
		DModel:SetLookAt( eyepos )
		DModel:SetCamPos( eyepos-Vector( -12, 0, 0 ) )	-- Move cam in front of eyes
		DModel.Entity:SetEyeTarget( eyepos-Vector( -12, 0, 0 ) )

local name = vgui.Create("DLabel",mainpanel)

		name:SetText("Name: ".. ply:GetName())

local wanted = vgui.Create("DButton", mainpanel)

		wanted:SetPos(10, 400)
		wanted:SetText("Check wanted Status")
		wanted.Paint = function(s,w,h)

Except it gets MY playermodel… not the bots…

It gets your playermodel because that’s exactly what you are telling it to do with this line:


maybe do something like this

local PLList = { }

for k,v in pairs(player.GetAll()) do
plylist:AddLine(v:Nick()) – Add lines
table.Insert( PLList, v )

if ( PLList[ checkid ] ) then
DModel:SetModel( PLList[ checkid ]:GetModel())


Cheers, will try :slight_smile:

Hey so I just got around to testing it… made some major GUI improvements. Except I am getting this error

[ERROR] lua/test:155: attempt to call field 'Insert' (a nil value)
  1. DoClick - lua/test:155
   2. unknown - lua/vgui/dlabel.lua:218

table.insert doesn’t have a capital I

Right except all it does now is

[ERROR] lua/test:161: attempt to index a nil value
  1. DoDoubleClick - lua/test:161
   2. OnClickLine - lua/vgui/dlistview.lua:478
    3. unknown - lua/vgui/dlistview_line.lua:93

drawmodel:SetModel(PLList[ checkid ]:GetModel()) -- Set to selected players model

Because you haven’t set checkid as anything?

its a function

local PLList = {}
	for k,v in pairs(player.GetAll()) do
   		plylist:AddLine(v:Nick()) -- Add lines

		plylist.DoDoubleClick = function (checkid)
			table.insert( PLList, v )
			drawmodel = vgui.Create( "DModelPanel", mainpan2)
			drawmodel:SetModel(PLList[ checkid ]:GetModel()) -- Set to selected players model

Try this instead:

plylist.DoDoubleClick = function(self, checkid)

You might be using the panel as the key rather than the actual line’s ID

Done that now but still returning a nil value. It’s all being ran clientside if that matters