HUD with custom materials. Pink checkerboard error.

Hello, I am currently making a custom HUD for my DarkRP server. I created the image in PS, converted the file into a VTF, and also created the VMF. I saved the file(s) in my garrysmod/materials/darkrp_themes folder. I created the darkrp_themes folder myself. I am editing the default DarkRP cl_hud.lua file ( can be found here -> https://github.com/FPtje/DarkRP/blob/master/gamemode/modules/hud/cl_hud.lua ). The code below is how I am drawing the HUD.


local function DoActualHUD()
--If the variables table has not be initialized, initialize it
LocalPlayer().DarkRPVars = LocalPlayer().DarkRPVars or {}
 
--If the money is not set, don't do anything
local v1 = LocalPlayer().DarkRPVars.money
if not v1 then v1 = "" end
 
--If the salary is not set, don't do anything
local v2 = LocalPlayer().DarkRPVars.salary
if not v2 then v2 = "" end

--Drawing
	local dzghud = Material( "materials/darkrp_themes/dzghud" )

	surface.SetMaterial(dzghud);
	surface.SetDrawColor(255,255,255,255);
	surface.DrawTexturedRect( ScrW()/2-371, 0,  742,46);
end

local function DrawHUD()
    local shouldDraw = hook.Call("HUDShouldDraw", GAMEMODE, "DarkRP_HUD")
    if shouldDraw == false then return end

    Scrw, Scrh = ScrW(), ScrH()
    RelativeX, RelativeY = 0, Scrh

    shouldDraw = hook.Call("HUDShouldDraw", GAMEMODE, "DarkRP_LocalPlayerHUD")
    shouldDraw = shouldDraw ~= false
    if shouldDraw then
        --Background
		DoActualHUD()
        GunLicense()
    end
    Agenda()
    DrawVoiceChat()
    LockDown()

    Arrested()
    AdminTell()
end


Unfortunately, I can’t seem to make it show the custom image, it just gives me the checkerboard :frowning:
Any help would be greatly appreciated. Thank you!

You shouldn’t initialize the Material inside of a chunk of code which runs every frame, which in this case is the DoActualHUD function. This isn’t going to cause the error you’re experiencing though.

Does your VMT point to the proper path of the VTF file? You said you made the VTF then moved the files so the path might be wrong. Also, it’s probably better to use a PNG for HUD elements as they are easier to manage.

I tried removing my VMT and VTF files and replacing them with a PNG and it still didn’t work.


"UnlitGeneric"
{
   "$basetexture" "materials/darkrp_themes/dzghud"
   "$vertexalpha" 1
   "$vertexcolor" 1
}

The above code was my VMT file.

Remove materials/ from the material string in your code. It should be Material( “darkrp_themes/dzghud” ). Sorry, I should’ve noticed that the first time.

Still nothing :confused: I’m very confused

You need to make sure the users are downloading the texture using [lua]reserouce.AddFile[/lua].

You seem to not have specified the file extension.


local dzghud = Material( "materials/darkrp_themes/dzghud.png" ) -- Add .png or .jpg or whatever

Wow… I honestly feel stupid. Thank you, man.