• I need help with closing a dermapanel without DoClick (NEWBIE LUA CODER)
    10 replies, posted
Hi guys im a extremely new lua coder, and I need help with some of my code. My issue is that im trying to currently create a dermapanel overlay after you click a button in a derma panel. I created the dermapanel yet I cannot seem to remove the dermapanel in other means. I would like to know how I can remove it by either waiting a certain period in time, or if the player is arrested or killed. If you can help me please explain to me and im a noob and would like to learn lol. Here is my code for examining. local DermaButton = vgui.Create("DButton" , DermaPanel)         DermaButton:SetText( "StartTEST" )         DermaButton:SetPos( 200, 100 )         DermaButton:SetSize( 100, 50 )         DermaButton:SetColor(Color(255,0,0))         DermaButton.DoClick = function()         local timeElapsed = CurTime() - lastOccurance         DermaPanel:Remove()         if timeElapsed < delay then         Started = 2         chat.AddText( Color( 100, 100, 255 ), "TEST", Color( 255, 255, 255 ), " You must wait ".. math.Round (timeElapsed - delay).. " seconds!")     else         net.Start("Start")         net.SendToServer()         gui.EnableScreenClicker(false)     net.Start("OverlayHud")         net.SendToServer()         local DermaPanell = vgui.Create('DFrame')     DermaPanell:SetSize(400, 50)     DermaPanell:SetPos(600,10)     DermaPanell:SetTitle("TEMP TEXT")     DermaPanell:ShowCloseButton(false)     DermaPanell:SetVisible(true)     DermaPanell:SetDraggable(false)     lastOccurance = CurTime()     if Started == 2 then      DermaPanell:SetVisible(false) ---- I also tried DermaPanell:Remove() but that did not seem to work either.     end end
Please at least glance at this page Category
DFrame/Close
I replaced "DermaPanell:SetVisible()" with "DermaPanell:Close()" and still it doesnt remove.
bump, issue still not fixed.
DermaPanell:Remove()
ive tried that aswell and it still doesnt work.
Okay, so I actually looked at your code and it'll never do what you want. You need to use a timer or a think hook in order to make the overlay go away after a set time. Right now none of that is happening. Something like this: local DermaButton = vgui.Create("DButton" , DermaPanel) DermaButton:SetText( "StartTEST" ) DermaButton:SetPos( 200, 100 ) DermaButton:SetSize( 100, 50 ) DermaButton:SetColor(Color(255,0,0)) DermaButton.DoClick = function() local timeElapsed = CurTime() - lastOccurance DermaPanel:Remove() if timeElapsed < delay then Started = 2 chat.AddText( Color( 100, 100, 255 ), "TEST", Color( 255, 255, 255 ), " You must wait ".. math.Round (timeElapsed - delay).. " seconds!") else net.Start("Start") net.SendToServer() gui.EnableScreenClicker(false) net.Start("OverlayHud") net.SendToServer() local DermaPanell = vgui.Create('DFrame') DermaPanell:SetSize(400, 50) DermaPanell:SetPos(600,10) DermaPanell:SetTitle("TEMP TEXT") DermaPanell:ShowCloseButton(false) DermaPanell:SetVisible(true) DermaPanell:SetDraggable(false) timer.Simple(2, function() DermaPanell:Remove() end) end end
thank you so much, this fixed my issue and I looked into timers. Very appreciated
you think theres anyway I can keep the timer, but also add a function to check if the ply:isArrested or dead then also remove the derma?
You'd need to do that in a think hook or by overriding the panel's think function, but yes
Sorry, you need to Log In to post a reply to this thread.