DPanelList - Help pls

[LUA]

Menu3 = vgui.Create(“DPanelList”)
Menu3:SetSize(ScrW() / 2-15,ScrH() / 2-50)
Menu3:SetSpacing(5)
Menu3:EnableHorizontal( false )
Menu3:EnableVerticalScrollbar( true )

function Inventory_List(k, v)

print(k…" Value : "…v)

Inventory.k = vgui.Create (“DLabel”)
Inventory.k:SetText("Item : “…k…” Value : "…v)
Inventory.k:SizeToContents()
Menu3:AddItem( Inventory.k )

end

function Inventory_Setup( cucc, id, inv, inventory )

Inventory = {}
table.foreach( inventory, Inventory_List )

end

datastream.Hook(“cucc”,Inventory_Setup)

[/LUA]

Got this error message:

attempt to call method ‘AddItem’ (a nil value)

Any idea?

[editline]25th October 2010[/editline]

Print work well

Inventory = {}
table.foreach( inventory, Inventory_List )

Capitalization error. Might not be the problem though.

I don’t think so, but I can try it

[editline]26th October 2010[/editline]

Still the same

Would you please post your full code? Makes it easier to actually know if your even making the derma panel

Edit:

This should work…
[lua]local Menu3 = vgui.Create ( “DPanelList” )
Menu3:SetSize(ScrW() / 2-15, ScrH() / 2-50)
Menu3:SetSpacing(5)
Menu3:EnableHorizontal( false )
Menu3:EnableVerticalScrollbar( true )

function Inventory_list (k, v)

print(k…" Value : "…v)

local InventoryList = vgui.Create( “DLabel” )
InventoryList:SetText("Item : “…k…” Value : "…v)
InventoryList:SizeToContents()
Menu3:AddItem(InventoryList)

end

function Inventory_Setup ( cucc, id, inv, inventory )

Inventory = {}
table.foreach( inventory, Inventory_list )

end

datastream.Hook(“cucc”, Inventory_Setup)
[/lua]

Not entirely sure but this should do the trick.

Still the same error message :S

[editline]26th October 2010[/editline]

[LUA]
function main_menu()

Mainmenu = vgui.Create(“DFrame”)
Mainmenu:SetPos(ScrW() / 4,ScrH() / 4)
Mainmenu:SetSize(ScrW() / 2, ScrH() / 2)
Mainmenu:SetTitle(“Main Menu”)
Mainmenu:SetDraggable(true)
Mainmenu:ShowCloseButton(true)
Mainmenu:SetVisible(true)
Mainmenu:MakePopup()

Menu1 = vgui.Create(“DPanel”)
Menu1:SetSize(ScrW() / 2-15,ScrH() / 2-50)

Menu2 = vgui.Create(“DPanel”)
Menu2:SetSize(ScrW() / 2-15,ScrH() / 2-50)

local Menu3 = vgui.Create ( “DPanelList” )
Menu3:SetSize(ScrW() / 2-15, ScrH() / 2-50)
Menu3:SetSpacing(5)
Menu3:EnableHorizontal( false )
Menu3:EnableVerticalScrollbar( true )

function Inventory_list (k, v)

print(k…" Value : "…v)

local InventoryList = vgui.Create( “DLabel” )
InventoryList:SetText("Item : “…k…” Value : "…v)
InventoryList:SizeToContents()
Menu3:AddItem(InventoryList)

end

function Inventory_Setup ( cucc, id, inv, inventory )

Inventory = {}
table.foreach( inventory, Inventory_list )

end

datastream.Hook(“cucc”, Inventory_Setup)
[/LUA]

[editline]26th October 2010[/editline]

Here is the important part of the lua

[editline]26th October 2010[/editline]

The whole file is 250 rows :smiley:

Hmm… Not really sure but… [lua] InventoryList:SetParent(Menu3)[/lua] should work too…

Still the same :’(((((((((((

Did you replace it with AddItem…?

no

[editline]26th October 2010[/editline]

I try it, wait

[editline]26th October 2010[/editline]

No error message but doesn’t work xd :S

[editline]26th October 2010[/editline]

AddItem is important for DPanelList

Hmm… You sure there arent any errors?

Yep

[editline]26th October 2010[/editline]

something is bad with the loop [with AddItem] :S, because if I add just one item, it works

More info please, is the panel list even showing up?

Also… What are you trying to make? A Spawnicon?

wait, show xfire live xD

[editline]26th October 2010[/editline]

<object width=“640” height=“505”><param name=“allowScriptAccess” value=“always” /><param name=“flashvars” value=“autoPlay=true&channel=xfire_runamagic&embed=true” /><embed src=“http://media.xfire.com/swf/livevideoplayer.swf” type=“application/x-shockwave-flash” allowscriptaccess=“always” allowfullscreen=“true” width=“640” height=“505” flashvars=“autoPlay=true&channel=xfire_runamagic&embed=true”></embed></object>

[editline]26th October 2010[/editline]

Oh, bad, then I give link

do [media]

LIVE xD

Still loading… You sure your vid is working…?

ye

[editline]26th October 2010[/editline]

my friend watching it

[editline]26th October 2010[/editline]

reload the page

[editline]26th October 2010[/editline]

any idea? xD

[editline]26th October 2010[/editline]

Watch now

[editline]26th October 2010[/editline]

New - Still the same problem :S
[LUA]

local Menu3 = vgui.Create(“DPanelList”)
Menu3:SetSize(ScrW() / 2-15, ScrH() / 2-50)
Menu3:SetSpacing(5)
Menu3:EnableHorizontal( false )
Menu3:EnableVerticalScrollbar( true )

function Inventory_Setup ( cucc, id, inv, inventory )

for k,v in pairs(inventory) do

local Panel1 = vgui.Create('DPanel')
Panel1:SetSize(200,50)

local Name = vgui.Create("DLabel", Panel1)
Name:SetPos(5,5)
Name:SetText("Item : "..k )
Name:SizeToContents()

local Value = vgui.Create("DLabel", Panel1)
Value:SetPos(5,25)
Value:SetText("Value : "..v)
Value:SizeToContents()

Menu3:AddItem(Panel1)

end

end

datastream.Hook(“cucc”, Inventory_Setup)
[/LUA]

I have fixed it.

AddItem takes a value not a key.