For some reason the resource.AddFile isn't working for me.
Directory and Code:
garrysmod\addons\swrphud\lua\autorun\server
resource.AddFile("materials/leftbg.png")
resource.AddFile("materials/starwarswallet.png")
garrysmod\addons\swrphud\lua\autorun\client
local leftbg = Material( "materials/leftbg.png" )
local starwarswallet = Material( "materials/starwarswallet.png" )
hook.Add( "HUDPaint", "ImagePaint", function()
surface.SetMaterial( leftbg )
surface.SetDrawColor( 255, 255, 255 )
surface.DrawTexturedRect( 400, ScrH() - 200, 100, 100 )
surface.SetMaterial( starwarswallet )
surface.SetDrawColor( 255, 255, 255 )
surface.DrawTexturedRect( 400, ScrH() - 500, 100, 100 )
end )
Garrysmod, or any valve source games don't accept pngs as inputs. Everything must be in the 'VTF' format.
I'd recommend VTFEditor by Nem for converting it.
Ok, thanks. Will try.
I've always used pngs, and it's worked.
this is how I've used it...
resource.AddFile("materials/berkark/chestmenui.png")
You need to make a folder inside the materials folder, then create your material inside that one.
-materials being the folder from the garrysmod folder
-berkark being my own folder inside materials for my own images
-chestmenui.png is the name of the image inside the folder.
I have tried both ways and it still doesn't work.
Code:
CLIENT
leftbg = Material("materials/swrphud/leftbg.png")
starwarswallet = Material("materials/swrphud/starwarswallet.png")
hook.Add( "HUDPaint", "ImagePaint", function()
surface.SetMaterial( leftbg )
surface.SetDrawColor( 255, 255, 255 )
surface.DrawTexturedRect( 400, ScrH() - 200, 100, 100 )
surface.SetMaterial( starwarswallet )
surface.SetDrawColor( 255, 255, 255 )
surface.DrawTexturedRect( 400, ScrH() - 500, 100, 100 )
end )
SERVER
resource.AddFile("materials/swrphud/leftbg.png")
resource.AddFile("materials/swrphud/starwarswallet.png")
are the materials all definitely in the right place? have you got a folder in your garrys mod files/addons called swrphud?
This is the directory to the materials
garrysmod\addons\swrphud\materials\swrphud
when you say it still doesn't work, is it texture errors, nothing showing at all? any errors?
No errors, but still black and purple textures.
have you restarted your game etc
It is downloading the textures, just when I put it in the clientside I guess it doesn't find that material?
Is this addon being ran on a server or your game. If it's a server you need to add the materials to your game.
Server. I am trying to have it so players don't need to sub to my hud on the workshop. I have seen many other huds do this, but for some reason it doesn't work for me.
try putting it just in autorun, that's where I've had it work too. I know it's a server side function but give it a go.
Still didn't work.
The only way to do it is to make a workshop addon giving the Clients the textures to download, FastDL might work, although I've not tried it.
Do you guys know how to draw text over an image?
Yes they do. In fact, in Garry's Mod, PNG files often work better than VTF files. surface.SetMaterial uses a Material, which can absolutely be a PNG.
Sorry, you need to Log In to post a reply to this thread.