• Adding custom icons to HUD
    11 replies, posted
hey, i'm trying to add some custom icons to my hud, but it just shows as black and purple. I created a new folder called "materials", and added both icons into it. Then, went to my hud lua file, and did this include("materials\zorexd\zhud\ui/wanted.png") include("materials\zorexd\zhud\ui/license.png") I tried without the license.png and without. both of them dont work, the hud just wont show up. When I delete these two lines, hud comes back, but icons show up as black and purple. Am I doing it right, should I include these files in autorun? Thanks in advance
no no the include function is to include lua files. Not materials. This is part of my first HUD Code, that uses PNG files to display textures. There is a difference if you use png files, or vtf/vmt files. but you use png, so i give you this: local picture = Material( "materials/picture.png" ) -- creates a variable of the png material surface.SetMaterial( picture ) -- gives the surface the picture to render surface.SetDrawColor( 255, 255, 255 ) -- sets the color. 255,255,255 is white (the original pic color) surface.DrawTexturedRect( 0, 0, 50, 50 ) -- renders the picture on the players screen. start point 0,0 size 50, 50 from here you can figure it out yourself.
But my png is a custom file. Did I put it in the right folder?
local wan = Material("materials/wanted.png") local function wanted() if LocalPlayer():getDarkRPVar("wanted") then surface.SetMaterial(wan) surface.SetDrawColor(255,255,255,255) surface.DrawTexturedRect(195, 990,16,16) end end local Gun = Material("materials/license.png") local function License()     if LocalPlayer():getDarkRPVar("HasGunlicense") then         surface.SetMaterial(Gun)         surface.SetDrawColor(255, 255, 255, 255)         surface.DrawTexturedRect(240, 962, 16, 16)     end end
how about you just try it out? asking if it might work before trying it out is useless
I did, they dont. Thats why I asked.
you need resource.AddFile()
You don't need "materials/" when you call Material because it starts in the materials directory. You also need to call resource.AddFile if you want clients to download the materials.
Do I call "resource.AddFile" in the autorun or in the lua file?
You call it in any serverside file that gets run and the path you're using there doesn't match what you have in the OP.
What do you mean?
Sorry, you need to Log In to post a reply to this thread.