Custom HUD issue with both GMod12 and 13.

I’ve created a custom HUD for a gamemode that’s in the making, but I’m having some weird trouble getting it to correctly draw on the screen.

When I originally designed and coded the script, it worked flawlessly. The HUD looked beautiful, and I thought I was done messing with it. However, after transferring my Garry’s Mod 12 files from one computer to another (An exact copy and paste from one Steam directory to another, mind you) the script draws a missing texture. I’ve triple-checked the code, and it parses with no problems. It points to the correct directory and to the correct file, and I’ve verified that the file is in the directory specified. I’ve also verified that the file is not corrupt by opening it in VTFEdit, and it looked fine to me.

This was first encountered after transferring to a new computer. I’m encountering the same problem once again with the first computer, except this time in Garry’s Mod 13. I have no idea what’s wrong. Does anybody have any ideas?

The function in question is below.

[lua]
function DrawHudBackground()
local HUD = surface.GetTextureID(“MonopolyInterface/hud”)
surface.SetTexture(HUD)
surface.SetDrawColor(255, 255, 255, 255)
surface.DrawTexturedRect(0, 0, ScrW(), ScrH())
end
[/lua]

Well, i usually make the dumb mistake of editing Gmod 12 files while Im in Gmod 13, and I was wondered what the hell is going on. Check if you are doing the same thing.

Nope. The files in Notepad++ all lead to the Garry’s Mod Beta directory.

Good idea, though.

[lua]
function DrawHudBackground()
local HUD = surface.GetTextureID(“MonopolyInterface/hud”)
surface.SetTexture(HUD)
surface.SetDrawColor(Color(255, 255, 255, 255))
surface.DrawTexturedRect(0, 0, ScrW(), ScrH())
end
[/lua]

garry changed it so that any setcolor() or getcolor() or anything of the sort requires (color(r,g,b,a)) instead of just (r,g,b,a)

I changed it and it didn’t change anything, BUT you did make me look at the .VMT file and realize that it was pointing to the wrong base texture. It’s fixed now and looking beautiful. Thank you. =)

you’re welcome anyways, that was really the only other possible problem

You know you can use .png files in GMod 13, instead of .vtf files which you have to create first… Just saying.

I recommend using .png files for a lossless rendered image, because if you use .vtf’s then when the player has their texture details turned down, it blurs the image.


    surface.SetMaterial( Material( "icon16/brick.png" ) );
    surface.SetDrawColor( Color(255, 255, 255, 255) );
    surface.DrawTexturedRect( 128, 128, 16, 16 );

Above code draws the brick icon at the location 128, 128 with the scale 16x16.

You can also use surface.SetDrawColor( Color( 255, 255, 255, 255 ) ); to adjust the color of the sprite.

When you resize the sprite, the filter is “Nearest Neighbor” which means you can stretch a 16x16 image to 64x64 and it’ll look pixelated instead of smoothed.