Gmod Derma button variable

Hi i am trying to make a button have a countdown from 5 (timer already made) But i cannot seem to get it to work.

I am trying to make the text look like:

“Abort (5)” and it counts down

Here is my vgui. How would i make it refresh to display the new variable value?


hook.Add("Initialize", netvar, function()
                hook.Add("Think", netvar, function()
                        local diff = cTime() - lastPing
                        if diff > (occurance + 5) then

                        local DLabel1
                        local DLabel2
                        local DLabel3
                        local DButton1
                        local DFrame1
                        if (open == 0) then
                            open = 1
                        DFrame1 = vgui.Create('DFrame')
                        DFrame1:SetSize(458, 176)
                        DFrame1:Center()
                        DFrame1:SetTitle('Server Crashed!')
                        DFrame1:SetDeleteOnClose(false)
                        DFrame1:ShowCloseButton(false)
                        DFrame1:SetBackgroundBlur(true)
                        DFrame1:MakePopup()

                        DButton1 = vgui.Create('DButton')
                        DButton1:SetParent(DFrame1)
                        DButton1:SetSize(70, 25)
                        DButton1:SetPos(196, 144)
                        DButton1:SetText('Abort ('..diff..')')
                        DButton1.DoClick = function() 
                        DFrame1:Close()


                    end

                        DLabel3 = vgui.Create('DLabel')
                        DLabel3:SetParent(DFrame1)
                        DLabel3:SetPos(322, 99)
                        DLabel3:SetText('5')
                        DLabel3:SizeToContents()
                        DLabel3:SetTextColor(Color(255, 0, 0, 255))
                        DLabel2 = vgui.Create('DLabel')
                        DLabel2:SetParent(DFrame1)
                        DLabel2:SetPos(142, 98)
                        DLabel2:SetText('Connecting to one of our servers in:')
                        DLabel2:SizeToContents()

                        DLabel1 = vgui.Create('DLabel')
                        DLabel1:SetParent(DFrame1)
                        DLabel1:SetPos(155, 46)
                        DLabel1:SetText('Server Crashed or Rebooted!')
                        DLabel1:SizeToContents()
                        DLabel1:SetTextColor(Color(240, 240, 240, 255))

                        end
                    end

bump still need help

First of all, you are missing two ) symbols after two last ends… Wait, it may be even worse than that. Anyway, you should check it.

Secondy, don’t use Think hook like that for this, use



DButton1.Think = function( self ) self:SetText( "do magic here" )  end


Take note that this will override default DButton.Think, so you probably should fix it.

[lua]
DButton1.OldThink = DButton1.Think
DButton1.Think = function( self ) self:OldThink() self:SetText( “do magic here” ) end
[/lua]

This has what you need: https://dl.dropboxusercontent.com/u/26074909/tutoring/_redistributable/acecooldev_base/gamemode/addons/_development/examples/cl_hook_motd.lua

It shows setting up an motd, and having a button count-down ( using timers ).

Thanks guys!