GetNWInt with derma not updating

I have a derma gui where i can up skill levels with a function. Now when i up them, it doesnt update me GetNWInt. I have to close my derma gui and reopen it to see it update. Is there a way to refresh my derma after it runs through my function???

Remember values are static not dynamic.
The best way to work around this with derma is to use a think hook. Alternatively you could replace the derma elements Think function (easyest way in SOME cases). I’ll show you the best way.

[lua]
local Panel = vgui.Create(“DLabel”)
local
function Panel:Think()
local Text = LocalPlayer:GetNWString(“Awesomeness”)
if ( Text != self:GetText() ) then
self:SetText( Text )
self:SizeToContents()
end
end
[/lua]
Notice i changed the Hook function of a DLabel element.
also used a meta function (self refers to the DLabel itself).
Will set the text of the DLabel to the Networed String “Awesomeness” when ever it changes.

So for a button, it would look something like this?


local SkillBTN = vgui.Create( "DButton", guiList )
function Panel:Think()  
local Text = LocalPlayer:GetNWInt("Skillone")  
if ( Text != self:GetText() ) then  
self:SetText( Text )  
self:SizeTocontents()  
end 
SkillBTN:SetPos( 25, 50 )
SkillBTN:SetSize( 150, 50 )
SkillBTN.DoClick = function ()
    RunConsoleCommand( "increaseSkill" )
end

Yes that looks like it should work fine.
But in the case of DButtons don’t use self:SizeToContents().

Give it ago and then come back and post back any bugs.

Ok i gots some problems with my script

attempt to call method ‘GetText’ (a nil value)

here is the code


local DermaButton2 = vgui.Create( "DButton" )
			function DermaButton2:Think()  
			local Text = LocalPlayer():GetNWInt("Agility")  
			if ( Text != self:GetText() ) then  
			self:SetText( Text )    
			end 
			DermaButton2:SetPos( 25, 50 )
			DermaButton2:SetSize( 150, 50 )
			DermaButton2.DoClick = function ()
				RunConsoleCommand( "increaseAgility" )
			end
			end
			DermaList:AddItem( DermaButton2 )

Thats odd i’m sure DButton has a :GetText() function.

So i think i fixed it, but i wanna know if this will cause any problems…


local DermaButton1 = vgui.Create( "DButton" )
			DermaButton1:SetParent( DermaList ) -- Set parent to our "DermaPanel"
			function DermaButton1:Think()
			self:SetText( LocalPlayer():GetNWInt( "Strength" ) )
			end
			DermaButton1:SetPos( 25, 50 )
			DermaButton1:SetSize( 150, 50 )
			DermaButton1.DoClick = function ()
				RunConsoleCommand("IncreaseStrength")
			end
			DermaList:AddItem( DermaButton1 )