• Error Closing my derma frame.
    2 replies, posted
I'm still fairly new to lua but have mad e aworking spawn menu with switch to tool gun etc. I wanted to add self closing so when u release Q it goes away.. i'm getting the error : ERROR: GAMEMODE:'OnSpawnMenuClose' Failed: vgui/dframe.lua:79: attempt to call method 'SetVisible' (a nil value) My code is: [lua] function proplist() print ("List Opening") local props = {} props[1] = "models/props_lab/blastdoor001b.mdl" props[2] = "models/props_lab/blastdoor001a.mdl" props[3] = "models/props_junk/wood_crate002a.mdl" props[4] = "models/props_junk/wood_crate001a.mdl" props[5] = "models/props_wasteland/barricade001a.mdl" props[6] = "models/props_wasteland/wood_fence01a.mdl" props[7] = "models/props_c17/furnitureStove001a.mdl" props[8] = "models/props_c17/FurnitureSink001a.mdl" props[9] = "models/props_c17/fence03a.mdl" props[10] = "models/props_c17/fence01a.mdl" props[11] = "models/props_c17/FurnitureChair001a.mdl" props[12] = "models/props_junk/watermelon01.mdl" props[13] = "models/props_junk/TrafficCone001a.mdl" props[14] = "models/props_interiors/VendingMachineSoda01a.mdl" props[15] = "models/props_interiors/VendingMachineSoda01a_door.mdl" props[16] = "models/props_interiors/Furniture_shelf01a.mdl" props[17] = "models/props_vehicles/wagon001a_phy.mdl" props[18] = "models/props_phx/construct/metal_plate1.mdl" props[19] = "models/props_phx/construct/metal_plate1x2.mdl" props[20] = "models/props_phx/construct/metal_plate2x2.mdl" props[21] = "models/props_phx/construct/metal_plate4x4.mdl" props[22] = "models/props_phx/construct/metal_plate2x4.mdl" props[23] = "models/props_phx/construct/glass/glass_plate4x4.mdl" props[24] = "models/props_phx/construct/glass/glass_plate2x4.mdl" props[25] = "models/props_phx/construct/glass/glass_plate2x2.mdl" props[26] = "models/props_phx/construct/glass/glass_plate1x2.mdl" props[27] = "models/props_phx/construct/glass/glass_plate1x1.mdl" local slframe = vgui.Create("DFrame") local IconList = vgui.Create("DPanelList", slframe) slframe:Center() slframe:SetSize(800,400) slframe:SetTitle("Prop Catalog") slframe:SetPos(500, 500) slframe:MakePopup() IconList:EnableVerticalScrollbar( true ) IconList:EnableHorizontal( true ) IconList:SetPadding( 5 ) IconList:SetPos(10,30) IconList:SetSize(200,350) local weldb = vgui.Create("DButton", slframe) weldb:SetSize(100, 25) weldb:SetPos(250, 30) weldb:SetText("Weld") weldb.DoClick = function() LocalPlayer():ConCommand("gmod_toolmode weld") LocalPlayer():ConCommand( "use gmod_tool") end local bsb = vgui.Create("DButton", slframe) bsb:SetSize(100, 25) bsb:SetPos(400, 30) bsb:SetText("Ballsocket") bsb.DoClick = function() LocalPlayer():ConCommand("gmod_toolmode ballsocket") LocalPlayer():ConCommand( "use gmod_tool") end for k,v in pairs(props) do local icon = vgui.Create( "SpawnIcon", IconList ) icon:SetModel( v ) IconList:AddItem( icon ) icon.DoClick = function( icon ) surface.PlaySound( "ui/buttonclickrelease.wav" ) RunConsoleCommand("gm_spawn", v) end end end concommand.Add("slist", proplist) function GM:OnSpawnMenuOpen() LocalPlayer():ConCommand("slist") end function GM:OnSpawnMenuClose() DFrame:Close(slframe) end [/lua]
You need to move the slframe to a global file scope, not inside the proplist() function. Once its outside of that function, close your DFrame with [b]slframe:Close()[/b] [editline]09:48AM[/editline] There's so many other things you're doing wrong, but lets start with that first.
Yes thanks thats cool now, im droping this project due to my other one.
Sorry, you need to Log In to post a reply to this thread.