you have the fps.DoClick outsice of the vgui.Create DButton function. how do you expect that to work?
local fps = vgui.Create("DButton", melon)
fps:SetParent(prop)
fps:SetText("FPS")
fps:SetTextColor(Color(44, 62, 80))
fps:SetPos(300, 80)
fps:SetSize(70, 24)
fps.Paint = function()
surface.SetDrawColor(236, 240, 241)
surface.DrawRect(0, 0, fps:GetWide(), fps:GetTall())
end
fps.DoClick = function()
surface.PlaySound("garrysmod/content_downloaded.wav")
end
local fpss = false
function onclick()
fpss = not fpss
if fpss then
RunConsoleCommand("net_graph 1000")
else
RunConsoleCommand("net_graph 0")
end
no man, put the fps.DoClick right under the fps:SetSize
This is an example of how to properly use Derma. Compare my code to yours and try to understand what you're doing wrong with your code.
local btn = vgui.Create("DButton")
btn:SetText("Clicked 0 times")
btn:SetTextColor(color_white)
btn:SetPos(100, 100)
btn:SetSize(150, 50)
function btn:Paint(w, h)
surface.SetDrawColor(color_black)
surface.DrawRect(0, 0, w, h)
end
function btn:DoClick()
self.Clicked = (self.Clicked or 0) + 1
self:SetText(
string.format(
"Clicked %i time%s",
self.Clicked,
self.Clicked ~= 1 and "s" or ""
)
)
end
It's okay. Thank you.
Sorry, you need to Log In to post a reply to this thread.