DlistView + LocalPlayer():GetWeapons() with table need info about this.

Hi all,

I try to integrate a table from " LocalPlayer():GetWeapons() " into an another table manually made into a
DListView but when I do


Test1 = {  }
for k,v in pairs( LocalPlayer():GetWeapons() ) do

table.insert(Test1, v:GetPrintName())

end

and on later in my file lua




--***********************--
--  <-----   Other Previous code...
--***********************--

DButton.DoClick = function()

-- for k,v in pairs( LocalPlayer():GetWeapons() ) do

-- table.insert(Test1, v:GetClass())


 for k,v in pairs( Test1 ) do		
	  DListNotSpawn:AddLine( k  ) -- Add lines

-- 	  end
end	
-- End of DButton.DoClick = function() --	
end

This one show only



  Weapon    1st Clip     Inf. Ammo?    Spawn?
 --------   --------     ----------   -------
  1          blank        blank        blank
  2
  3
  4
  5
  6
  7...


and no value of weapons stored…
For now I just need printName of the weapon not the other values.

Any idea ?

Can I hook a Table with GetWeapons()
and how to lua_run_cl Print … something
when I do this everything dont print anything.

Thanks

[lua]DListNotSpawn:AddLine( k )[/lua]

Don’t you mean v instead of k?

You need to do sv_allowcslua 1 to allow lua_run_cl and lua_openscript_cl to work.

Thanks it work for all now,
but how to print the name of the weapon on the same way from the label below
I mean the " #HL2_SMG1 " to " SMG "

http://puu.sh/4ngbd.jpg

get the class

wait, no it’s not the class but it’s not what you are doing either.

I tried with GetPrintName() and GetClass() but it’s when I get a value on a Line on a DListview


-- Name Of The Menu InSide DPanel1stOverall --
LbLTitleSelectorSpawn = vgui.Create("DLabel", DPanel1stOverall)
LbLTitleSelectorSpawn:SetPos(16,12) // Position
LbLTitleSelectorSpawn:SetText( "Weapon " .. "Selected : " .. "( " .. "" .. " )"  )
LbLTitleSelectorSpawn:SetSize ( 390 , 20  )
LbLTitleSelectorSpawn:SetColor(Color(200,200,200,255)) // Color
LbLTitleSelectorSpawn:SetFont("SearchFont")



DermaListView = vgui.Create("DListView")
DermaListView:SetParent(DPanel1stOverall)
DermaListView:SetPos(7,90)
DermaListView:SetSize(308, 240)

DermaListView:SetMultiSelect(false)
DermaListView:AddColumn("Weapon"):SetFixedWidth( 90 ); -- Add column
DermaListView:AddColumn("1st Clip"):SetFixedWidth( 46 );
DermaListView:AddColumn("Clip Size"):SetFixedWidth( 45 );
DermaListView:AddColumn("Inf. Ammo ?"):SetFixedWidth( 64 );
DermaListView:AddColumn("Spawn ?"):SetFixedWidth( 63 );		
--DermaListView:SelectItem()
DermaListView.Paint = function()
draw.RoundedBox( 0, 0, 0, DermaListView:GetWide(), DermaListView:GetTall(), Color( 112, 113, 115, 180 ) )
			surface.SetDrawColor( Color(0, 0, 0, 250) )
			surface.DrawOutlinedRect( 0, 0, DermaListView:GetWide(), DermaListView:GetTall() )
		end



 for k,v in pairs( Test1 ) do		

TestR_K = k
TestR_V = v

-- RunConsoleCommand("Say" , TheValue)
	DermaListView:AddLine( TestR_V  ) -- Add lines	

end

 DermaListView.OnClickLine = function(parent, line, isselected)

LbLTitleSelectorSpawn:SetText( "Weapon " .. "Selected : " .. "( " .. TheValue .. " )"  )
TheValue = line:GetValue(1)


end

the problem it’s with " … TheValue … " it’s give me #HL2_SMG1 instead of " SMG "

This should work.

[lua]LbLTitleSelectorSpawn:SetText( "Weapon " … "Selected : " … “( " … language.GetPhrase(TheValue) … " )” )[/lua]

Thanks it’s work (you are very good :smiley: ) , without this I never found that.