• Derma Panel Help
    8 replies, posted
Hey guys.. again, well, I got another problem, I made a little Dermamenu, and theres a error.. GmodHotel/gamemode/cl_init.lua:71: '=' expected near 'end' I have put a = at end, but it doesnt seem to work.. How to fix this? I appreciate a answer very much. -Staneh function testpanel() test = vgui.Create("DFrame") menu1 = vgui.Create("DButton") test:SetPos(50,50) test:SetSize(300, 300) test:SetTitle( "--GmodHotel Menu--" ) test:SetVisible( true ) test:MakePopup() menu1:SetParent( test ) menu1:SetText( "Menu" ) menu1:SetPos(150, 150) menu1:SetSize( 100, 20 ) menu1.DoClick = function ( btn ) menu1:AddOption("Whats my cash?", function() cash_get end ) menu1:Open() end end concommand.Add("menutest", testpanel)
What are you trying to do here? [lua]menu1:AddOption("Whats my cash?", function() cash_get end )[/lua] [editline]06:21PM[/editline] Menu1 is a DButton, you don't add options to buttons...
[QUOTE=MakeR;21250105]What are you trying to do here? [lua]menu1:AddOption("Whats my cash?", function() cash_get end )[/lua] [editline]06:21PM[/editline] Menu1 is a DButton, you don't add options to buttons...[/QUOTE] What i'm trying to do is opening a menu, and theres just one button, click it, and it shows your cash in the chat box.. But I can only make a menu pop up, you need to click a button, then there comes another button, and then u click that, and then your cash shows up.. I was trying around, but I dont know how to do this.. I'm still a noob in lua.. Thanks for replying so fast by the way.. :P Heres the code about that what I just said: [lua] function testpanel() test = vgui.Create("DFrame") menu1 = vgui.Create("DButton") test:SetPos(50,50) test:SetSize(300, 300) test:SetTitle( "Test" ) test:SetVisible( true ) test:MakePopup() menu1:SetParent( test ) menu1:SetText( "Menu >" ) menu1:SetPos(150, 150) menu1:SetSize( 100, 20 ) menu1.DoClick = function ( btn ) local menu123 = DermaMenu() menu123:AddOption("Whats my cash?", function() cash_get end ) menu123:Open() end end concommand.Add("menutest", testpanel) [/lua]
What is cash_get?
[QUOTE=MakeR;21250507]What is cash_get?[/QUOTE] Thats like the command to print the cash you got now to the chat box, its from [lua] function PrintCash( pl ) pl:ChatPrint("Your cash is: " .. pl:GetMoney()) end concommand.Add("cash_get",PrintCash) [/lua] This command works fine though.
You want to do this then: [lua]menu1:AddOption("Whats my cash?", function() RunConsoleCommand("cash_get") end )[/lua]
[QUOTE=MakeR;21250805]You want to do this then: [lua]menu1:AddOption("Whats my cash?", function() RunConsoleCommand("cash_get") end )[/lua][/QUOTE] Thanks, i'll try it now. [editline]07:25PM[/editline] [QUOTE=MakeR;21250805]You want to do this then: [lua]menu1:AddOption("Whats my cash?", function() RunConsoleCommand("cash_get") end )[/lua][/QUOTE] Im getting another error.. which says: GmodHotel/gamemode/cl_init.lua:71: attempt to call method 'AddOption' (a nil value) The button is here, it happens when u press it.
change menu1 to menu123.
[QUOTE=MakeR;21251163]change menu1 to menu123.[/QUOTE] Okay ty, it works.
Sorry, you need to Log In to post a reply to this thread.