• Pressing use on an entity opens multiple derma menus instead of one
    6 replies, posted
Pressing use on the entity should only open one derma menu, but it's opening like five. cl_init: [lua] function MoneyPrinterSettings() local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetPos( 100,100 ) DermaPanel:SetSize( 500, 700 ) DermaPanel:SetTitle( "Money Printer" ) DermaPanel:SetVisible( true ) DermaPanel:SetDraggable( true ) DermaPanel:ShowCloseButton( true ) DermaPanel:MakePopup() local DermaListView = vgui.Create("DListView") DermaListView:SetParent(DermaPanel) DermaListView:SetPos(25, 50) DermaListView:SetSize(450, 625) DermaListView:SetMultiSelect(false) DermaListView:AddColumn("Name") end usermessage.Hook("MoneyPrinterSettings", MoneyPrinterSettings) [/lua] init: [lua] function ENT:AcceptInput( Name, Caller ) if Name == "Use" and Caller:IsPlayer() then umsg.Start("MoneyPrinterSettings", Caller) umsg.End() end end [/lua] [img]http://i.imgur.com/fCMxpKW.jpg?1[/img]
That might be running continuously while use is held down, try ENT:Use instead
If you want it to only open one menu per press, the use type needs to be set to SIMPLE_USE. Use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetUseType]Entity:SetUseType[/url] to, well, set the use type. Use this in conjunction with what Niandra said.
Use a variable. Use a variable! This is a common errors! [CODE]function ENT:AcceptInput( Name, Caller ) if Caller.is_in_menu == nil then Caller.is_in_menu=false end if Name == "Use" and Caller:IsPlayer() then if !Caller.is_in_menu then --umsg.Start("MoneyPrinterSettings", Caller) --umsg.End() --Usermessage are deprecated. net.Start("MoneyPrinterSettings") net.Send(Caller) end end end[/CODE] [CODE]function MoneyPrinterSettings() local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetPos( 100,100 ) DermaPanel:SetSize( 500, 700 ) DermaPanel:SetTitle( "Money Printer" ) DermaPanel:SetVisible( true ) DermaPanel:SetDraggable( true ) DermaPanel:ShowCloseButton( true ) DermaPanel:MakePopup() local DermaListView = vgui.Create("DListView") DermaListView:SetParent(DermaPanel) DermaListView:SetPos(25, 50) DermaListView:SetSize(450, 625) DermaListView:SetMultiSelect(false) DermaListView:AddColumn("Name") end net.Receive("MoneyPrinterSettings",function() MoneyPrinterSettings() end)[/CODE]
[QUOTE=Gedo789;48810351]Use a variable. Use a variable! This is a common errors! [CODE]function ENT:AcceptInput( Name, Caller ) if Caller.is_in_menu == nil then Caller.is_in_menu=false end if Name == "Use" and Caller:IsPlayer() then if !Caller.is_in_menu then --umsg.Start("MoneyPrinterSettings", Caller) --umsg.End() --Usermessage are deprecated. net.Start("MoneyPrinterSettings") net.Send(Caller) end end end[/CODE] [/QUOTE] Where did you get "Caller.is_in_menu" from?
[QUOTE=AK to Spray;48810332]If you want it to only open one menu per press, the use type needs to be set to SIMPLE_USE. Use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetUseType]Entity:SetUseType[/url] to, well, set the use type. Use this in conjunction with what Niandra said.[/QUOTE] This is being your problem. You have to set the use type to SIMPLE_USE for that to only be exed once [editline]2nd October 2015[/editline] [QUOTE=Gedo789;48810351]Use a variable. Use a variable! This is a common errors! [CODE]function ENT:AcceptInput( Name, Caller ) if Caller.is_in_menu == nil then Caller.is_in_menu=false end if Name == "Use" and Caller:IsPlayer() then if !Caller.is_in_menu then --umsg.Start("MoneyPrinterSettings", Caller) --umsg.End() --Usermessage are deprecated. net.Start("MoneyPrinterSettings") net.Send(Caller) end end end[/CODE] [CODE]function MoneyPrinterSettings() local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetPos( 100,100 ) DermaPanel:SetSize( 500, 700 ) DermaPanel:SetTitle( "Money Printer" ) DermaPanel:SetVisible( true ) DermaPanel:SetDraggable( true ) DermaPanel:ShowCloseButton( true ) DermaPanel:MakePopup() local DermaListView = vgui.Create("DListView") DermaListView:SetParent(DermaPanel) DermaListView:SetPos(25, 50) DermaListView:SetSize(450, 625) DermaListView:SetMultiSelect(false) DermaListView:AddColumn("Name") end net.Receive("MoneyPrinterSettings",function() MoneyPrinterSettings() end)[/CODE][/QUOTE] What the fuck?
Alright, thank you all for your help. It's working now!
Sorry, you need to Log In to post a reply to this thread.