• Print

Author Topic: Derma Refuses to Work.. Again  (Read 4251 times)

0 Members and 1 Guest are viewing this topic.

Offline OpticPotatOS

  • Jr. Member
  • **
  • Posts: 53
  • Karma: 0
  • GLaDOS
    • Gaming for Everyone
Derma Refuses to Work.. Again
« on: June 24, 2016, 11:49:28 am »
So, the couple  topics I've put here have mostly been about some code I'm trying to get to work, and then I hit one problem I can't fix at all. So, when I run my command, other than my bad positioning of the derma, it works. Except, the button I added to make it close doesn't work, it just doesn't do it's job. No errors, it just doesn't work.

My code:

Code: Lua
  1. function WarnDerma( sv_reason ) --Creating the derma function to be recieved by clientRPC
  2.   local DFrame = vgui.Create( "DFrame" ) --Create the Derma frame
  3.         DFrame:Center()
  4.         DFrame:SetSize( 700, 400 )
  5.         DFrame:SetTitle( "Warning: #A", sv_reason )
  6.         DFrame:SetVisible( true )
  7.         DFrame:SetDraggable( false )
  8.         DFrame:ShowCloseButton( false ) --So a clever person doesn't just click it away immediately
  9.         DFrame:MakePopup()
  10.         local richtext = vgui.Create( "RichText", DFrame )
  11.         richtext:Dock( FILL ) --No idea what this does, but Garry uses it in the documentation, so better use it
  12.         richtext:InsertColorChange( 192, 192, 192, 255 )
  13.         richtext:AppendText( sv_reason ) --Displays the warning reason
  14.         local DButton = vgui.Create( "DButton", DFrame )
  15.   DButton:SetText( "OK" )
  16.   DButton:SetTextColor( Color( 255, 255, 255 ) )
  17.         DButton:Center()
  18.         DButton:SetSize( 100, 30 )
  19.         DButton:SetEnabled( true )
  20.         if DButton:IsDown() then DFrame:Close() end
  21. end
  22.  

Anyone know why this wouldn't work?
My website isn't my website, rather, it's the gaming network my sever is connected to.

ttt.gfe.nu

Unforeseen Consequences

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Derma Refuses to Work.. Again
« Reply #1 on: June 24, 2016, 11:56:45 am »
Code: Lua
  1. DButton.DoClick = function()
  2.  
  3.   DFrame:Close()
  4.  
  5. end


IsDown() only checks if the button is currently being held down by a player.. to constantly check you'd need a "Think" hook (I believe) but to close a panel, just use the DoClick function. It's not on the wiki for DButton for some reason, but that's how you would do it.
« Last Edit: June 24, 2016, 11:59:34 am by iViscosity »
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline OpticPotatOS

  • Jr. Member
  • **
  • Posts: 53
  • Karma: 0
  • GLaDOS
    • Gaming for Everyone
Re: Derma Refuses to Work.. Again
« Reply #2 on: June 24, 2016, 12:25:11 pm »
THANK YOU SO MUCH! IT WORKS! IT WORKS!!! WOOOO!

Sorry, I've been working on this command for a short while, and it always has SOMETHING to go wrong.
My website isn't my website, rather, it's the gaming network my sever is connected to.

ttt.gfe.nu

Unforeseen Consequences

  • Print