how do i change the material of a vgui panel?
//Thanks
Well, by default panels don't use a texture to draw, but a background. However, if you wanted to draw a texture in the background you could do something like this:
[lua]function panel:Paint()
draw.TexturedQuad({
texture = surface.GetTextureID("your/texture"),
color = color_white,
x = 0,
y = 0,
w = self:GetWide(),
h = self:GetTall(),
})
end[/lua]
Obviously replacing "your/texture" with the texture you want to use.
For reference:
[b][url=wiki.garrysmod.com/?title=Panel.Paint]Panel.Paint [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[b][url=http://wiki.garrysmod.com/?title=Draw.TexturedQuad]Draw.TexturedQuad [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[CODE]function RPLicenseWeaponsTab()
local weaponspanel = vgui.Create("DPanelList")
weaponspanel:SetSpacing(1)
weaponspanel:EnableHorizontal(false)
weaponspanel:EnableVerticalScrollbar(true)
function weaponspanel:Update()
self:Clear(true)
local Explanation = vgui.Create("DLabel")
Explanation:SetText(LANGUAGE.license_tab)
Explanation:SizeToContents()
self:AddItem(Explanation)
for k,v in pairs(DefaultWeapons) do
if type(v) == "table" and v.name then
local checkbox = vgui.Create("DCheckBoxLabel")
checkbox:SetText(v.name)
checkbox:SetValue(GetConVarNumber("licenseweapon_"..v.class))
function checkbox.Button:Toggle()
if ( self:GetChecked() == nil || !self:GetChecked() ) then
self:SetValue( true )
else
self:SetValue( false )
end
local tonum = {}
tonum[false] = "0"
tonum[true] = "1"
RunConsoleCommand("rp_licenseweapon_".. v.class, tonum[self:GetChecked()])
end
self:AddItem(checkbox)
end
end
local OtherWeps = vgui.Create("DLabel")
OtherWeps:SetText(LANGUAGE.license_tab_other_weapons)
OtherWeps:SizeToContents()
self:AddItem(OtherWeps)
for k,v in pairs(weapons.GetList()) do
if type(v) == "table" and v.Classname then
if v.Classname and not string.find(string.lower(v.Classname), "base") and v.Classname ~= "" then
local checkbox = vgui.Create("DCheckBoxLabel")
if v.PrintName then
checkbox:SetText(v.PrintName)
else
checkbox:SetText(v.Classname)
end
checkbox:SetValue(GetConVarNumber("licenseweapon_"..v.Classname))
function checkbox.Button:Toggle()
if ( self:GetChecked() == nil || !self:GetChecked() ) then
self:SetValue( true )
else
self:SetValue( false )
end
local tonum = {}
tonum[false] = "0"
tonum[true] = "1"
RunConsoleCommand("rp_licenseweapon_".. string.lower(v.Classname), tonum[self:GetChecked()])
end
self:AddItem(checkbox)
end
end
end
end
weaponspanel:Update()
return weaponspanel
end
[/CODE]
where should i put it?
Anywhere before return weaponspanel.
im getting the error[CODE]
GRSRP\gamemode\showteamtabs.lua:1176: attempt to index global 'panel' (a nil value)
[/CODE]
and this is how it looks
[IMG]http://img218.imageshack.us/img218/2913/picfor.jpg[/IMG]
Replace panel with weaponspanel.
[QUOTE=MakeR;21566198]Replace panel with weaponspanel.[/QUOTE]
thanks man , i learned something new today :)
Sorry, you need to Log In to post a reply to this thread.